[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a14811f: Don't hard-code ignored functions in `indent-according-t
From: |
Lars Ingebrigtsen |
Subject: |
master a14811f: Don't hard-code ignored functions in `indent-according-to-mode' |
Date: |
Fri, 5 Feb 2021 07:36:10 -0500 (EST) |
branch: master
commit a14811fc96d63157acbf398034ef7f1b5fd14d5d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Don't hard-code ignored functions in `indent-according-to-mode'
* lisp/indent.el (indent-line-ignored-functions): New variable
(bug#26945).
(indent-according-to-mode): Use it.
---
etc/NEWS | 5 +++++
lisp/indent.el | 11 ++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index dddc150..61efdc7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2189,6 +2189,11 @@ define-obsolete-variable-alias.
* Lisp Changes in Emacs 28.1
+---
+** New variable 'indent-line-ignored-functions'.
+This allows modes to cycle through a set of indentation functions
+appropriate for those modes.
+
** New function 'garbage-collect-maybe' to trigger GC early.
---
diff --git a/lisp/indent.el b/lisp/indent.el
index 5c5270b..4a55507 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -83,22 +83,23 @@ This variable has no effect unless `tab-always-indent' is
`complete'."
(const :tag "Unless at a word, parenthesis, or punctuation."
'word-or-paren-or-punct))
:version "27.1")
+(defvar indent-line-ignored-functions '(indent-relative
+ indent-relative-maybe
+ indent-relative-first-indent-point)
+ "Values that are ignored by `indent-according-to-mode'.")
(defun indent-according-to-mode ()
"Indent line in proper way for current major mode.
Normally, this is done by calling the function specified by the
variable `indent-line-function'. However, if the value of that
-variable is `indent-relative' or `indent-relative-first-indent-point',
+variable is present in the `indent-line-ignored-functions' variable,
handle it specially (since those functions are used for tabbing);
in that case, indent by aligning to the previous non-blank line."
(interactive)
(save-restriction
(widen)
(syntax-propertize (line-end-position))
- (if (memq indent-line-function
- '(indent-relative
- indent-relative-maybe
- indent-relative-first-indent-point))
+ (if (memq indent-line-function indent-line-ignored-functions)
;; These functions are used for tabbing, but can't be used for
;; indenting. Replace with something ad-hoc.
(let ((column (save-excursion
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a14811f: Don't hard-code ignored functions in `indent-according-to-mode',
Lars Ingebrigtsen <=