From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67158: [PATCH] Repair tab-always-indent Date: Sat, 25 Nov 2023 11:31:36 +0200 Message-ID: <835y1qdvrb.fsf@gnu.org> References: <87msvhqkx6.fsf@X570GP> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8264"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67158@debbugs.gnu.org To: Aymeric Agon-Rambosson , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 25 10:32:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r6p1J-0001wE-Mv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Nov 2023 10:32:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6p15-00069S-Jl; Sat, 25 Nov 2023 04:31:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6p13-00069A-JE for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 04:31:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6p13-00081C-Az for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 04:31:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6p18-0003mS-9R for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 04:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Nov 2023 09:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67158 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67158-submit@debbugs.gnu.org id=B67158.170090471114513 (code B ref 67158); Sat, 25 Nov 2023 09:32:02 +0000 Original-Received: (at 67158) by debbugs.gnu.org; 25 Nov 2023 09:31:51 +0000 Original-Received: from localhost ([127.0.0.1]:37819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6p0w-0003m1-RW for submit@debbugs.gnu.org; Sat, 25 Nov 2023 04:31:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6p0v-0003ln-7H for 67158@debbugs.gnu.org; Sat, 25 Nov 2023 04:31:50 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6p0k-00080W-7t; Sat, 25 Nov 2023 04:31:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Mo0RwCAH7dQPt442EzEko2hRYqlBZAqh6Y3E12Ht6TU=; b=f3DJZUmePU6K vg9dbJdSfQI17sT0IIheVB6HbmI/MD/RS7BT/0LELLFq73WvZDoK4sRGtWvnz5A9dAMJ0MChDBCb7 sZc0tiB5jMXeb5LyPZbnNxnIwvBzyZB7qmq0S0O9HNrjYDkU+Z7Tbsw4kVgKHegCcZWfPcYbJMkwh jdnD8t69uCI7Y1oEWFYySARCzyccgio4MuirNdYPV/jS1ODoT4EsPZ9hiOwi7ild1LuZ1WT67Unzq 8ne5bjRlIu+yWoYV3AsGaCJ1Z902rYO1CwO/3iVTX+GWMns74bFFo1oQ6iIfjmDE27w056jayGDpO gNAH7HpPvAACkT57FONiHQ==; In-Reply-To: <87msvhqkx6.fsf@X570GP> (message from Aymeric Agon-Rambosson on Tue, 14 Nov 2023 00:43:17 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274935 Archived-At: > From: Aymeric Agon-Rambosson > Date: Tue, 14 Nov 2023 00:43:17 +0100 > > tab-first-completion does not work correctly at the moment, and > indent-for-tab-command must be modified in several ways to take > its meaning into account correctly : > > Since syntax-after returns a list and not an integer, the forms > like (eql 2 syn) will always return nil. This was introduced by > commit c7234011518. We partially revert that commit, although it > would have been possible to solve this issue by wrapping > (syntax-after (point)) with syntax-class like so : Stefan, any comments on these two patches? > diff --git a/lisp/indent.el b/lisp/indent.el > index 89de0a1d7d1..e5f2acdd33b 100644 > --- a/lisp/indent.el > +++ b/lisp/indent.el > @@ -171,7 +171,7 @@ prefix argument is ignored." > (let ((old-tick (buffer-chars-modified-tick)) > (old-point (point)) > (old-indent (current-indentation)) > - (syn (syntax-after (point)))) > + (syn (syntax-class (syntax-after (point))))) > > ;; Indent the line. > (or (not (eq (indent--funcall-widened indent-line-function) 'noindent)) > > Feel free to change the commit if you prefer this way. > > Then, the semantic of word-or-paren and word-or-paren-or-punct is > not correctly implemented : in the current state, if > tab-first-completion is set to word-or-paren, and if > tab-always-indent is set to complete, and we press tab in the > middle of a word, the word will get autocompleted despite the > docstring promising the contrary because : > > The following form will correctly return nil : > > (and (memq tab-first-completion > '(word word-or-paren word-or-paren-or-punct)) > (not (memq 2 syn))) > > But this one will return non-nil : > > (and (memq tab-first-completion > '(word-or-paren word-or-paren-or-punct)) > (not (or (eql 4 syn) > (eql 5 syn)))) > > Since syn is equal to (2) (we are within a word). > > The constraints need to be cumulative, since they are evaluated > until one succeeds. So we simply cumulate them so that > word-or-paren cannot succeed where word could not, and > word-or-paren-or-punct cannot succeed when word-or-paren could > not. > > This is my first contribution with email. I have tried to follow > the guidelines specified in CONTRIBUTE and Sending-Patches. Feel > free to change the commit message or ask me to do it. I have > already attributed the Copyright to the FSF because of a previous > contribution. > > >From 8afb0f0ec8e645b41c8da2a5d5156e63fc04bdbd Mon Sep 17 00:00:00 2001 > From: Aymeric Agon-Rambosson > Date: Tue, 14 Nov 2023 00:03:46 +0100 > > Take the values word, word-or-paren, word-or-paren-or-punct correctly > into account in the function indent-for-tab-command : > * syntax-after returns a list, not an integer, either memq or member > must be used (partial revert of c7234011518). > * the constraints on completion-at-point must be cumulative when we go > from word to word-or-paren to word-or-paren-or-punct. Otherwise, tab > always complete with values word-or-paren or word-or-paren-or-punct, > which is not what the docstring seems to say > --- > lisp/indent.el | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/lisp/indent.el b/lisp/indent.el > index 89de0a1d7d1..de8101dc76e 100644 > --- a/lisp/indent.el > +++ b/lisp/indent.el > @@ -191,13 +191,17 @@ prefix argument is ignored." > (eolp)) > (and (memq tab-first-completion > '(word word-or-paren word-or-paren-or-punct)) > - (not (eql 2 syn))) > + (not (memq 2 syn))) > (and (memq tab-first-completion > '(word-or-paren word-or-paren-or-punct)) > - (not (or (eql 4 syn) > - (eql 5 syn)))) > + (not (or (memq 2 syn) > + (memq 4 syn) > + (memq 5 syn)))) > (and (eq tab-first-completion 'word-or-paren-or-punct) > - (not (eql 1 syn))))) > + (not (or (memq 2 syn) > + (memq 4 syn) > + (memq 5 syn) > + (memq 1 syn)))))) > (completion-at-point)) > > ;; If a prefix argument was given, rigidly indent the following > -- > 2.39.2