1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-02 21:52:04 -08:00

Repair tab-first-completion (bug#67158)

Copyright-paperwork-exempt: yes

* lisp/indent.el (indent-for-tab-command): Use `syntax-class` to fix
longstanding thinko introduced back in 2020 in commit 64c8511664.
Rework the check for `syn` because TAB always completed when
`tab-first-completion` had value `word-or-paren` or `word-or-paren-or-punct`.
This commit is contained in:
Aymeric Agon-Rambosson 2023-11-25 10:07:49 -05:00 committed by Stefan Monnier
parent efae0e68ef
commit c20226a1ef

View 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