Skip to content

Instantly share code, notes, and snippets.

@alphapapa
Last active April 24, 2017 01:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphapapa/2cd1f1fc6accff01fec06946844ef5a5 to your computer and use it in GitHub Desktop.
Save alphapapa/2cd1f1fc6accff01fec06946844ef5a5 to your computer and use it in GitHub Desktop.
org-avy-refile-as-child: Refile Org heading as child of heading selected with Avy
(defun ap/org-avy-refile-as-child ()
"Refile current heading as first child of heading selected with `avy.'"
;; Inspired by `org-teleport': http://kitchingroup.cheme.cmu.edu/blog/2016/03/18/Org-teleport-headlines/
(interactive)
(let* ((org-reverse-note-order t)
(pos (save-excursion
(avy-with avy-goto-line (avy--generic-jump (rx bol "*") nil avy-style))
(point)))
(filename (buffer-file-name (or (buffer-base-buffer (current-buffer))
(current-buffer))))
(rfloc (list nil filename nil pos)))
(org-refile nil nil rfloc)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment