From 1f782981fec2df49c7bfb61e12d3d9ab49eb6fb2 Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Thu, 18 Apr 2024 13:43:35 -0700 Subject: [PATCH] Update move-to-beginnings to work with org headers --- thoom-emacs/modules/thoom-editing.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/thoom-emacs/modules/thoom-editing.el b/thoom-emacs/modules/thoom-editing.el index c0d4aa3..5c1203b 100644 --- a/thoom-emacs/modules/thoom-editing.el +++ b/thoom-emacs/modules/thoom-editing.el @@ -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