]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't hard-code ignored functions in `indent-according-to-mode'
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 5 Feb 2021 12:36:01 +0000 (13:36 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 5 Feb 2021 12:36:06 +0000 (13:36 +0100)
* lisp/indent.el (indent-line-ignored-functions): New variable
(bug#26945).
(indent-according-to-mode): Use it.

etc/NEWS
lisp/indent.el

index dddc150af1439f7948325fe4edf64d120fde8cb9..61efdc7b612768f367a343da471935ddc57f855f 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2189,6 +2189,11 @@ define-obsolete-variable-alias.
 \f
 * 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.
 
 ---
index 5c5270b07c411024232930dce0870de9aa1d42d5..4a5550786d5964e2f550fe274c389fc6bf17d4c9 100644 (file)
@@ -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