Update move-to-beginnings to work with org headers

This commit is contained in:
2024-04-18 13:43:35 -07:00
parent 8bc3bf8e1c
commit 1f782981fe

View File

@@ -1,17 +1,19 @@
(provide 'thoom-editing)
;; TODO Support org headings and comments
(defun thoom/move-to-beginnings ()
"Move between the two beginnings of a line: The very beginning,
and the first non-whitespace character."
;; TODO Support comments
(defun move-to-beginnings ()
"Move between possible beginnings of a line:
The very beginning, the start of an org headline, and the first non-whitespace character."
(interactive "^")
(if (bolp)
(back-to-indentation)
(move-beginning-of-line 1)))
(cond
((not (bolp))
(move-beginning-of-line 1))
((org-at-heading-p)
(search-forward-regexp "*+ *" nil t))
(t (back-to-indentation))))
(use-package emacs
:bind (("C-a" . thoom/move-to-beginnings)))
:bind (("C-a" . move-to-beginnings)))
;; Allow movement during isearch
;; C/M-v move to next/previous match not currently visible