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

* bug#57057: Prevent ‘electric-quote-mode’ from merging single quotes
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-09 18:43 UTC (permalink / raw)
  To: Andrea Greselin; +Cc: 57057

Andrea Greselin <greselin.andrea@gmail.com> writes:

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

Makes sense to me, so I've now pushed your change to Emacs 29 (with some
changes to the doc string to conform to our conventions).

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?





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

* bug#57057: Prevent ‘electric-quote-mode’ from merging single quotes
  2022-08-09 18:43 ` Lars Ingebrigtsen
@ 2022-08-09 21:43   ` Andrea Greselin
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Greselin @ 2022-08-09 21:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 57057

[-- Attachment #1: Type: text/plain, Size: 86 bytes --]

Hi Lars, I've already done the paperwork.
Thanks for taking care of the patch.
Andrea

[-- Attachment #2: Type: text/html, Size: 163 bytes --]

^ permalink raw reply	[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).