From f63b507f07531f6bc5e196b38bb815321b07eee7 Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Mon, 16 Sep 2024 13:46:21 -0700 Subject: [PATCH] Replace personal C-a hack with mwim --- thoom-emacs/modules/thoom-editing.el | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/thoom-emacs/modules/thoom-editing.el b/thoom-emacs/modules/thoom-editing.el index cfcbe30..5d859c3 100644 --- a/thoom-emacs/modules/thoom-editing.el +++ b/thoom-emacs/modules/thoom-editing.el @@ -1,19 +1,20 @@ (provide 'thoom-editing) -;; 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 "^") - (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" . move-to-beginnings))) +(use-package mwim + :ensure t + :bind (([remap move-beginning-of-line] . mwim-beginning) + ([remap move-end-of-line] . mwim-end)) + :init + (defun thoom/mwim-org-heading-beginning () + (mwim-point-at + (move-beginning-of-line nil) + (skip-syntax-forward "_ " (line-end-position)))) + :config + (setq mwim-beginning-position-functions + '(mwim-code-beginning + thoom/mwim-org-heading-beginning + mwim-comment-beginning + mwim-line-beginning))) ;; Allow movement during isearch ;; C/M-v move to next/previous match not currently visible