From: Stefan Monnier Date: Tue, 21 Apr 2015 01:55:00 +0000 (-0400) Subject: Fix byte-compiler warnings about looking-back. X-Git-Tag: emacs-25.0.90~2346 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/c9a75a4030a556d700fd95222ec0bf4c1a9f67b5 Fix byte-compiler warnings about looking-back. * lisp/vc/log-view.el (log-view-end-of-defun-1): * lisp/textmodes/tex-mode.el (latex-forward-sexp-1): * lisp/textmodes/reftex-ref.el (reftex-goto-label): * lisp/textmodes/bibtex.el (bibtex-insert-kill): * lisp/progmodes/sh-script.el (sh--maybe-here-document): * lisp/progmodes/ruby-mode.el (ruby-end-of-defun): * lisp/progmodes/ada-mode.el (ada-in-numeric-literal-p): * lisp/org/org.el (org-insert-heading, org-sort-entries): * lisp/org/org-mouse.el (org-mouse-end-headline) (org-mouse-context-menu): * lisp/org/org-clock.el (org-clock-cancel): * lisp/man.el (Man-default-man-entry): * lisp/mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text) (rmail-ensure-blank-line): * lisp/mail/footnote.el (Footnote-delete-footnote): * lisp/mail/emacsbug.el (report-emacs-bug): * lisp/info.el (Info-follow-reference, Info-fontify-node): * lisp/info-look.el (info-lookup-guess-custom-symbol): * lisp/help-fns.el (help-fns--key-bindings): * lisp/files.el (hack-local-variables): * lisp/emulation/viper-ex.el (viper-get-ex-token, ex-cmd-complete) (viper-get-ex-pat, ex-expand-filsyms, viper-get-ex-file) (viper-complete-filename-or-exit): * lisp/emulation/viper-cmd.el (viper-backward-indent): * lisp/emacs-lisp/lisp-mode.el (calculate-lisp-indent): * lisp/emacs-lisp/elint.el (elint-get-top-forms): * lisp/cus-edit.el (custom-face-edit-value-create): * lisp/calendar/todo-mode.el (todo-set-item-priority) (todo-filter-items-1, todo-convert-legacy-files) (todo-prefix-overlays): Add explicit second arg to looking-back. --- diff --git a/etc/NEWS b/etc/NEWS index 9dd0e1512c..804b819a8b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -233,7 +233,9 @@ Unicode standards. * Changes in Specialized Modes and Packages in Emacs 25.1 ** In xterms, killing text now also sets the CLIPBOARD/PRIMARY selection -in the surrounding GUI (using the OSC-52 escape sequence). +in the surrounding GUI (using the OSC-52 escape sequence). This only works +if your xterm supports it and enables the `allowWindowOps' options (disabled +by default at least in Debian, for security reasons). ** xterm-mouse-mode now supports mouse-tracking (if your xterm supports it). diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index dcc960fb9b..bb9316c81d 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -2606,7 +2606,8 @@ meaning to raise or lower the item's priority by one." ;; separator. (when (looking-back (concat "^" (regexp-quote todo-category-done) - "\n")) + "\n") + (line-beginning-position 0)) (todo-backward-item)))) (todo-insert-with-overlays item) ;; If item was marked, restore the mark. @@ -4231,7 +4232,8 @@ the values of FILTER and FILE-LIST." (if (and (eobp) (looking-back (concat (regexp-quote todo-done-string) - "\n"))) + "\n") + (line-beginning-position 0))) (delete-region (point) (progn (forward-line -2) (point)))))) @@ -4648,7 +4650,7 @@ name in `todo-directory'. See also the documentation string of ;; If the item ends with a non-comment parenthesis not ;; followed by a period, we lose (but we inherit that ;; problem from the legacy code). - (when (looking-back "(\\(.*\\)) ") + (when (looking-back "(\\(.*\\)) " (line-beginning-position)) (setq comment (match-string 1)) (replace-match "") (insert "[" todo-comment-string ": " comment "]")) @@ -5342,7 +5344,8 @@ of each other." (looking-at todo-done-string-start) (looking-back (concat "^" (regexp-quote todo-category-done) - "\n"))) + "\n") + (line-beginning-position 0))) (setq num 1 done t)) (setq prefix (concat (propertize diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 9cc2fa81d0..cd894f4726 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -3115,7 +3115,7 @@ face attributes (as specified by a `default' defface entry)." widget (widget-get widget :default-face-attributes))) entry) - (unless (looking-back "^ *") + (unless (looking-back "^ *" (line-beginning-position)) (insert ?\n)) (insert-char ?\s (widget-get widget :extra-offset)) (if (or alist defaults show-all) diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el index 136467046b..317e5a6fd3 100644 --- a/lisp/emacs-lisp/elint.el +++ b/lisp/emacs-lisp/elint.el @@ -374,7 +374,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 "'") + (if (looking-back "'" (1- (point))) ;; Eg cust-print.el uses ' as a comment syntax. (elint-warning "Skipping quoted form `'%.20s...'" (read (current-buffer))) diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index fec172d05c..104c23c210 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -437,9 +437,9 @@ This can be found in an RCS or SCCS header." ((re-search-forward (concat "@(#)" - (if buffer-file-name + (if buffer-file-name (regexp-quote (file-name-nondirectory buffer-file-name)) - "[^\t\n]*") + "[^\t\n]+") "\t\\([012345679.]*\\)") header-max t) (match-string-no-properties 1))))))) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 26a21d5237..108d5ccb0e 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -855,9 +855,10 @@ is the buffer position of the start of the containing expression." ;; Handle prefix characters and whitespace ;; following an open paren. (Bug#1012) (backward-prefix-chars) - (while (and (not (looking-back "^[ \t]*\\|([ \t]+")) - (or (not containing-sexp) - (< (1+ containing-sexp) (point)))) + (while (not (or (looking-back "^[ \t]*\\|([ \t]+" + (line-beginning-position)) + (and containing-sexp + (>= (1+ containing-sexp) (point))))) (forward-sexp -1) (backward-prefix-chars)) (setq calculate-lisp-indent-last-sexp (point))) diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index bd03a870fd..5c91df9016 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -4533,7 +4533,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^]") + (if (looking-back "[0^]" (1- (point))) (progn (if (eq ?^ (preceding-char)) (setq viper-preserve-indent t)) @@ -4545,7 +4545,7 @@ One can use `` and '' to temporarily jump 1 step back." (delete-region (point) p) (if indent (indent-to (- c viper-shift-width))) - (if (or (bolp) (looking-back "[^ \t]")) + (if (or (bolp) (looking-back "[^ \t]" (1- (point)))) (setq viper-cted nil))))) ;; do smart indent diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index 212f0533b8..e6bcf8f89a 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -455,7 +455,8 @@ reversed." (while (and (not (eolp)) cont) ;;(re-search-forward "[^/]*/") (re-search-forward "[^/]*\\(/\\|\n\\)") - (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/")) + (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/" + (line-beginning-position 0))) (setq cont nil)))) (backward-char 1) (setq ex-token (buffer-substring (point) (mark t))) @@ -468,7 +469,8 @@ reversed." (while (and (not (eolp)) cont) ;;(re-search-forward "[^\\?]*\\?") (re-search-forward "[^\\?]*\\(\\?\\|\n\\)") - (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?")) + (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?" + (line-beginning-position 0))) (setq cont nil)) (backward-char 1) (if (not (looking-at "\n")) (forward-char 1)))) @@ -563,14 +565,18 @@ reversed." save-pos (point))) (if (or (= dist 0) - (looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") + (looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)" + (line-beginning-position)) (looking-back - "^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+")) + "^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+" + (line-beginning-position))) ;; Preceding characters are not the ones allowed in an Ex command ;; or we have typed past command name. ;; Note: we didn't do parsing, so there can be surprises. - (if (or (looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*") - (looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") + (if (or (looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*" + (line-beginning-position)) + (looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)" + (line-beginning-position)) (looking-at "[^ \t\n\C-m]")) nil (with-output-to-temp-buffer "*Completions*" @@ -747,7 +753,8 @@ reversed." (error "Missing closing delimiter for global regexp") (goto-char (point-max)))) (if (not (looking-back - (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c))) + (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c) + (line-beginning-position 0))) (setq cont nil) ;; we are at an escaped delimiter: unescape it and continue (delete-char -2) @@ -963,7 +970,7 @@ reversed." (while (re-search-forward "%\\|#" nil t) (let ((data (match-data)) (char (buffer-substring (match-beginning 0) (match-end 0)))) - (if (looking-back (concat "\\\\" char)) + (if (looking-back "\\\\." (- (point) 2)) (replace-match char) (store-match-data data) (if (string= char "%") @@ -989,7 +996,7 @@ reversed." (get-buffer-create viper-ex-work-buf-name)) (skip-chars-forward " \t") (if (looking-at "!") - (if (and (not (looking-back "[ \t]")) + (if (and (not (looking-back "[ \t]" (1- (point)))) ;; read doesn't have a corresponding :r! form, so ! is ;; immediately interpreted as a shell command. (not (string= ex-token "read"))) @@ -1066,7 +1073,7 @@ reversed." (cond ((ex-cmd-accepts-multiple-files-p ex-token) (exit-minibuffer)) ;; apparently the argument to an Ex command is ;; supposed to be a shell command - ((looking-back "^[ \t]*!.*") + ((looking-back "^[ \t]*!.*" (line-beginning-position)) (setq ex-cmdfile t) (insert " ")) (t diff --git a/lisp/files.el b/lisp/files.el index 0b011f4c36..152f155427 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3375,7 +3375,7 @@ local variables, but directory-local variables may still be applied." (error "Local variables entry is missing the prefix")) (end-of-line) ;; Discard the suffix. - (if (looking-back suffix) + (if (looking-back suffix (line-beginning-position)) (delete-region (match-beginning 0) (point)) (error "Local variables entry is missing the suffix")) (forward-line 1)) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 7ecd271d0c..53f4b38b9e 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -329,7 +329,7 @@ suitable file is found, return nil." (with-current-buffer standard-output (fill-region-as-paragraph pt2 (point)) - (unless (looking-back "\n\n") + (unless (looking-back "\n\n" (- (point) 2)) (terpri)))))) (defun help-fns--compiler-macro (function) diff --git a/lisp/info-look.el b/lisp/info-look.el index 9cf185edf5..8a86dc8168 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el @@ -634,7 +634,8 @@ Return nil if there is nothing appropriate in the buffer near point." (setq end (point)) (> end beg)) (and (looking-at "[ \t\n]") - (looking-back (concat "[" significant-chars "]")) + (looking-back (concat "[" significant-chars "]") + (1- (point))) (setq end (point)) (skip-chars-backward significant-chars) (setq beg (point)) diff --git a/lisp/info.el b/lisp/info.el index 0159661947..057bd77ba1 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -2577,7 +2577,9 @@ new buffer." (save-excursion ;; Move point to the beginning of reference if point is on reference (or (looking-at "\\*note[ \n\t]+") - (and (looking-back "\\*note[ \n\t]+") + (and (looking-back "\\*note[ \n\t]+" + (save-excursion (skip-chars-backward " \n\t") + (line-beginning-position))) (goto-char (match-beginning 0))) (if (and (save-excursion (goto-char (+ (point) 5)) ; skip a possible *note @@ -4738,9 +4740,11 @@ first line or header line, and for breadcrumb links.") ;; an end of sentence (skip-syntax-backward " (")) (setq other-tag - (cond ((save-match-data (looking-back "\\