summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gregory <jgrg@autistici.org>2019-07-17 21:47:51 -0300
committerJonathan Gregory <jgrg@autistici.org>2019-07-17 21:47:51 -0300
commit6f3011995d0cdca6ab4d810b065d5f563a42517d (patch)
tree83f5b68e114b5d00dbe3d8129a7085a360a51d7d
parent8c3189f0d3c227fc235c59a8267ddb15b043a978 (diff)
Fix bug when preselecting headings
* helm-org.el (helm-org-in-buffer-preselect): Do it. This happens if the heading contains brackets: [#A] etc. I'm also moving the point to the closest heading.
-rw-r--r--helm-org.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/helm-org.el b/helm-org.el
index cd338366..5dadcd8d 100644
--- a/helm-org.el
+++ b/helm-org.el
@@ -307,11 +307,14 @@ will be refiled."
(org-refile nil nil rfloc))))))
(defun helm-org-in-buffer-preselect ()
- (if (org-on-heading-p)
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))
- (save-excursion
- (outline-previous-visible-heading 1)
- (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
+ "Return the current or closest visible heading as a regexp string."
+ (save-excursion
+ (cond ((org-at-heading-p) (forward-line 0))
+ ((org-before-first-heading-p)
+ (outline-next-visible-heading 1))
+ (t (outline-previous-visible-heading 1)))
+ (regexp-quote (buffer-substring-no-properties (point-at-bol)
+ (point-at-eol)))))
(defun helm-org-run-refile-heading-to ()
(interactive)