emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 28e6584 1/3: Refactor 'electric-quote-mode'


From: Philipp Stephani
Subject: [Emacs-diffs] master 28e6584 1/3: Refactor 'electric-quote-mode'
Date: Sun, 9 Jul 2017 15:56:02 -0400 (EDT)

branch: master
commit 28e6584861a7f80b199edcd0d9eb3d97e344958f
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Refactor 'electric-quote-mode'
    
    * lisp/electric.el (electric-quote-post-self-insert-function): Remove
    local variable 'start', which was misnamed and only used once.
---
 lisp/electric.el | 96 +++++++++++++++++++++++++++-----------------------------
 1 file changed, 47 insertions(+), 49 deletions(-)

diff --git a/lisp/electric.el b/lisp/electric.el
index 4c1d9039..6e1b685 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -470,55 +470,53 @@ This requotes when a quoting key is typed."
                       (eq last-command-event ?\`)))
              (not (run-hook-with-args-until-success
                    'electric-quote-inhibit-functions)))
-    (let ((start
-           (if (and comment-start comment-use-syntax)
-               (when (or electric-quote-comment electric-quote-string)
-                 (let* ((syntax (syntax-ppss))
-                        (beg (nth 8 syntax)))
-                   (and beg
-                        (or (and electric-quote-comment (nth 4 syntax))
-                            (and electric-quote-string (nth 3 syntax)))
-                        ;; Do not requote a quote that starts or ends
-                        ;; a comment or string.
-                        (eq beg (nth 8 (save-excursion
-                                         (syntax-ppss (1- (point)))))))))
-             (and electric-quote-paragraph
-                  (derived-mode-p 'text-mode)
-                  ;; FIXME: Why is the next form there?  It’s never
-                  ;; nil.
-                  (or (eq last-command-event ?\`)
-                      (save-excursion (backward-paragraph) (point)))))))
-      (pcase electric-quote-chars
-        (`(,q< ,q> ,q<< ,q>>)
-         (when start
-           (save-excursion
-             (let ((backtick ?\`))
-               (if (or (eq last-command-event ?\`)
-                       (and electric-quote-context-sensitive
-                            (save-excursion
-                              (backward-char)
-                              (or (bobp) (bolp)
-                                  (memq (char-before) (list q< q<<))
-                                  (memq (char-syntax (char-before))
-                                        '(?\s ?\())))
-                            (setq backtick ?\')))
-                   (cond ((search-backward (string q< backtick) (- (point) 2) 
t)
-                          (replace-match (string q<<))
-                          (when (and electric-pair-mode
-                                     (eq (cdr-safe
-                                          (assq q< electric-pair-text-pairs))
-                                         (char-after)))
-                            (delete-char 1))
-                          (setq last-command-event q<<))
-                         ((search-backward (string backtick) (1- (point)) t)
-                          (replace-match (string q<))
-                          (setq last-command-event q<)))
-                 (cond ((search-backward (string q> ?') (- (point) 2) t)
-                        (replace-match (string q>>))
-                        (setq last-command-event q>>))
-                       ((search-backward "'" (1- (point)) t)
-                        (replace-match (string q>))
-                        (setq last-command-event q>))))))))))))
+             (if (and comment-start comment-use-syntax)
+                 (when (or electric-quote-comment electric-quote-string)
+                   (let* ((syntax (syntax-ppss))
+                          (beg (nth 8 syntax)))
+                     (and beg
+                          (or (and electric-quote-comment (nth 4 syntax))
+                              (and electric-quote-string (nth 3 syntax)))
+                          ;; Do not requote a quote that starts or ends
+                          ;; a comment or string.
+                          (eq beg (nth 8 (save-excursion
+                                           (syntax-ppss (1- (point)))))))))
+               (and electric-quote-paragraph
+                    (derived-mode-p 'text-mode)
+                    ;; FIXME: Why is the next form there?  It’s never
+                    ;; nil.
+                    (or (eq last-command-event ?\`)
+                        (save-excursion (backward-paragraph) (point))))))
+    (pcase electric-quote-chars
+      (`(,q< ,q> ,q<< ,q>>)
+       (save-excursion
+         (let ((backtick ?\`))
+           (if (or (eq last-command-event ?\`)
+                   (and electric-quote-context-sensitive
+                        (save-excursion
+                          (backward-char)
+                          (or (bobp) (bolp)
+                              (memq (char-before) (list q< q<<))
+                              (memq (char-syntax (char-before))
+                                    '(?\s ?\())))
+                        (setq backtick ?\')))
+               (cond ((search-backward (string q< backtick) (- (point) 2) t)
+                      (replace-match (string q<<))
+                      (when (and electric-pair-mode
+                                 (eq (cdr-safe
+                                      (assq q< electric-pair-text-pairs))
+                                     (char-after)))
+                        (delete-char 1))
+                      (setq last-command-event q<<))
+                     ((search-backward (string backtick) (1- (point)) t)
+                      (replace-match (string q<))
+                      (setq last-command-event q<)))
+             (cond ((search-backward (string q> ?') (- (point) 2) t)
+                    (replace-match (string q>>))
+                    (setq last-command-event q>>))
+                   ((search-backward "'" (1- (point)) t)
+                    (replace-match (string q>))
+                    (setq last-command-event q>))))))))))
 
 (put 'electric-quote-post-self-insert-function 'priority 10)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]