mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-13 21:33:05 +00:00
parent
8556274978
commit
245b5d62fe
69
avy.el
69
avy.el
@ -538,39 +538,6 @@ multiple DISPLAY-FN invokations."
|
|||||||
(funcall avy-handler-function char))))
|
(funcall avy-handler-function char))))
|
||||||
(cdar alist))))
|
(cdar alist))))
|
||||||
|
|
||||||
;; ** Org-mode
|
|
||||||
|
|
||||||
(defun avy-org-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 ((rfloc (save-excursion
|
|
||||||
(let* ((org-reverse-note-order t)
|
|
||||||
(pos (avy-with avy-goto-line
|
|
||||||
(avy--generic-jump (rx bol (1+ "*") (1+ space))
|
|
||||||
nil avy-style)
|
|
||||||
(point)))
|
|
||||||
(filename (buffer-file-name (or (buffer-base-buffer (current-buffer))
|
|
||||||
(current-buffer)))))
|
|
||||||
(list nil filename nil pos)))))
|
|
||||||
;; org-refile must be called outside of the excursion
|
|
||||||
(org-refile nil nil rfloc)))
|
|
||||||
|
|
||||||
(defun avy-org-goto-heading-timer (&optional arg)
|
|
||||||
"Read one or many characters and jump to matching Org headings.
|
|
||||||
The window scope is determined by `avy-all-windows' (ARG negates it)."
|
|
||||||
(interactive "P")
|
|
||||||
(let ((avy-all-windows (if arg
|
|
||||||
(not avy-all-windows)
|
|
||||||
avy-all-windows)))
|
|
||||||
(avy-with avy-goto-char-timer
|
|
||||||
(avy--process
|
|
||||||
(avy--read-candidates
|
|
||||||
(lambda (input)
|
|
||||||
(format "^\\*+ .*\\(%s\\)" input)))
|
|
||||||
(avy--style-fn avy-style))
|
|
||||||
(org-back-to-heading))))
|
|
||||||
|
|
||||||
;;** Rest
|
;;** Rest
|
||||||
(defun avy-window-list ()
|
(defun avy-window-list ()
|
||||||
"Return a list of windows depending on `avy-all-windows'."
|
"Return a list of windows depending on `avy-all-windows'."
|
||||||
@ -1905,6 +1872,42 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
|
|||||||
(error
|
(error
|
||||||
(set-mark-command 4)))))
|
(set-mark-command 4)))))
|
||||||
|
|
||||||
|
;; ** Org-mode
|
||||||
|
(defvar org-reverse-note-order)
|
||||||
|
(declare-function org-refile "org")
|
||||||
|
(declare-function org-back-to-heading "org")
|
||||||
|
|
||||||
|
(defun avy-org-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 ((rfloc (save-excursion
|
||||||
|
(let* ((org-reverse-note-order t)
|
||||||
|
(pos (avy-with avy-goto-line
|
||||||
|
(avy--generic-jump (rx bol (1+ "*") (1+ space))
|
||||||
|
nil avy-style)
|
||||||
|
(point)))
|
||||||
|
(filename (buffer-file-name (or (buffer-base-buffer (current-buffer))
|
||||||
|
(current-buffer)))))
|
||||||
|
(list nil filename nil pos)))))
|
||||||
|
;; org-refile must be called outside of the excursion
|
||||||
|
(org-refile nil nil rfloc)))
|
||||||
|
|
||||||
|
(defun avy-org-goto-heading-timer (&optional arg)
|
||||||
|
"Read one or many characters and jump to matching Org headings.
|
||||||
|
The window scope is determined by `avy-all-windows' (ARG negates it)."
|
||||||
|
(interactive "P")
|
||||||
|
(let ((avy-all-windows (if arg
|
||||||
|
(not avy-all-windows)
|
||||||
|
avy-all-windows)))
|
||||||
|
(avy-with avy-goto-char-timer
|
||||||
|
(avy--process
|
||||||
|
(avy--read-candidates
|
||||||
|
(lambda (input)
|
||||||
|
(format "^\\*+ .*\\(%s\\)" input)))
|
||||||
|
(avy--style-fn avy-style))
|
||||||
|
(org-back-to-heading))))
|
||||||
|
|
||||||
(provide 'avy)
|
(provide 'avy)
|
||||||
|
|
||||||
;;; avy.el ends here
|
;;; avy.el ends here
|
||||||
|
Loading…
x
Reference in New Issue
Block a user