From: Lars Ingebrigtsen Date: Fri, 5 Feb 2021 12:36:01 +0000 (+0100) Subject: Don't hard-code ignored functions in `indent-according-to-mode' X-Git-Tag: emacs-28.0.90~3918 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a14811fc96d63157acbf398034ef7f1b5fd14d5d;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index dddc150af14..61efdc7b612 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 5c5270b07c4..4a5550786d5 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