summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorFilipp Gunbin <fgunbin@fastmail.fm>2022-08-05 21:01:10 +0300
committerFilipp Gunbin <fgunbin@fastmail.fm>2022-08-05 21:03:03 +0300
commit50730a8b04ede381c958600a1400efe8d04d9dfc (patch)
treebb4ae4d2afb64b21e0b2a73bc2ea8fa9583a4252 /lisp/emacs-lisp
parent0da97d66852a0ab3abd3b4116825338636ac9367 (diff)
downloademacs-50730a8b04ede381c958600a1400efe8d04d9dfc.tar.gz
emacs-50730a8b04ede381c958600a1400efe8d04d9dfc.tar.bz2
emacs-50730a8b04ede381c958600a1400efe8d04d9dfc.zip
Add variable end-of-defun-moves-to-eol
* lisp/emacs-lisp/lisp.el (end-of-defun-moves-to-eol): New variable. (end-of-defun): Use it.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 4b85414943a..cc8185e4530 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -507,6 +507,13 @@ It is called with no argument, right after calling `beginning-of-defun-raw'.
So the function can assume that point is at the beginning of the defun body.
It should move point to the first position after the defun.")
+(defvar end-of-defun-moves-to-eol t
+ "Defines whether `end-of-defun' moves to eol before doing
+everything else.
+
+Set this to nil in major mode if this movement affects mode's
+decisions about context in an unwanted way.")
+
(defun buffer-end (arg)
"Return the \"far end\" position of the buffer, in direction ARG.
If ARG is positive, that's the end of the buffer.
@@ -538,7 +545,9 @@ report errors as appropriate for this kind of usage."
(push-mark))
(if (or (null arg) (= arg 0)) (setq arg 1))
(let ((pos (point))
- (beg (progn (end-of-line 1) (beginning-of-defun-raw 1) (point)))
+ (beg (progn (when end-of-defun-moves-to-eol
+ (end-of-line 1))
+ (beginning-of-defun-raw 1) (point)))
(skip (lambda ()
;; When comparing point against pos, we want to consider that
;; if point was right after the end of the function, it's