lang/org: add goto-visible & refile-to-visible commands

- Bind 'gsh' to goto-visible command in org-mode
- Bind '<localleader> g v' to goto-visible
- Bind '<localleader> r v' to refile-to-visible
- Add avy package to lang/org module

Powered by avy.
This commit is contained in:
Henrik Lissner 2019-12-06 17:00:01 -05:00
parent 77b0784075
commit c8cfa31a1e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 45 additions and 0 deletions

View file

@ -62,3 +62,22 @@
(lambda (_p _coll _pred _rm _ii _h default &rest _)
default)))
(org-refile)))
(defvar org-after-refile-insert-hook)
;; Inspired by org-teleport and alphapapa/alpha-org
;;;###autoload
(defun +org/refile-to-visible ()
"Refile current heading as first child of visible heading selected with Avy."
(interactive)
(when-let (marker (+org-headline-avy))
(let* ((buffer (marker-buffer marker))
(filename
(buffer-file-name (or (buffer-base-buffer buffer)
buffer)))
(heading
(org-with-point-at marker
(org-get-heading 'no-tags 'no-todo)))
;; Won't work with target buffers whose filename is nil
(rfloc (list heading filename nil marker))
(org-after-refile-insert-hook (cons #'org-reveal org-after-refile-insert-hook)))
(org-refile nil nil rfloc))))