[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 91478f4: Nix some useless uses of looking-at, looki
From: |
Mark Oteiza |
Subject: |
[Emacs-diffs] master 91478f4: Nix some useless uses of looking-at, looking-back |
Date: |
Sun, 12 Feb 2017 11:03:51 -0500 (EST) |
branch: master
commit 91478f46238ab5a0f5fb7e6e6b4b1da0163c596e
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>
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.
---
lisp/allout.el | 5 ++---
lisp/bookmark.el | 4 ++--
lisp/cus-edit.el | 4 ++--
lisp/cus-theme.el | 4 ++--
lisp/emacs-lisp/autoload.el | 2 +-
lisp/emacs-lisp/bytecomp.el | 2 +-
lisp/emacs-lisp/checkdoc.el | 16 ++++++++--------
lisp/emacs-lisp/elint.el | 2 +-
lisp/emulation/viper-cmd.el | 2 +-
lisp/image-dired.el | 4 ++--
lisp/simple.el | 2 +-
11 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/lisp/allout.el b/lisp/allout.el
index 4a0aeee..e837f83 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -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)
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 02dd8a9..ab4363b 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -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:
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 2b86051..fac9c77 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -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.
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index c5682ad..d2ee14d 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -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")))))
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index ca1d751..1b7ff36 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -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
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 63be7e2..09ea720 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -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)
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 59edbe1..1d6fdfa 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -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
diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el
index d68e49f..f5e10a2 100644
--- a/lisp/emacs-lisp/elint.el
+++ b/lisp/emacs-lisp/elint.el
@@ -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)))
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 8636428..aa31fac 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -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))
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 2a40645..49dba52 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -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 ()
diff --git a/lisp/simple.el b/lisp/simple.el
index c0dad2d..f110c6f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 91478f4: Nix some useless uses of looking-at, looking-back,
Mark Oteiza <=