all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gustavo Barros <gusbrs.2016@gmail.com>
To: 36307@debbugs.gnu.org
Cc: "João Távora" <joaotavora@gmail.com>
Subject: bug#36307: 26.2; Interaction between electric-pair and electric-quote
Date: Mon, 19 Apr 2021 12:53:28 -0300	[thread overview]
Message-ID: <87sg3mfeyv.fsf@gmail.com> (raw)
In-Reply-To: <87impptkpi.fsf@gmail.com>

Hi All,

This is an old report which, admittedly, was originally somewhat 
confusing (not my best job at that).  But I came back to this issue 
recently and I think I got a better grasp of what's going on, and can 
thus provide a clear diagnostic of where the problem lies.

There's an interaction between `electric-quote-mode' and 
`electric-pair-mode' such that `electric-pair-inhibit-predicate' is 
ignored for electric quotes.  What I failed to get when I originally 
reported is that, given the depths set at each of these modes' hooks, 
`electric-indent-post-self-insert-function' runs before 
`electric-pair-post-self-insert-function'.  This is why all of my 
attempts to tamper with the former (some of which I shared in this 
thread) had one or another shortcoming.  This is also the reason why 
`electric-pair-inhibit-predicate' is ignored by the later, since when 
`electric-pair-post-self-insert-function' runs, the electric quote 
substitution has already taken place.  However, the call to 
`electric-pair-inhibit-predicate' is behind a check on the syntax class 
of character being paired (or not) (the check is `(memq syntax '(?\( ?\" 
?\$))').  The curved quotes, depending on the syntax table of the 
major-mode, but usually, will fail this test, thus the pair will be 
inserted regardless of `electric-pair-inhibit-predicate'.  As far as I 
get, the same is true for `electric-pair-skip-whitespace-function', but 
I cannot generate a case where this is problematic (perhaps this is 
handled on `electric-quote-mode's side, I'm not sure).

A simple test to check that this is the case is the following.  Starting 
from `emacs -Q' (I'm running 27.2):

#+begin_src emacs-lisp
(defun my-electric-pair-inhibit-all ()
  t)

(setq electric-pair-inhibit-predicate 'my-electric-pair-inhibit-all)

(setq electric-quote-context-sensitive t)
(setq electric-quote-replace-double t)

(electric-pair-mode 1)
#+end_src

Now, this has thus far enabled `electric-pair-mode' but in a way that 
all and any pairing is (or should be) inhibited by 
`my-electric-pair-inhibit-all'.  Play with common pairs, particularly 
with the quotes, and see that this is actually the case: pairing does 
not take place.  Well, this is not true always, it is true for 
`lisp-interaction-mode', and for `org-mode'.  It is not true for 
`text-mode', and I presume that for the same reason that the pairing of 
curved quotes fail to get inhibited elsewhere: the syntax class of the 
character in question.

Now enable `electric-quote-mode', and play again with common pairs, 
particularly with quotes.  I've tested on `lisp-interaction-mode', 
`org-mode' and `text-mode'.  Of course, in the case of the first, and 
all those derived from `prog-mode', electric quoting is only done (by 
default) in comments and strings, but whenever the (opening) curved 
quote kicks in, their (closing) pair comes along.  Which demonstrates 
that `electric-pair-inhibit-predicate' is being ignored.

I don't know what is the best fix for this, but I hope this clearer 
diagnostic of the problem is of some use.  Since this is a long standing 
issue/report, and since I think this report circumscribes the issue much 
better than the original, I took the liberty of CC'ing João, as the 
maintainer of `elec-pair.el', I hope that is not inappropriate.

Best regards,
Gustavo.






  reply	other threads:[~2021-04-19 15:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20 13:20 bug#36307: 26.2; Interaction between electric-pair and electric-quote Gustavo Barros
2019-06-26 17:37 ` Gustavo Barros
2019-09-18 20:26   ` Gustavo Barros
2021-04-19 15:53     ` Gustavo Barros [this message]
2021-04-19 19:12       ` João Távora
2021-04-19 19:16         ` João Távora
2021-04-19 19:55           ` Gustavo Barros
2021-10-19  9:35         ` Gustavo Barros

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=87sg3mfeyv.fsf@gmail.com \
    --to=gusbrs.2016@gmail.com \
    --cc=36307@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    /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.