From c20226a1ef5fbdfd3e71e2ef8654ee19994c0f2f Mon Sep 17 00:00:00 2001 From: Aymeric Agon-Rambosson Date: Sat, 25 Nov 2023 10:07:49 -0500 Subject: [PATCH] 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 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 | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lisp/indent.el b/lisp/indent.el index 89de0a1d7d1..f64049d64b2 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -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 -- 2.39.2