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

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

bug#47936: closed (AucTeX and electric-pair-mode)


From: GNU bug Tracking System
Subject: bug#47936: closed (AucTeX and electric-pair-mode)
Date: Wed, 21 Apr 2021 20:10:02 +0000

Your message dated Wed, 21 Apr 2021 21:54:57 +0200
with message-id <87y2dbqu1k.fsf@gnu.org>
and subject line Re: bug#47936: AucTeX and electric-pair-mode
has caused the debbugs.gnu.org bug report #47936,
regarding AucTeX and electric-pair-mode
to be marked as done.

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


-- 
47936: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=47936
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: AucTeX and electric-pair-mode Date: Wed, 21 Apr 2021 17:31:10 +0000
Hi,

an annoyance I have with auctex is it's interaction with
electric-pair-mode. If both LaTeX-electric-left-right-brace and
electric-pair-mode are enabled, typing '(' inserts "())", because both
AucTeX and the electric function insert a closing parentheses. I still
want to keep LaTeX-electric-left-right-brace enabled, because it handles
TeX-specific parentheses (\{, \left <something>, ...) better.

I'm not sure if there is a real fix for this, but I couldn't find
anything and my go-to solution of locally removing
electric-pair-post-self-insert-function from post-self-insert-hook is
also unstable.

The attached patch would propose a solution that respects
electric-pair-mode and doesn't insert an extra closing pair if
enabled. It seems to work on my system, and if there are no issues it
would be great if something along these lines could be done to avoid
this behaviour.

-- 
        Philip K.

>From d47f68ddf8c7d1d9c90adbc2ea9ee09588010ce3 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Wed, 21 Apr 2021 19:25:16 +0200
Subject: [PATCH] Improve handling for parentheses with electric-pair-mode

---
 latex.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/latex.el b/latex.el
index 83d50caf..512639d5 100644
--- a/latex.el
+++ b/latex.el
@@ -2979,6 +2979,8 @@ is nil, consult user which brace should be used."
     (if rmacro
         (insert TeX-esc rmacro))
     (cond
+     ((and (string= (char-to-string last-command-event) lbrace)
+           electric-pair-mode))
      ((and TeX-arg-right-insert-p rbrace)
       (insert rbrace))
      (rmacro
-- 
2.30.2


--- End Message ---
--- Begin Message --- Subject: Re: bug#47936: AucTeX and electric-pair-mode Date: Wed, 21 Apr 2021 21:54:57 +0200 User-agent: mu4e 1.5.11; emacs 28.0.50
Philip Kaludercic <philipk@posteo.net> writes:

Hi Philip,

> an annoyance I have with auctex is it's interaction with
> electric-pair-mode. If both LaTeX-electric-left-right-brace and
> electric-pair-mode are enabled, typing '(' inserts "())", because both
> AucTeX and the electric function insert a closing parentheses. I still
> want to keep LaTeX-electric-left-right-brace enabled, because it
> handles TeX-specific parentheses (\{, \left <something>, ...) better.

Ok, makes sense.

> The attached patch would propose a solution that respects
> electric-pair-mode and doesn't insert an extra closing pair if
> enabled.

> @@ -2979,6 +2979,8 @@ is nil, consult user which brace should be used."
>      (if rmacro
>          (insert TeX-esc rmacro))
>      (cond
> +     ((and (string= (char-to-string last-command-event) lbrace)
> +           electric-pair-mode))
>       ((and TeX-arg-right-insert-p rbrace)
>        (insert rbrace))
>       (rmacro

LGTM, I've applied it with slight modifications and a ChangeLog style
commit message following our/Emacs conventions.

Thanks a lot, Philip!

Bye,
Tassilo


--- End Message ---

reply via email to

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