]> git.eshelyaron.com Git - emacs.git/commitdiff
Nix some useless uses of looking-at, looking-back
authorMark Oteiza <mvoteiza@udel.edu>
Sun, 12 Feb 2017 14:46:03 +0000 (09:46 -0500)
committerMark Oteiza <mvoteiza@udel.edu>
Sun, 12 Feb 2017 15:59:33 +0000 (10:59 -0500)
* lisp/allout.el (allout-kill-topic):
(allout-next-topic-pending-encryption):
* lisp/bookmark.el (bookmark-kill-line):
* lisp/cus-edit.el (custom-save-variables, custom-save-faces):
* lisp/cus-theme.el (custom-theme-write-variables):
(custom-theme-write-faces):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads):
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer):
* lisp/emacs-lisp/checkdoc.el (checkdoc-interactive-loop):
(checkdoc-interactive-ispell-loop):
(checkdoc-message-interactive-ispell-loop, checkdoc-this-string-valid):
(checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/elint.el (elint-get-top-forms):
* lisp/emulation/viper-cmd.el (viper-backward-indent):
* lisp/image-dired.el (image-dired-delete-char):
* lisp/simple.el (kill-visual-line): Replace instances of looking-at,
looking-back with char comparisons using following-char, preceding-char.

lisp/allout.el
lisp/bookmark.el
lisp/cus-edit.el
lisp/cus-theme.el
lisp/emacs-lisp/autoload.el
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/checkdoc.el
lisp/emacs-lisp/elint.el
lisp/emulation/viper-cmd.el
lisp/image-dired.el
lisp/simple.el

index 4a0aeeedf6a3798279da0ba132395397c6c66c6d..e837f83ed38b84364f5764915102be013efd9733 100644 (file)
@@ -4462,7 +4462,7 @@ Topic exposure is marked with text-properties, to be used by
     (if (and (/= (current-column) 0) (not (eobp)))
         (forward-char 1))
     (if (not (eobp))
-       (if (and (save-match-data (looking-at "\n"))
+       (if (and (= (following-char) ?\n)
                  (or (save-excursion
                        (or (not (allout-next-heading))
                            (= depth allout-recent-depth)))
@@ -6278,8 +6278,7 @@ It must also have content."
             (setq got nil
                   done t)
           (goto-char (setq got (match-beginning 0)))
-          (if (save-match-data (looking-at "\n"))
-              (forward-char 1))
+          (when (= (following-char) ?\n) (forward-char 1))
           (setq got (point)))
 
         (cond ((not got)
index 02dd8a9f6fcb552bec0560f69cf9c5f040ab441a..ab4363b023e11fe12ed4d40a11129c53ce2c3606 100644 (file)
@@ -896,8 +896,8 @@ If optional arg NEWLINE-TOO is non-nil, delete the newline too.
 Does not affect the kill ring."
   (let ((eol (line-end-position)))
     (delete-region (point) eol)
-    (if (and newline-too (looking-at "\n"))
-        (delete-char 1))))
+    (when (and newline-too (= (following-char) ?\n))
+      (delete-char 1))))
 
 
 ;; Defvars to avoid compilation warnings:
index 2b86051a726937db9f18326487ed25e234411b46..fac9c77e12a980ae88fd64271e4311420df0b481 100644 (file)
@@ -4581,7 +4581,7 @@ This function does not save the buffer."
       (if (bolp)
          (princ " "))
       (princ ")")
-      (unless (looking-at-p "\n")
+      (when (/= (following-char) ?\n)
        (princ "\n")))))
 
 (defun custom-save-faces ()
@@ -4636,7 +4636,7 @@ This function does not save the buffer."
       (if (bolp)
          (princ " "))
       (princ ")")
-      (unless (looking-at-p "\n")
+      (when (/= (following-char) ?\n)
        (princ "\n")))))
 \f
 ;;; The Customize Menu.
index c5682add23a86fa001f089d7e30f8c6e4873e8b1..d2ee14d8bdf7469d507ec3549d581323ccc99950 100644 (file)
@@ -431,7 +431,7 @@ It includes all variables in list VARS."
       (if (bolp)
          (princ " "))
       (princ ")")
-      (unless (looking-at "\n")
+      (when (/= (following-char) ?\n)
        (princ "\n")))))
 
 (defun custom-theme-write-faces (theme faces)
@@ -463,7 +463,7 @@ It includes all faces in list FACES."
              (princ ")")))))
       (if (bolp) (princ " "))
       (princ ")")
-      (unless (looking-at "\n")
+      (when (/= (following-char) ?\n)
        (princ "\n")))))
 
 \f
index ca1d75176dc549f176a30a62061fc392cef851a4..1b7ff36f422b440ca0fac5642e57b2a839fc0c21 100644 (file)
@@ -748,7 +748,7 @@ FILE's modification time."
                               (setq output-start (autoload--setup-output
                                                   otherbuf outbuf absfile load-name)))
                             (autoload--print-cookie-text output-start load-name file))
