From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aymeric Agon-Rambosson Newsgroups: gmane.emacs.bugs Subject: bug#67158: [PATCH] Repair tab-always-indent Date: Tue, 14 Nov 2023 00:43:17 +0100 Message-ID: <87msvhqkx6.fsf@X570GP> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6326"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.7; emacs 29.1 To: 67158@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 14 08:41:04 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 1r2o2i-0001Sb-Fe for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Nov 2023 08:41:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2o23-0005Mp-G7; Tue, 14 Nov 2023 02:40:23 -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 1r2o21-0005MS-K4 for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:40:22 -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 1r2o21-0003LV-B7 for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:40:21 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r2o2h-0003lj-5Q for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2023 02:41:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Aymeric Agon-Rambosson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Nov 2023 07:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67158 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169994761514394 (code B ref -1); Tue, 14 Nov 2023 07:41:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Nov 2023 07:40:15 +0000 Original-Received: from localhost ([127.0.0.1]:59957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2o1t-0003jy-Vu for submit@debbugs.gnu.org; Tue, 14 Nov 2023 02:40:15 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:52588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2gbI-0007TQ-Pf for submit@debbugs.gnu.org; Mon, 13 Nov 2023 18:44:17 -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 1r2gaX-0002lt-AZ for bug-gnu-emacs@gnu.org; Mon, 13 Nov 2023 18:43:29 -0500 Original-Received: from forward102c.mail.yandex.net ([178.154.239.213]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r2gaU-0005V3-Nu for bug-gnu-emacs@gnu.org; Mon, 13 Nov 2023 18:43:29 -0500 Original-Received: from mail-nwsmtp-smtp-production-main-84.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-84.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:a712:0:640:cd83:0]) by forward102c.mail.yandex.net (Yandex) with ESMTP id 606DE60916 for ; Tue, 14 Nov 2023 02:43:19 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-84.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Ihsj7lrBYmI0-GPUYTMRB; Tue, 14 Nov 2023 02:43:18 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1699918998; bh=5qMF6oKQBJTRbSQgw7Pxerukn2NhateXJwPTNi665iU=; h=Message-ID:Subject:To:From:Date; b=Ku2Ceur4pfPrry4WChEd4/6M6H1B6+cstFq/MG2YwIbFEMNH/vTzfNLpvURKAJvKQ llwd3w2LoNlEgNapE5/aXya8pwZ0dwaSGNzHbeVmDLdJIGTqV8rTSWbaF7Iqp23Q4o eo1VdAbGwX9LFXPJBItiicEoliLPTZErjipUUEAQ= Authentication-Results: mail-nwsmtp-smtp-production-main-84.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.com Received-SPF: pass client-ip=178.154.239.213; envelope-from=aymeric.agon@yandex.com; helo=forward102c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 14 Nov 2023 02:40:10 -0500 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:274295 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Tags: patch Tags: patch Hello, 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 : --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=class.patch 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)) --=-=-= Content-Type: text/plain; format=flowed 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. Best, Aymeric Agon-Rambosson In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2023-09-20, modified by Debian built on X570GP Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation=aot --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation=aot --with-x=yes --with-x-toolkit=lucid --with-toolkit-scroll-bars --without-gsettings 'CFLAGS=-g -O2 -ffile-prefix-map=/build/emacs-G3TJOq/emacs-29.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Repair-tab-always-indent.patch >From 8afb0f0ec8e645b41c8da2a5d5156e63fc04bdbd Mon Sep 17 00:00:00 2001 From: Aymeric Agon-Rambosson Date: Tue, 14 Nov 2023 00:03:46 +0100 Subject: [PATCH] Repair tab-always-indent 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 --=-=-=--