emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67158: closed ([PATCH] Repair tab-always-indent)


From: GNU bug Tracking System
Subject: bug#67158: closed ([PATCH] Repair tab-always-indent)
Date: Wed, 29 Nov 2023 14:27:01 +0000

Your message dated Wed, 29 Nov 2023 16:25:51 +0200
with message-id <837cm07i1c.fsf@gnu.org>
and subject line Re: bug#67158: [PATCH] Repair tab-always-indent
has caused the debbugs.gnu.org bug report #67158,
regarding [PATCH] Repair tab-always-indent
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
67158: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67158
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] Repair tab-always-indent Date: Tue, 14 Nov 2023 00:43:17 +0100 User-agent: mu4e 1.10.7; emacs 29.1
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 :

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.

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'

Attachment: 0001-Repair-tab-always-indent.patch
Description: Text Data


--- End Message ---
--- Begin Message --- Subject: Re: bug#67158: [PATCH] Repair tab-always-indent Date: Wed, 29 Nov 2023 16:25:51 +0200
> Cc: 67158@debbugs.gnu.org
> Date: Sun, 26 Nov 2023 08:56:04 -0500
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> > - In commit c20226a1ef5, you used memql to compare syn to '(2 4   5), and
> >   memq to compare syn to '(2 4 5 1). I'd say both are   equivalent in this
> >   case, so why having used each of them once   rather than the same twice ?
> 
> Oops, not sure how that happened.  They should both use the same (tho
> either `memq` or `memql` does the trick).

I fixed that on master.

> > - Any chance this commit gets cherry-picked for the 29.2 bugfix release ?
> 
> I'll let Eli or Stefan make the decision.

I've cherry-picked it.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]