Giter Site home page Giter Site logo

quickroam's People

Contributors

meedstrom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

quickroam's Issues

quickroam-insert inserts link at top of buffer, regardless of (point)

I expect quickroam-insert to insert in the same way org-roam-node-insert does, which is to insert the link at (point). Instead, the link is inserted on the second line of the file and anything on that line is pushed to the side.

I suspect it's because of this bit:

;; Try to strip the todo keyword, whatever counts as todo syntax
;; in the target file.  Fail silently because it matters not much.
(ignore-errors
  (org-roam-with-file
      (expand-file-name (plist-get node :file) org-roam-directory)
      nil
    (widen)
    (goto-char 1)
    (forward-line (1- (plist-get node :line-number)))
    (setq link-desc (nth 4 (org-heading-components)))))

I don't understand the purpose of this code. Is the title not an appropriate link description? What's that about stripping the TODO keyword? Does this assume something about the current buffer and/or the buffer of the node we've selected?

I restored my expected behavior by using a modified quickroam-insert:

(defun cashpw/quickroam-insert ()
  "Fast substitute for `org-roam-node-insert'."
  (interactive nil org-mode)
  (require 'org-roam)
  (when (or (hash-table-empty-p quickroam-cache)
            (not quickroam-mode))
    (quickroam-reset))
  (let* ((beg nil)
         (end nil)
         (region-text (when (region-active-p)
                        (setq beg (region-beginning))
                        (setq end (region-end))
                        (org-link-display-format
                         (buffer-substring-no-properties beg end))))
         (title (completing-read "Node: " quickroam-cache nil nil nil 'org-roam-node-history))
         (node (gethash title quickroam-cache))
         (id (plist-get node :id))
         (link-desc (or region-text title)))
    (if node
        (atomic-change-group
          (when region-text
            (delete-region beg end))
          (insert (org-link-make-string (concat "id:" id) link-desc))
          (run-hook-with-args 'org-roam-post-node-insert-hook id link-desc))
      (atomic-change-group
        (org-roam-capture-
         :node (org-roam-node-create :title title)
         :props (append
                 (when region-text
                   (list :region (cons (set-marker (make-marker) beg)
                                       (set-marker (make-marker) end))))
                 (list :link-description link-desc
                       :finalize 'insert-link)))))))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.