From: Andrea Greselin <greselin.andrea@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: How to control pairing of quotes in text-mode with electric-pair-mode?
Date: Fri, 5 Jul 2019 11:40:49 +0200 [thread overview]
Message-ID: <CAJ_oJbY9Ru28=Et3Kp9+xnVDFw8QjjFc9k6sTzaqDfNsJ2XH5Q@mail.gmail.com> (raw)
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
next reply other threads:[~2019-07-05 9:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-05 9:40 Andrea Greselin [this message]
2019-07-11 11:22 ` How to control pairing of quotes in text-mode with electric-pair-mode? Noam Postavsky
2019-07-12 16:35 ` Andrea Greselin
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='CAJ_oJbY9Ru28=Et3Kp9+xnVDFw8QjjFc9k6sTzaqDfNsJ2XH5Q@mail.gmail.com' \
--to=greselin.andrea@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.