1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

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.
This commit is contained in:
Andrea Greselin 2022-08-09 20:43:08 +02:00 committed by Lars Ingebrigtsen
parent 744ed0ceee
commit 41169b5534
2 changed files with 19 additions and 3 deletions

View File

@ -375,6 +375,9 @@ option) and can be set to nil to disable Just-in-time Lock mode.
* Changes in Emacs 29.1
---
** New user option 'electric-quote-replace-consecutive'.
---
** Emacs is now capable of editing files with very long lines.
The display of long lines has been optimized, and Emacs should no

View File

@ -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'."