diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-org.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el index 312a0e0..46054a7 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -518,6 +518,9 @@ global value. A numeric prefix sets MAXLEVEL (defaults to 2)." ;;; Links +(add-to-list 'load-path "~/src/emacs/org-link-edit/") +(require 'org-link-edit-autoloads) + (setq org-link-search-must-match-exact-headline nil) (after 'org @@ -552,9 +555,38 @@ The hook functions and `org-store-link' are called within a (dired (file-name-directory (org-element-property :path el))))) +(after 'org-link-edit + (defun km/org-link-edit-slurp-link () + "Slurp trailing text into link. + + \[link\]extra -> \[\[linkextra\]\] + +After slurping, return the slurped text and move point to the +beginning of the link." + (interactive) + (cl-multiple-value-bind (beg end link desc) (org-link-edit--get-link-data) + (when (progn (goto-char end) (looking-at "[^ \t\n]+")) + (let ((slurped (match-string-no-properties 0))) + (setq link (concat link slurped) + end (match-end 0)) + (delete-region beg end) + (insert (org-make-link-string link desc)) + (goto-char beg) + slurped))))) + (define-key km/org-prefix-map "d" 'km/org-open-link-directory) (define-key km/global-org-map "l" 'km/org-store-link) +(define-key km/org-prefix-map "." + (defhydra hydra-org-link-edit () + "Org Link Edit" + ("j" org-link-edit-forward-slurp "forward slurp") + ("k" org-link-edit-forward-barf "forward barf") + ("u" org-link-edit-backward-slurp "backward slurp") + ("i" org-link-edit-backward-barf "backward barf") + ("l" km/org-link-edit-slurp-link "slurp link" :color blue) + ("q" nil "cancel"))) + ;;; Export |