How to obtain/implement a beginning-of-defun drop-in replacement that is idempotent?

i.e., if I already am at the beginning of a defun, beginning-of-defun should do nothing, rather than jumping to the beginning of the previous defun.

I acknowledge though that the following case would be ambiguous:

(defun ...)

| ;; <------ cursor is here. What should the function do: jump to next or previous defun?

(defun ...)
  • Can't you just invoke end-of-defun before calling beginning-of-defun to get the behavior you describe? – Willy Lee Mar 2 '19 at 23:16
  • Fantastic, that will do. – deprecated Mar 3 '19 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.