]> git.eshelyaron.com Git - emacs.git/commitdiff
Repair `tab-first-completion` (bug#67158)
authorAymeric Agon-Rambosson <aymeric.agon@yandex.com>
Sat, 25 Nov 2023 15:07:49 +0000 (10:07 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 25 Nov 2023 15:24:39 +0000 (10:24 -0500)
Copyright-paperwork-exempt: yes

* lisp/indent.el (indent-for-tab-command): Use `syntax-class` to fix
longstanding thinko introduced back in 2020 in commit 64c851166442.
Rework the check for `syn` because TAB always completed when
`tab-first-completion` had value `word-or-paren` or `word-or-paren-or-punct`.

lisp/indent.el

index 89de0a1d7d1e3bc9e0834bb0affbf9caf7c4fc76..f64049d64b2212281ea21edf5cd0341ef221efa2 100644 (file)
@@ -170,8 +170,7 @@ prefix argument is ignored."
    (t
     (let ((old-tick (buffer-chars-modified-tick))
           (old-point (point))
-         (old-indent (current-indentation))
-          (syn (syntax-after (point))))
+         (old-indent (current-indentation)))
 
       ;; Indent the line.
       (or (not (eq (indent--funcall-widened indent-line-function) 'noindent))
@@ -185,19 +184,14 @@ prefix argument is ignored."
        ((and (eq tab-always-indent 'complete)
              (eql old-point (point))
              (eql old-tick (buffer-chars-modified-tick))
-             (or (null tab-first-completion)
-                 (eq last-command this-command)
-                 (and (eq tab-first-completion 'eol)
-                      (eolp))
-                 (and (memq tab-first-completion
-                            '(word word-or-paren word-or-paren-or-punct))
-                      (not (eql 2 syn)))
-                 (and (memq tab-first-completion
-                            '(word-or-paren word-or-paren-or-punct))
-                      (not (or (eql 4 syn)
-                               (eql 5 syn))))
-                 (and (eq tab-first-completion 'word-or-paren-or-punct)
-                      (not (eql 1 syn)))))
+             (or (eq last-command this-command)
+                 (let ((syn (syntax-class (syntax-after (point)))))
+                   (pcase tab-first-completion
+                     ('nil t)
+                     ('eol (eolp))
+                     ('word (not (eql 2 syn)))
+                     ('word-or-paren (not (memql syn '(2 4 5))))
+                     ('word-or-paren-or-punct (not (memq syn '(2 4 5 1))))))))
         (completion-at-point))
 
        ;; If a prefix argument was given, rigidly indent the following