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