Skip to content

Instantly share code, notes, and snippets.

@mmarshall540
Last active April 6, 2025 14:24
Show Gist options
  • Select an option

  • Save mmarshall540/58b0374295f2760c9ee5058d3225a22d to your computer and use it in GitHub Desktop.

Select an option

Save mmarshall540/58b0374295f2760c9ee5058d3225a22d to your computer and use it in GitHub Desktop.
Beginning-of-line or indentation on one key
(defun my/mbol-advice (arg)
"With prefix ARG other than 1, return t.
Else, go `back-to-indentation', and if point hasn't moved, return t."
(if (eq arg 1)
(let ((start (point)))
(back-to-indentation)
(eq start (point)))
t))
(advice-add 'move-beginning-of-line :before-while 'my/mbol-advice)
@mmarshall540
Copy link
Author

mmarshall540 commented Apr 5, 2025

Updated so that if a prefix argument other than 1 is passed, move-beginning-of-line will be immediately called using the prefix argument, since back-to-indentation doesn't use a prefix argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment