mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-14 05:43:04 +00:00
avy.el (avy-org-refile-as-child): Don't refile when avy aborted
And ensure refiled heading is visible by calling org-reveal in the after-refile hook. When the avy session is aborted with C-g, avy--generic-jump returns t. Now we detect that and do not attempt to refile. Fixes #258
This commit is contained in:
parent
df4c4ac488
commit
bcc0cb0891
26
avy.el
26
avy.el
@ -2014,17 +2014,23 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
|
|||||||
"Refile current heading as first child of heading selected with `avy.'"
|
"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/
|
;; Inspired by `org-teleport': http://kitchingroup.cheme.cmu.edu/blog/2016/03/18/Org-teleport-headlines/
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((rfloc (save-excursion
|
|
||||||
(let* ((org-reverse-note-order t)
|
(let* ((org-reverse-note-order t)
|
||||||
(pos (avy-with avy-goto-line
|
(marker (save-excursion
|
||||||
(avy--generic-jump (rx bol (1+ "*") (1+ space))
|
(avy-with avy-goto-line
|
||||||
nil avy-style)
|
(unless (eq 't (avy--generic-jump (rx bol (1+ "*") (1+ space))
|
||||||
(point)))
|
nil avy-style))
|
||||||
(filename (buffer-file-name (or (buffer-base-buffer (current-buffer))
|
;; `avy--generic-jump' returns t when aborted with C-g.
|
||||||
(current-buffer)))))
|
(point-marker)))))
|
||||||
(list nil filename nil pos)))))
|
(filename (buffer-file-name (or (buffer-base-buffer (marker-buffer marker))
|
||||||
;; org-refile must be called outside of the excursion
|
(marker-buffer marker))))
|
||||||
(org-refile nil nil rfloc)))
|
(rfloc (list nil filename nil marker))
|
||||||
|
;; Ensure the refiled heading is visible.
|
||||||
|
(org-after-refile-insert-hook (if (member 'org-reveal org-after-refile-insert-hook)
|
||||||
|
org-after-refile-insert-hook
|
||||||
|
(cons #'org-reveal org-after-refile-insert-hook))))
|
||||||
|
(when marker
|
||||||
|
;; Only attempt refile if avy session was not aborted.
|
||||||
|
(org-refile nil nil rfloc))))
|
||||||
|
|
||||||
(defun avy-org-goto-heading-timer (&optional arg)
|
(defun avy-org-goto-heading-timer (&optional arg)
|
||||||
"Read one or many characters and jump to matching Org headings.
|
"Read one or many characters and jump to matching Org headings.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user