GNU bug report logs - #32076
24.5; Electric behavior of dollar sign using AUCTeX

Previous Next

Package: emacs;

Reported by: Patrick <patrick <at> math.utah.edu>

Date: Sat, 7 Jul 2018 00:09:02 UTC

Severity: normal

Merged with 40865

Found in versions 24.5, 26.3

Full log


View this message in rfc822 format

From: João Távora <joaotavora <at> gmail.com>
To: Patrick <patrick <at> math.utah.edu>
Cc: 32076 <at> debbugs.gnu.org
Subject: bug#32076: 24.5; Electric behavior of dollar sign using AUCTeX
Date: Sun, 08 Jul 2018 15:37:01 +0100
Patrick <patrick <at> math.utah.edu> writes:

> See the following StackExchange question: <a
> href="https://emacs.stackexchange.com/questions/42278/electric-behavior-of-dollar-sign-using-auctex">https://emacs.stackexchange.com/questions/42278/electric-behavior-of-dollar-sign-using-auctex</a>
> Reporting as suggested by Joao Tavora.

Thanks Patrick,

In general we want the bug descriptions Emacs bug tracker to be as
self-contained as possible.  So here's the simple way to reproduce this:

    emacs -Q
    M-x tex-mode
    M-x electric-pair-mode
    type $, two dollars correctly appear and point is in the middle
    type something
    type $, again.  Two dollars appear again instead of skipping over
    the dollar.

The reason for this is that `electric-pair-skip-if-helps-balance'
doesn't recognize the $ (paired-delimiter) syntax.  It's easy to open a
door for this in elec-pair.el (see attached partial patch), but Emacs'
built-in tex-mode doesn't have anything to plug into the new
electric-pair-between-paired-delimiters-function var (or does it?)

AUCTeX, on the other hand, has `texmathp' which seems to do nicely.
Should we lift this function into Emacs, or use some other, perhaps more
generic, technique of discovering wether point is between two $$?

João

diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 7df7098295..3040a5be6d 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -428,6 +428,9 @@ electric-pair-inhibit-if-helps-balance
                   (electric-pair--unbalanced-strings-p char))))
        (insert-char char)))))
 
+(defvar electric-pair-between-paired-delimiters-function #'ignore
+  "Function returning non-nil if point between paired delimiters.")
+
 (defun electric-pair-skip-if-helps-balance (char)
   "Return non-nil if skipping CHAR would benefit parentheses' balance.
 
@@ -451,7 +454,9 @@ electric-pair-skip-if-helps-balance
                            ((car innermost)
                             (not (eq (cdr outermost) pair)))))))
                  ((eq syntax ?\")
-                  (electric-pair--inside-string-p char))))
+                  (electric-pair--inside-string-p char))
+                 ((eq syntax ?\$)
+                  (funcall electric-pair-between-paired-delimiters-function))))
        (insert-char char)))))
 
 (defun electric-pair-default-skip-self (char)





This bug report was last modified 3 years and 354 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.