-                           ((looking-at ";")
+                           ((= (following-char) ?\;)
                             ;; Don't read the comment.
                             (forward-line 1))
                            (t
index 63be7e208b30942a9f46a60e82588fa456b4e23f..09ea7206d6ef5158937f9af6cef1b3b421fa3f2e 100644 (file)
@@ -1995,7 +1995,7 @@ With argument ARG, insert value in current buffer after the form."
        ;; Compile the forms from the input buffer.
        (while (progn
                 (while (progn (skip-chars-forward " \t\n\^l")
-                              (looking-at ";"))
+                              (= (following-char) ?\;))
                   (forward-line 1))
                 (not (eobp)))
          (setq byte-compile-read-position (point)
index 59edbe100e15a6dafa73d73f54a62f681dcb8043..1d6fdfa4e8790f323f9dc535e07635f1e26a379e 100644 (file)
@@ -603,7 +603,7 @@ style."
              (checkdoc-overlay-put cdo 'face 'highlight)
              ;; Make sure the whole doc string is visible if possible.
              (sit-for 0)
-             (if (and (looking-at "\"")
+             (if (and (= (following-char) ?\")
                       (not (pos-visible-in-window-p
                             (save-excursion (forward-sexp 1) (point))
                             (selected-window))))
@@ -743,9 +743,9 @@ buffer, otherwise searching starts at START-HERE."
       (while (checkdoc-next-docstring)
         (message "Searching for doc string spell error...%d%%"
                  (floor (* 100.0 (point)) (point-max)))
-        (if (looking-at "\"")
-            (checkdoc-ispell-docstring-engine
-             (save-excursion (forward-sexp 1) (point-marker)))))
+        (when (= (following-char) ?\")
+          (checkdoc-ispell-docstring-engine
+           (save-excursion (forward-sexp 1) (point-marker)))))
       (message "Checkdoc: Done."))))
 
 (defun checkdoc-message-interactive-ispell-loop (start-here)
@@ -763,7 +763,7 @@ buffer, otherwise searching starts at START-HERE."
       (while (checkdoc-message-text-next-string (point-max))
         (message "Searching for message string spell error...%d%%"
                  (floor (* 100.0 (point)) (point-max)))
-        (if (looking-at "\"")
+        (if (= (following-char) ?\")
             (checkdoc-ispell-docstring-engine
              (save-excursion (forward-sexp 1) (point-marker)))))
       (message "Checkdoc: Done."))))
@@ -1381,7 +1381,7 @@ See the style guide in the Emacs Lisp manual for more details."
                "All variables and subroutines might as well have a \
 documentation string")
              (point) (+ (point) 1) t)))))
-    (if (and (not err) (looking-at "\""))
+    (if (and (not err) (= (following-char) ?\"))
         (with-syntax-table checkdoc-syntax-table
           (checkdoc-this-string-valid-engine fp))
       err)))
@@ -1395,7 +1395,7 @@ regexp short cuts work.  FP is the function defun information."
        ;; we won't accidentally lose our place.  This could cause
        ;; end-of doc string whitespace to also delete the " char.
        (s (point))
-       (e (if (looking-at "\"")
+       (e (if (= (following-char) ?\")
               (save-excursion (forward-sexp 1) (point-marker))
             (point))))
     (or
@@ -1475,7 +1475,7 @@ regexp short cuts work.  FP is the function defun information."
        ((looking-at "[\\!?;:.)]")
         ;; These are ok
         nil)
-        ((and checkdoc-permit-comma-termination-flag (looking-at ","))
+        ((and checkdoc-permit-comma-termination-flag (= (following-char) ?,))
         nil)
        (t
         ;; If it is not a complete sentence, let's see if we can
index d68e49fa4b2f9319e09b9dd33569afd282b01011..f5e10a24d371751caecb96b03cab6d68fe89ba8a 100644 (file)
@@ -372,7 +372,7 @@ Returns the forms."
        (let ((elint-current-pos (point)))
          ;; non-list check could be here too. errors may be out of seq.
          ;; quoted check cannot be elsewhere, since quotes skipped.
-         (if (looking-back "'" (1- (point)))
+         (if (= (preceding-char) ?\')
              ;; Eg cust-print.el uses ' as a comment syntax.
              (elint-warning "Skipping quoted form `%c%.20s...'" ?\'
                           (read (current-buffer)))
index 86364282dcfc7cbb2ff5a416e228faaaa2a56204..aa31fac32ccf510e55f2c542c89b69bf88ad9255 100644 (file)
@@ -4520,7 +4520,7 @@ One can use \\=`\\=` and \\='\\=' to temporarily jump 1 step back."
   (interactive)
   (if viper-cted
       (let ((p (point)) (c (current-column)) bol (indent t))
-       (if (looking-back "[0^]" (1- (point)))
+       (if (memq (preceding-char) '(?0 ?^))
            (progn
              (if (eq ?^ (preceding-char))
                  (setq viper-preserve-indent t))
index 2a4064560a7579162e72c2fc7d8447576c7ba99b..49dba52c88430fcdedc76703cd5e6b13418c4399 100644 (file)
@@ -1751,8 +1751,8 @@ Ask user for number of images to show and the delay in between."
   (interactive)
   (let ((inhibit-read-only t))
     (delete-char 1)
-    (if (looking-at " ")
-        (delete-char 1))))
+    (when (= (following-char) ?\s)
+      (delete-char 1))))
 
 ;;;###autoload
 (defun image-dired-display-thumbs-append ()
index c0dad2d36e7290874abd8bac27cbb36e4a117c18..f110c6f3267e9b0f07644c30da2f9726bd9914d6 100644 (file)
@@ -6665,7 +6665,7 @@ even beep.)"
        ;; whether the trailing whitespace is highlighted.  But, it's
        ;; OK to just do this unconditionally.
        (skip-chars-forward " \t")))
-    (kill-region opoint (if (and kill-whole-line (looking-at "\n"))
+    (kill-region opoint (if (and kill-whole-line (= (following-char) ?\n))
                            (1+ (point))
                          (point)))))