Commit 91478f46 authored by Mark Oteiza's avatar Mark Oteiza

Nix some useless uses of looking-at, looking-back

* 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.
parent 862d6438
......@@ -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)
......
......@@ -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:
......
......@@ -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")))))
;;; The Customize Menu.
......
......@@ -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")))))
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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)))
......
......@@ -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))
......
......@@ -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 ()
......
......@@ -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)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment