unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57057: Prevent ‘electric-quote-mode’ from merging single quotes
@ 2022-08-08 12:25 Andrea Greselin
  2022-08-09 18:43 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Greselin @ 2022-08-08 12:25 UTC (permalink / raw)
  To: 57057


[-- Attachment #1.1: Type: text/plain, Size: 532 bytes --]

Hello everyone,

I stumbled a couple of times across a behaviour by
‘electric-quote-mode’ where it replaces two consecutive single
electric quotes with a single double quote. To see what I mean open
‘emacs -Q’, enable ‘electric-quote-mode’ and ‘text-mode’, then hit `
or ' twice. I find it more annoying than helpful so I changed
‘electric-quote-post-self-insert-function’ to make it check an option
that can disable this behaviour. Do you think it can be included in
Emacs?

Best of wishes,
Andrea

[-- Attachment #1.2: Type: text/html, Size: 581 bytes --]

[-- Attachment #2: electric.patch --]
[-- Type: text/x-patch, Size: 1949 bytes --]

diff --git a/lisp/electric.el b/lisp/electric.el
index 042fc90..08ac447 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -534,6 +534,13 @@ closing double quote otherwise."
   :version "26.1"
   :type 'boolean :safe #'booleanp :group 'electricity)
 
+(defcustom electric-quote-replace-consecutive t
+  "Non-nil means to replace a pair of opening or closing single
+quotes with the corresponding double quote when the second quote
+of the pair is entered electrically (i.e. by typing ` or ')."
+  :version "29.1"
+  :type 'boolean :safe #'booleanp :group 'electricity)
+
 (defvar electric-quote-inhibit-functions ()
   "List of functions that should inhibit electric quoting.
 When the variable `electric-quote-mode' is non-nil, Emacs will
@@ -586,7 +593,8 @@ This requotes when a quoting key is typed."
                               (memq (char-syntax (char-before))
                                     '(?\s ?\())))
                         (setq backtick ?\')))
-               (cond ((search-backward (string q< backtick) (- (point) 2) t)
+               (cond ((and electric-quote-replace-consecutive
+                           (search-backward (string q< backtick) (- (point) 2) t))
                       (replace-match (string q<<))
                       (when (and electric-pair-mode
                                  (eq (cdr-safe
@@ -600,7 +608,8 @@ This requotes when a quoting key is typed."
                      ((search-backward "\"" (1- (point)) t)
                       (replace-match (string q<<))
                       (setq last-command-event q<<)))
-             (cond ((search-backward (string q> ?') (- (point) 2) t)
+             (cond ((and electric-quote-replace-consecutive
+                         (search-backward (string q> ?') (- (point) 2) t))
                     (replace-match (string q>>))
                     (setq last-command-event q>>))
                    ((search-backward "'" (1- (point)) t)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-09 21:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 12:25 bug#57057: Prevent ‘electric-quote-mode’ from merging single quotes Andrea Greselin
2022-08-09 18:43 ` Lars Ingebrigtsen
2022-08-09 21:43   ` Andrea Greselin

Code repositories for project(s) associated with this public inbox

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

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).