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: Tue, 14 Nov 2023 14:39:29 +0200 Message-ID: <837cmktsou.fsf@gnu.org> References: <87msvhqkx6.fsf@X570GP> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22631"; 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 Tue Nov 14 13:40:41 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 1r2sif-0005hp-EA for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Nov 2023 13:40:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2siM-0002Ds-Kr; Tue, 14 Nov 2023 07:40:22 -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 1r2siK-0002Dk-JM for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 07:40:21 -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 1r2siK-0000mY-8p for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 07:40:20 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r2sj0-00032A-Bz for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 07:41: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: Tue, 14 Nov 2023 12:41: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.169996563511613 (code B ref 67158); Tue, 14 Nov 2023 12:41:02 +0000 Original-Received: (at 67158) by debbugs.gnu.org; 14 Nov 2023 12:40:35 +0000 Original-Received: from localhost ([127.0.0.1]:60303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2siY-00031D-V4 for submit@debbugs.gnu.org; Tue, 14 Nov 2023 07:40:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2siW-000310-OF for 67158@debbugs.gnu.org; Tue, 14 Nov 2023 07:40:33 -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 1r2shi-0000XV-S6; Tue, 14 Nov 2023 07:39:44 -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=xPb9ujul6vxOqqTIHXlKrHR9MRWfrDUQT+TjH+K6RSw=; b=hDSgD1Dhmovn csVyC77dMbtLo/yFfpAwNtXUOA2Yi9XQhOKeEHCLiM7A8rRQxdacF48Thu5GD7Q9502kpB0ueCha3 5ek6LJ9I8ymILr4r6fPB7M+EFzzw0tFaY8rRKdf+/ednhT4+oNIAggYwf2/PNgn74poM+YMJMCr9R 04dyf8d+pqUSsFESHphdWBOH6vuGExgTGFE1Yl369ygdJe1JRprzhFOG/tAqwIyaVatqF6Mw2oU6a gz/lOtGGdPCxYcOOpPWwjqfswkDVYrhrd+NKqT6GSD6/BXSt7rHxjHcfmGqFWKhJAtmB/oA6y6NDa vyVpdFjuKTD3723GF0dxZQ==; 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:274308 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 : Could you please post a recipe which reproduces the problems you describe? > 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 : > > 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. Thanks. I added Stefan to this discussion.