diff options
| author | Mark Oteiza | 2017-02-12 09:46:03 -0500 |
|---|---|---|
| committer | Mark Oteiza | 2017-02-12 10:59:33 -0500 |
| commit | 91478f46238ab5a0f5fb7e6e6b4b1da0163c596e (patch) | |
| tree | d02f5d6a4227d838e6523311085414390fefcc8f | |
| parent | 862d6438cfa6c6c035033697751f3d002357b024 (diff) | |
| download | emacs-91478f46238ab5a0f5fb7e6e6b4b1da0163c596e.tar.gz emacs-91478f46238ab5a0f5fb7e6e6b4b1da0163c596e.zip | |
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.
| -rw-r--r-- | lisp/allout.el | 5 | ||||
| -rw-r--r-- | lisp/bookmark.el | 4 | ||||
| -rw-r--r-- | lisp/cus-edit.el | 4 | ||||
| -rw-r--r-- | lisp/cus-theme.el | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 16 | ||||
| -rw-r--r-- | lisp/emacs-lisp/elint.el | 2 | ||||
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 2 | ||||
| -rw-r--r-- | lisp/image-dired.el | 4 | ||||
| -rw-r--r-- | lisp/simple.el | 2 |
11 files changed, 23 insertions, 24 deletions
diff --git a/lisp/allout.el b/lisp/allout.el index 4a0aeeedf6a..e837f83ed38 100644 --- a/lisp/allout.el +++ b/lisp/allout.el | |||
| @@ -4462,7 +4462,7 @@ Topic exposure is marked with text-properties, to be used by | |||
| 4462 | (if (and (/= (current-column) 0) (not (eobp))) | 4462 | (if (and (/= (current-column) 0) (not (eobp))) |
| 4463 | (forward-char 1)) | 4463 | (forward-char 1)) |
| 4464 | (if (not (eobp)) | 4464 | (if (not (eobp)) |
| 4465 | (if (and (save-match-data (looking-at "\n")) | 4465 | (if (and (= (following-char) ?\n) |
| 4466 | (or (save-excursion | 4466 | (or (save-excursion |
| 4467 | (or (not (allout-next-heading)) | 4467 | (or (not (allout-next-heading)) |
| 4468 | (= depth allout-recent-depth))) | 4468 | (= depth allout-recent-depth))) |
| @@ -6278,8 +6278,7 @@ It must also have content." | |||
| 6278 | (setq got nil | 6278 | (setq got nil |
| 6279 | done t) | 6279 | done t) |
| 6280 | (goto-char (setq got (match-beginning 0))) | 6280 | (goto-char (setq got (match-beginning 0))) |
| 6281 | (if (save-match-data (looking-at "\n")) | 6281 | (when (= (following-char) ?\n) (forward-char 1)) |
| 6282 | (forward-char 1)) | ||
| 6283 | (setq got (point))) | 6282 | (setq got (point))) |
| 6284 | 6283 | ||
| 6285 | (cond ((not got) | 6284 | (cond ((not got) |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 02dd8a9f6fc..ab4363b023e 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. | |||
| 896 | Does not affect the kill ring." | 896 | Does not affect the kill ring." |
| 897 | (let ((eol (line-end-position))) | 897 | (let ((eol (line-end-position))) |
| 898 | (delete-region (point) eol) | 898 | (delete-region (point) eol) |
| 899 | (if (and newline-too (looking-at "\n")) | 899 | (when (and newline-too (= (following-char) ?\n)) |
| 900 | (delete-char 1)))) | 900 | (delete-char 1)))) |
| 901 | 901 | ||
| 902 | 902 | ||
| 903 | ;; Defvars to avoid compilation warnings: | 903 | ;; Defvars to avoid compilation warnings: |
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 2b86051a726..fac9c77e12a 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -4581,7 +4581,7 @@ This function does not save the buffer." | |||
| 4581 | (if (bolp) | 4581 | (if (bolp) |
| 4582 | (princ " ")) | 4582 | (princ " ")) |
| 4583 | (princ ")") | 4583 | (princ ")") |
| 4584 | (unless (looking-at-p "\n") | 4584 | (when (/= (following-char) ?\n) |
| 4585 | (princ "\n"))))) | 4585 | (princ "\n"))))) |
| 4586 | 4586 | ||
| 4587 | (defun custom-save-faces () | 4587 | (defun custom-save-faces () |
| @@ -4636,7 +4636,7 @@ This function does not save the buffer." | |||
| 4636 | (if (bolp) | 4636 | (if (bolp) |
| 4637 | (princ " ")) | 4637 | (princ " ")) |
| 4638 | (princ ")") | 4638 | (princ ")") |
| 4639 | (unless (looking-at-p "\n") | 4639 | (when (/= (following-char) ?\n) |
| 4640 | (princ "\n"))))) | 4640 | (princ "\n"))))) |
| 4641 | 4641 | ||
| 4642 | ;;; The Customize Menu. | 4642 | ;;; The Customize Menu. |
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index c5682add23a..d2ee14d8bdf 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el | |||
| @@ -431,7 +431,7 @@ It includes all variables in list VARS." | |||
| 431 | (if (bolp) | 431 | (if (bolp) |
| 432 | (princ " ")) | 432 | (princ " ")) |
| 433 | (princ ")") | 433 | (princ ")") |
| 434 | (unless (looking-at "\n") | 434 | (when (/= (following-char) ?\n) |
| 435 | (princ "\n"))))) | 435 | (princ "\n"))))) |
| 436 | 436 | ||
| 437 | (defun custom-theme-write-faces (theme faces) | 437 | (defun custom-theme-write-faces (theme faces) |
| @@ -463,7 +463,7 @@ It includes all faces in list FACES." | |||
| 463 | (princ ")"))))) | 463 | (princ ")"))))) |
| 464 | (if (bolp) (princ " ")) | 464 | (if (bolp) (princ " ")) |
| 465 | (princ ")") | 465 | (princ ")") |
| 466 | (unless (looking-at "\n") | 466 | (when (/= (following-char) ?\n) |
| 467 | (princ "\n"))))) | 467 | (princ "\n"))))) |
| 468 | 468 | ||
| 469 | 469 | ||
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index ca1d75176dc..1b7ff36f422 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el | |||
| @@ -748,7 +748,7 @@ FILE's modification time." | |||
| 748 | (setq output-start (autoload--setup-output | 748 | (setq output-start (autoload--setup-output |
| 749 | otherbuf outbuf absfile load-name))) | 749 | otherbuf outbuf absfile load-name))) |
| 750 | (autoload--print-cookie-text output-start load-name file)) | 750 | (autoload--print-cookie-text output-start load-name file)) |
| 751 | ((looking-at ";") | 751 | ((= (following-char) ?\;) |
| 752 | ;; Don't read the comment. | 752 | ;; Don't read the comment. |
| 753 | (forward-line 1)) | 753 | (forward-line 1)) |
| 754 | (t | 754 | (t |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 63be7e208b3..09ea7206d6e 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." | |||
| 1995 | ;; Compile the forms from the input buffer. | 1995 | ;; Compile the forms from the input buffer. |
| 1996 | (while (progn | 1996 | (while (progn |
| 1997 | (while (progn (skip-chars-forward " \t\n\^l") | 1997 | (while (progn (skip-chars-forward " \t\n\^l") |
| 1998 | (looking-at ";")) | 1998 | (= (following-char) ?\;)) |
| 1999 | (forward-line 1)) | 1999 | (forward-line 1)) |
| 2000 | (not (eobp))) | 2000 | (not (eobp))) |
| 2001 | (setq byte-compile-read-position (point) | 2001 | (setq byte-compile-read-position (point) |
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 59edbe100e1..1d6fdfa4e87 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -603,7 +603,7 @@ style." | |||
| 603 | (checkdoc-overlay-put cdo 'face 'highlight) | 603 | (checkdoc-overlay-put cdo 'face 'highlight) |
| 604 | ;; Make sure the whole doc string is visible if possible. | 604 | ;; Make sure the whole doc string is visible if possible. |
| 605 | (sit-for 0) | 605 | (sit-for 0) |
| 606 | (if (and (looking-at "\"") | 606 | (if (and (= (following-char) ?\") |
| 607 | (not (pos-visible-in-window-p | 607 | (not (pos-visible-in-window-p |
| 608 | (save-excursion (forward-sexp 1) (point)) | 608 | (save-excursion (forward-sexp 1) (point)) |
| 609 | (selected-window)))) | 609 | (selected-window)))) |
| @@ -743,9 +743,9 @@ buffer, otherwise searching starts at START-HERE." | |||
| 743 | (while (checkdoc-next-docstring) | 743 | (while (checkdoc-next-docstring) |
| 744 | (message "Searching for doc string spell error...%d%%" | 744 | (message "Searching for doc string spell error...%d%%" |
| 745 | (floor (* 100.0 (point)) (point-max))) | 745 | (floor (* 100.0 (point)) (point-max))) |
| 746 | (if (looking-at "\"") | 746 | (when (= (following-char) ?\") |
| 747 | (checkdoc-ispell-docstring-engine | 747 | (checkdoc-ispell-docstring-engine |
| 748 | (save-excursion (forward-sexp 1) (point-marker))))) | 748 | (save-excursion (forward-sexp 1) (point-marker))))) |
| 749 | (message "Checkdoc: Done.")))) | 749 | (message "Checkdoc: Done.")))) |
| 750 | 750 | ||
| 751 | (defun checkdoc-message-interactive-ispell-loop (start-here) | 751 | (defun checkdoc-message-interactive-ispell-loop (start-here) |
| @@ -763,7 +763,7 @@ buffer, otherwise searching starts at START-HERE." | |||
| 763 | (while (checkdoc-message-text-next-string (point-max)) | 763 | (while (checkdoc-message-text-next-string (point-max)) |
| 764 | (message "Searching for message string spell error...%d%%" | 764 | (message "Searching for message string spell error...%d%%" |
| 765 | (floor (* 100.0 (point)) (point-max))) | 765 | (floor (* 100.0 (point)) (point-max))) |
| 766 | (if (looking-at "\"") | 766 | (if (= (following-char) ?\") |
| 767 | (checkdoc-ispell-docstring-engine | 767 | (checkdoc-ispell-docstring-engine |
| 768 | (save-excursion (forward-sexp 1) (point-marker))))) | 768 | (save-excursion (forward-sexp 1) (point-marker))))) |
| 769 | (message "Checkdoc: Done.")))) | 769 | (message "Checkdoc: Done.")))) |
| @@ -1381,7 +1381,7 @@ See the style guide in the Emacs Lisp manual for more details." | |||
| 1381 | "All variables and subroutines might as well have a \ | 1381 | "All variables and subroutines might as well have a \ |
| 1382 | documentation string") | 1382 | documentation string") |
| 1383 | (point) (+ (point) 1) t))))) | 1383 | (point) (+ (point) 1) t))))) |
| 1384 | (if (and (not err) (looking-at "\"")) | 1384 | (if (and (not err) (= (following-char) ?\")) |
| 1385 | (with-syntax-table checkdoc-syntax-table | 1385 | (with-syntax-table checkdoc-syntax-table |
| 1386 | (checkdoc-this-string-valid-engine fp)) | 1386 | (checkdoc-this-string-valid-engine fp)) |
| 1387 | err))) | 1387 | err))) |
| @@ -1395,7 +1395,7 @@ regexp short cuts work. FP is the function defun information." | |||
| 1395 | ;; we won't accidentally lose our place. This could cause | 1395 | ;; we won't accidentally lose our place. This could cause |
| 1396 | ;; end-of doc string whitespace to also delete the " char. | 1396 | ;; end-of doc string whitespace to also delete the " char. |
| 1397 | (s (point)) | 1397 | (s (point)) |
| 1398 | (e (if (looking-at "\"") | 1398 | (e (if (= (following-char) ?\") |
| 1399 | (save-excursion (forward-sexp 1) (point-marker)) | 1399 | (save-excursion (forward-sexp 1) (point-marker)) |
| 1400 | (point)))) | 1400 | (point)))) |
| 1401 | (or | 1401 | (or |
| @@ -1475,7 +1475,7 @@ regexp short cuts work. FP is the function defun information." | |||
| 1475 | ((looking-at "[\\!?;:.)]") | 1475 | ((looking-at "[\\!?;:.)]") |
| 1476 | ;; These are ok | 1476 | ;; These are ok |
| 1477 | nil) | 1477 | nil) |
| 1478 | ((and checkdoc-permit-comma-termination-flag (looking-at ",")) | 1478 | ((and checkdoc-permit-comma-termination-flag (= (following-char) ?,)) |
| 1479 | nil) | 1479 | nil) |
| 1480 | (t | 1480 | (t |
| 1481 | ;; If it is not a complete sentence, let's see if we can | 1481 | ;; 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 d68e49fa4b2..f5e10a24d37 100644 --- a/lisp/emacs-lisp/elint.el +++ b/lisp/emacs-lisp/elint.el | |||
| @@ -372,7 +372,7 @@ Returns the forms." | |||
| 372 | (let ((elint-current-pos (point))) | 372 | (let ((elint-current-pos (point))) |
| 373 | ;; non-list check could be here too. errors may be out of seq. | 373 | ;; non-list check could be here too. errors may be out of seq. |
| 374 | ;; quoted check cannot be elsewhere, since quotes skipped. | 374 | ;; quoted check cannot be elsewhere, since quotes skipped. |
| 375 | (if (looking-back "'" (1- (point))) | 375 | (if (= (preceding-char) ?\') |
| 376 | ;; Eg cust-print.el uses ' as a comment syntax. | 376 | ;; Eg cust-print.el uses ' as a comment syntax. |
| 377 | (elint-warning "Skipping quoted form `%c%.20s...'" ?\' | 377 | (elint-warning "Skipping quoted form `%c%.20s...'" ?\' |
| 378 | (read (current-buffer))) | 378 | (read (current-buffer))) |
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 86364282dcf..aa31fac32cc 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." | |||
| 4520 | (interactive) | 4520 | (interactive) |
| 4521 | (if viper-cted | 4521 | (if viper-cted |
| 4522 | (let ((p (point)) (c (current-column)) bol (indent t)) | 4522 | (let ((p (point)) (c (current-column)) bol (indent t)) |
| 4523 | (if (looking-back "[0^]" (1- (point))) | 4523 | (if (memq (preceding-char) '(?0 ?^)) |
| 4524 | (progn | 4524 | (progn |
| 4525 | (if (eq ?^ (preceding-char)) | 4525 | (if (eq ?^ (preceding-char)) |
| 4526 | (setq viper-preserve-indent t)) | 4526 | (setq viper-preserve-indent t)) |
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 2a4064560a7..49dba52c884 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." | |||
| 1751 | (interactive) | 1751 | (interactive) |
| 1752 | (let ((inhibit-read-only t)) | 1752 | (let ((inhibit-read-only t)) |
| 1753 | (delete-char 1) | 1753 | (delete-char 1) |
| 1754 | (if (looking-at " ") | 1754 | (when (= (following-char) ?\s) |
| 1755 | (delete-char 1)))) | 1755 | (delete-char 1)))) |
| 1756 | 1756 | ||
| 1757 | ;;;###autoload | 1757 | ;;;###autoload |
| 1758 | (defun image-dired-display-thumbs-append () | 1758 | (defun image-dired-display-thumbs-append () |
diff --git a/lisp/simple.el b/lisp/simple.el index c0dad2d36e7..f110c6f3267 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -6665,7 +6665,7 @@ even beep.)" | |||
| 6665 | ;; whether the trailing whitespace is highlighted. But, it's | 6665 | ;; whether the trailing whitespace is highlighted. But, it's |
| 6666 | ;; OK to just do this unconditionally. | 6666 | ;; OK to just do this unconditionally. |
| 6667 | (skip-chars-forward " \t"))) | 6667 | (skip-chars-forward " \t"))) |
| 6668 | (kill-region opoint (if (and kill-whole-line (looking-at "\n")) | 6668 | (kill-region opoint (if (and kill-whole-line (= (following-char) ?\n)) |
| 6669 | (1+ (point)) | 6669 | (1+ (point)) |
| 6670 | (point))))) | 6670 | (point))))) |
| 6671 | 6671 | ||