summaryrefslogtreecommitdiff
path: root/lisp/electric.el
diff options
context:
space:
mode:
authorAndrea Greselin <greselin.andrea@gmail.com>2022-08-09 20:43:08 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-08-09 20:44:07 +0200
commit41169b55340878120fdf695eb4ac1fcb2679e7b8 (patch)
tree9ea792d1ea7b821a3fce85d533d3a4639ddaf3d4 /lisp/electric.el
parent744ed0ceeed7472a160fea7154939cf641205577 (diff)
downloademacs-41169b55340878120fdf695eb4ac1fcb2679e7b8.tar.gz
emacs-41169b55340878120fdf695eb4ac1fcb2679e7b8.tar.bz2
emacs-41169b55340878120fdf695eb4ac1fcb2679e7b8.zip
Add new user option electric-quote-replace-consecutive
* lisp/electric.el (electric-quote-replace-consecutive): New user option (bug#57057). (electric-quote-post-self-insert-function): Use it.
Diffstat (limited to 'lisp/electric.el')
-rw-r--r--lisp/electric.el19
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/electric.el b/lisp/electric.el
index 0cf3a299cfa..f2ff837333f 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -540,6 +540,16 @@ 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 single quotes with a double quote.
+Two single quotes are replaced by the corresponding double quote
+when the second quote of the pair is entered (i.e. by typing ` or
+') by default. If nil, the single quotes are not altered."
+ :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
@@ -592,7 +602,9 @@ 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
@@ -606,7 +618,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)
@@ -627,7 +640,7 @@ and text paragraphs, and these are selectively controlled with
`electric-quote-paragraph'.
Customize `electric-quote-chars' to use characters other than the
-ones listed here.
+ones listed here. Also see `electric-quote-replace-consecutive'.
This is a global minor mode. To toggle the mode in a single buffer,
use `electric-quote-local-mode'."