all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Patrick <patrick@math.utah.edu>
Cc: 32076@debbugs.gnu.org
Subject: bug#32076: 24.5; Electric behavior of dollar sign using AUCTeX
Date: Sun, 08 Jul 2018 15:37:01 +0100	[thread overview]
Message-ID: <87601pztde.fsf@gmail.com> (raw)
In-Reply-To: <woy9efggt1mg.fsf@libra.math.utah.edu> (patrick@math.utah.edu's message of "Fri, 06 Jul 2018 16:56:07 -0600")

Patrick <patrick@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)






  reply	other threads:[~2018-07-08 14:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 22:56 bug#32076: 24.5; Electric behavior of dollar sign using AUCTeX Patrick
2018-07-08 14:37 ` João Távora [this message]
2018-07-10  5:32   ` Patrick Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87601pztde.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=32076@debbugs.gnu.org \
    --cc=patrick@math.utah.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.