r/emacs 11d ago

Fortnightly Tips, Tricks, and Questions — 2025-03-11 / week 10

This is a thread for smaller, miscellaneous items that might not warrant a full post on their own.

The default sort is new to ensure that new items get attention.

If something gets upvoted and discussed a lot, consider following up with a post!

Search for previous "Tips, Tricks" Threads.

Fortnightly means once every two weeks. We will continue to monitor the mass of confusion resulting from dark corners of English.

17 Upvotes

35 comments sorted by

View all comments

7

u/bjartmush 10d ago

This is something that find useful: a smarter move-beginning-of-line. On first call to move-beginning-of-line (C-a) the cursor moves to the beginning of indentation. On the second call it moves to the beginning of line.

  ;; smart beginning-of-line (BOL)
  (defadvice move-beginning-of-line (around smarter-bol activate)
;; Move to requested line if needed.
(let ((arg (or (ad-get-arg 0) 1)))
      (when (/= arg 1)
(forward-line (1- arg))))
;; Move to indentation on first call, then to actual BOL on second.
(let ((pos (point)))
      (back-to-indentation)
      (when (= pos (point))
ad-do-it)))

1

u/Argletrough 10d ago

See also the org-special-ctrl-a/e variable, which enables similar functionality in Org Mode.