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)