diff options
| author | Philipp Stephani | 2017-07-02 18:03:06 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-07-09 21:55:30 +0200 |
| commit | 28e6584861a7f80b199edcd0d9eb3d97e344958f (patch) | |
| tree | c4677c53322a5ee54ebece1e0eaeaef5f0020c6f | |
| parent | 51b29de1593c88ad801597ed840814616d16ef37 (diff) | |
| download | emacs-28e6584861a7f80b199edcd0d9eb3d97e344958f.tar.gz emacs-28e6584861a7f80b199edcd0d9eb3d97e344958f.zip | |
Refactor 'electric-quote-mode'
* lisp/electric.el (electric-quote-post-self-insert-function): Remove
local variable 'start', which was misnamed and only used once.
| -rw-r--r-- | lisp/electric.el | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/lisp/electric.el b/lisp/electric.el index 4c1d9039d9a..6e1b685ed66 100644 --- a/lisp/electric.el +++ b/lisp/electric.el | |||
| @@ -470,55 +470,53 @@ This requotes when a quoting key is typed." | |||
| 470 | (eq last-command-event ?\`))) | 470 | (eq last-command-event ?\`))) |
| 471 | (not (run-hook-with-args-until-success | 471 | (not (run-hook-with-args-until-success |
| 472 | 'electric-quote-inhibit-functions))) | 472 | 'electric-quote-inhibit-functions))) |
| 473 | (let ((start | 473 | (if (and comment-start comment-use-syntax) |
| 474 | (if (and comment-start comment-use-syntax) | 474 | (when (or electric-quote-comment electric-quote-string) |
| 475 | (when (or electric-quote-comment electric-quote-string) | 475 | (let* ((syntax (syntax-ppss)) |
| 476 | (let* ((syntax (syntax-ppss)) | 476 | (beg (nth 8 syntax))) |
| 477 | (beg (nth 8 syntax))) | 477 | (and beg |
| 478 | (and beg | 478 | (or (and electric-quote-comment (nth 4 syntax)) |
| 479 | (or (and electric-quote-comment (nth 4 syntax)) | 479 | (and electric-quote-string (nth 3 syntax))) |
| 480 | (and electric-quote-string (nth 3 syntax))) | 480 | ;; Do not requote a quote that starts or ends |
| 481 | ;; Do not requote a quote that starts or ends | 481 | ;; a comment or string. |
| 482 | ;; a comment or string. | 482 | (eq beg (nth 8 (save-excursion |
| 483 | (eq beg (nth 8 (save-excursion | 483 | (syntax-ppss (1- (point))))))))) |
| 484 | (syntax-ppss (1- (point))))))))) | 484 | (and electric-quote-paragraph |
| 485 | (and electric-quote-paragraph | 485 | (derived-mode-p 'text-mode) |
| 486 | (derived-mode-p 'text-mode) | 486 | ;; FIXME: Why is the next form there? It’s never |
| 487 | ;; FIXME: Why is the next form there? It’s never | 487 | ;; nil. |
| 488 | ;; nil. | 488 | (or (eq last-command-event ?\`) |
| 489 | (or (eq last-command-event ?\`) | 489 | (save-excursion (backward-paragraph) (point)))))) |
| 490 | (save-excursion (backward-paragraph) (point))))))) | 490 | (pcase electric-quote-chars |
| 491 | (pcase electric-quote-chars | 491 | (`(,q< ,q> ,q<< ,q>>) |
| 492 | (`(,q< ,q> ,q<< ,q>>) | 492 | (save-excursion |
| 493 | (when start | 493 | (let ((backtick ?\`)) |
| 494 | (save-excursion | 494 | (if (or (eq last-command-event ?\`) |
| 495 | (let ((backtick ?\`)) | 495 | (and electric-quote-context-sensitive |
| 496 | (if (or (eq last-command-event ?\`) | 496 | (save-excursion |
| 497 | (and electric-quote-context-sensitive | 497 | (backward-char) |
| 498 | (save-excursion | 498 | (or (bobp) (bolp) |
| 499 | (backward-char) | 499 | (memq (char-before) (list q< q<<)) |
| 500 | (or (bobp) (bolp) | 500 | (memq (char-syntax (char-before)) |
| 501 | (memq (char-before) (list q< q<<)) | 501 | '(?\s ?\()))) |
| 502 | (memq (char-syntax (char-before)) | 502 | (setq backtick ?\'))) |
| 503 | '(?\s ?\()))) | 503 | (cond ((search-backward (string q< backtick) (- (point) 2) t) |
| 504 | (setq backtick ?\'))) | 504 | (replace-match (string q<<)) |
| 505 | (cond ((search-backward (string q< backtick) (- (point) 2) t) | 505 | (when (and electric-pair-mode |
| 506 | (replace-match (string q<<)) | 506 | (eq (cdr-safe |
| 507 | (when (and electric-pair-mode | 507 | (assq q< electric-pair-text-pairs)) |
| 508 | (eq (cdr-safe | 508 | (char-after))) |
| 509 | (assq q< electric-pair-text-pairs)) | 509 | (delete-char 1)) |
| 510 | (char-after))) | 510 | (setq last-command-event q<<)) |
| 511 | (delete-char 1)) | 511 | ((search-backward (string backtick) (1- (point)) t) |
| 512 | (setq last-command-event q<<)) | 512 | (replace-match (string q<)) |
| 513 | ((search-backward (string backtick) (1- (point)) t) | 513 | (setq last-command-event q<))) |
| 514 | (replace-match (string q<)) | 514 | (cond ((search-backward (string q> ?') (- (point) 2) t) |
| 515 | (setq last-command-event q<))) | 515 | (replace-match (string q>>)) |
| 516 | (cond ((search-backward (string q> ?') (- (point) 2) t) | 516 | (setq last-command-event q>>)) |
| 517 | (replace-match (string q>>)) | 517 | ((search-backward "'" (1- (point)) t) |
| 518 | (setq last-command-event q>>)) | 518 | (replace-match (string q>)) |
| 519 | ((search-backward "'" (1- (point)) t) | 519 | (setq last-command-event q>)))))))))) |
| 520 | (replace-match (string q>)) | ||
| 521 | (setq last-command-event q>)))))))))))) | ||
| 522 | 520 | ||
| 523 | (put 'electric-quote-post-self-insert-function 'priority 10) | 521 | (put 'electric-quote-post-self-insert-function 'priority 10) |
| 524 | 522 | ||