aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/electric.el33
1 files changed, 14 insertions, 19 deletions
diff --git a/lisp/electric.el b/lisp/electric.el
index 8ca09316bcb..bef5bb9fec7 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -453,7 +453,7 @@ This requotes when a quoting key is typed."
453 (save-excursion 453 (save-excursion
454 (if (eq last-command-event ?\`) 454 (if (eq last-command-event ?\`)
455 (cond ((and (electric--insertable-p "“") 455 (cond ((and (electric--insertable-p "“")
456 (re-search-backward "[`]`" (- (point) 2) t)) 456 (search-backward "‘`" (- (point) 2) t))
457 (replace-match "“") 457 (replace-match "“")
458 (when (and electric-pair-mode 458 (when (and electric-pair-mode
459 (eq (cdr-safe 459 (eq (cdr-safe
@@ -465,19 +465,14 @@ This requotes when a quoting key is typed."
465 (search-backward "`" (1- (point)) t)) 465 (search-backward "`" (1- (point)) t))
466 (replace-match "‘") 466 (replace-match "‘")
467 (setq last-command-event ?‘))) 467 (setq last-command-event ?‘)))
468 (let ((pos (point))) 468 (cond ((and (electric--insertable-p "”")
469 (if (memq (char-before (1- (point))) '(?\' ?’)) 469 (search-backward "’'" (- (point) 2) t))
470 (when (and (search-backward "“" start t) 470 (replace-match "”")
471 (eq pos (re-search-forward 471 (setq last-command-event ?”))
472 "“\\(\\([^‘”]\\|‘[^‘’”]*’\\)*\\)['’]'" 472 ((and (electric--insertable-p "’")
473 pos t))) 473 (search-backward "'" (1- (point)) t))
474 (replace-match "“\\1”") 474 (replace-match "’")
475 (setq last-command-event ?”)) 475 (setq last-command-event ?’)))))))))
476 (when (and (search-backward "‘" start t)
477 (eq pos (re-search-forward
478 "‘\\([^’]*\\)'" pos t)))
479 (replace-match "‘\\1’")
480 (setq last-command-event ?’))))))))))
481 476
482(put 'electric-quote-post-self-insert-function 'priority 10) 477(put 'electric-quote-post-self-insert-function 'priority 10)
483 478
@@ -488,11 +483,11 @@ With a prefix argument ARG, enable Electric Quote mode if
488ARG is positive, and disable it otherwise. If called from Lisp, 483ARG is positive, and disable it otherwise. If called from Lisp,
489enable the mode if ARG is omitted or nil. 484enable the mode if ARG is omitted or nil.
490 485
491When enabled, this replaces \\=`foo bar' with \\=‘foo bar\\=’ and replaces 486When enabled, as you type this replaces \\=` with \\=‘, \\=' with \\=,
492\\=`\\=`foo bar'' with “foo bar” as you type. This occurs only in 487\\=`\\=` with “, and \\='\\=' with ”. This occurs only in comments, strings,
493comments, strings, and text paragraphs, and these are selectively 488and text paragraphs, and these are selectively controlled with
494controlled with ‘electric-quote-comment’, 489‘electric-quote-comment’, ‘electric-quote-string’, and
495‘electric-quote-string’, and ‘electric-quote-paragraph’. 490‘electric-quote-paragraph’.
496 491
497This is a global minor mode. To toggle the mode in a single buffer, 492This is a global minor mode. To toggle the mode in a single buffer,
498use ‘electric-quote-local-mode’." 493use ‘electric-quote-local-mode’."