* How to control pairing of quotes in text-mode with electric-pair-mode?
@ 2019-07-05 9:40 Andrea Greselin
2019-07-11 11:22 ` Noam Postavsky
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Greselin @ 2019-07-05 9:40 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
I'd like 'electric-pair-mode' not to pair quotes at the end of words or
following punctuation characters, as in "…end of quote" or "… end of quote."
I've written this function for 'electric-pair-inhibit-predicate', based on
'electric-pair-conservative-inhibit':
(defun my-electric-pair-inhibit (char)
(or
;; Do not pair when the same char is next.
(eq char (char-after))
;; Do not pair right before a word.
(eq (char-syntax (following-char)) ?w)
;; After a word or a punctuation character, pair parentheses but do
not pair quotes.
(when (and (> (point) 2) (char-equal char ?\"))
(or (eq (char-syntax (char-before (1- (point)))) ?w)
(eq (char-syntax (char-before (1- (point)))) ?.)))))
It works fine in 'emacs-lisp-mode' but it doesn't in 'text-mode': quotes
are still paired around words. I've noticed that it's the same with
'electric-pair-inhibit-predicate' set to
'electric-pair-conservative-inhibit', which should suppress pairing at the
beginning of words: in 'emacs-lisp-mode' both parentheses and quotes are
not paired at the beginning of words, but in 'text-mode' only parentheses
pairing is suppressed.
All the best,
Andrea
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to control pairing of quotes in text-mode with electric-pair-mode?
2019-07-05 9:40 How to control pairing of quotes in text-mode with electric-pair-mode? Andrea Greselin
@ 2019-07-11 11:22 ` Noam Postavsky
2019-07-12 16:35 ` Andrea Greselin
0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2019-07-11 11:22 UTC (permalink / raw)
To: Andrea Greselin; +Cc: Help Gnu Emacs mailing list
On Fri, 5 Jul 2019 at 08:43, Andrea Greselin <greselin.andrea@gmail.com> wrote:
> It works fine in 'emacs-lisp-mode' but it doesn't in 'text-mode': quotes
> are still paired around words. I've noticed that it's the same with
> 'electric-pair-inhibit-predicate' set to
> 'electric-pair-conservative-inhibit', which should suppress pairing at the
> beginning of words: in 'emacs-lisp-mode' both parentheses and quotes are
> not paired at the beginning of words, but in 'text-mode' only parentheses
> pairing is suppressed.
Looks like the predicate is not considered when the character comes
from electric-pair-pairs. In that case electric-pair-syntax-info
returns t for UNCONDITIONAL, and
electric-pair-post-self-insert-function doesn't call
electric-pair-inhibit-predicate.
So I guess this is not possible right now.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to control pairing of quotes in text-mode with electric-pair-mode?
2019-07-11 11:22 ` Noam Postavsky
@ 2019-07-12 16:35 ` Andrea Greselin
0 siblings, 0 replies; 3+ messages in thread
From: Andrea Greselin @ 2019-07-12 16:35 UTC (permalink / raw)
To: Noam Postavsky; +Cc: Help Gnu Emacs mailing list
Well, so be it. Thanks.
On Thu, 11 Jul 2019 at 13:22, Noam Postavsky <npostavs@gmail.com> wrote:
> On Fri, 5 Jul 2019 at 08:43, Andrea Greselin <greselin.andrea@gmail.com>
> wrote:
>
> > It works fine in 'emacs-lisp-mode' but it doesn't in 'text-mode': quotes
> > are still paired around words. I've noticed that it's the same with
> > 'electric-pair-inhibit-predicate' set to
> > 'electric-pair-conservative-inhibit', which should suppress pairing at
> the
> > beginning of words: in 'emacs-lisp-mode' both parentheses and quotes are
> > not paired at the beginning of words, but in 'text-mode' only parentheses
> > pairing is suppressed.
>
> Looks like the predicate is not considered when the character comes
> from electric-pair-pairs. In that case electric-pair-syntax-info
> returns t for UNCONDITIONAL, and
> electric-pair-post-self-insert-function doesn't call
> electric-pair-inhibit-predicate.
>
> So I guess this is not possible right now.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-12 16:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-05 9:40 How to control pairing of quotes in text-mode with electric-pair-mode? Andrea Greselin
2019-07-11 11:22 ` Noam Postavsky
2019-07-12 16:35 ` Andrea Greselin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).