From 45fdb48240996f7ad9c8c03f438ecf7f5b925d8e Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Sat, 10 Aug 2013 17:17:29 +0200 Subject: [PATCH] lisp/*.el: Remove lexical-binding warnings; additional small cleanups. * calculator.el (calculator): Mark unused argument. (calculator-paste, calculator-quit, calculator-integer-p): Use ignore-errors. (calculator-string-to-number, calculator-decimal, calculator-exp) (calculator-op-or-exp): Use string-match-p. * dired-aux.el (dired-compress): Use ignore-errors. (dired-do-chxxx, dired-do-chmod, dired-trample-file-versions) (dired-do-async-shell-command, dired-do-shell-command) (dired-shell-stuff-it, dired-compress-file, dired-insert-subdir) (dired-insert-subdir-validate): Use string-match-p. (dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p. (dired-add-entry): Use string-match-p, looking-at-p. (dired-insert-subdir-newpos): Remove unused local variable. * dired.el (dired-buffer-more-recently-used-p): Declare. (dired-insert-set-properties, dired-insert-old-subdirs): Use ignore-errors. * filenotify.el (file-notify-callback): Remove unused local variable. * filesets.el (filesets-error): Mark unused argument. (filesets-which-command-p, filesets-filter-dir-names) (filesets-directory-files, filesets-get-external-viewer) (filesets-ingroup-get-data): Use string-match-p. * find-file.el (ff-other-file-name, ff-other-file-name) (ff-find-the-other-file, ff-cc-hh-converter): Remove unused local variables. (ff-get-file-name): Use string-match-p. (ff-all-dirs-under): Use ignore-errors. * follow.el (follow-comint-scroll-to-bottom): Mark unused argument. (follow-select-if-visible): Remove unused local variable. * forms.el (read-file-filter): Move declaration. (forms--make-format, forms--make-parser, forms-insert-record): Quote function with #'. (forms--update): Use string-match-p. Quote function with #'. * help-mode.el (help-dir-local-var-def): Mark unused argument. (help-make-xrefs): Use looking-at-p. (help-xref-on-pp): Use looking-at-p, ignore-errors. * ibuffer.el (ibuffer-ext-visible-p): Declare. (ibuffer-confirm-operation-on): Use string-match-p. * msb.el (msb-item-handler, msb-dired-item-handler): Mark unused arguments. * ses.el (ses-decode-cell-symbol) (ses-kill-override): Remove unused local variable. (ses-create-cell-variable, ses-relocate-formula): Use string-match-p. (ses-load): Use ignore-errors, looking-at-p. (ses-jump-safe): Use ignore-errors. (ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments. * tabify.el (untabify, tabify): Mark unused arguments. * thingatpt.el (thing-at-point--bounds-of-well-formed-url): Mark unused argument. (bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point) (thing-at-point-newsgroup-p, form-at-point): Use ignore-errors. --- lisp/ChangeLog | 64 ++++++++++++++++++++++ lisp/calculator.el | 36 ++++++------- lisp/dired-aux.el | 60 ++++++++++----------- lisp/dired.el | 52 +++++++++--------- lisp/filenotify.el | 2 +- lisp/filesets.el | 24 ++++----- lisp/find-file.el | 50 +++++++---------- lisp/follow.el | 7 ++- lisp/forms.el | 24 ++++----- lisp/help-mode.el | 43 ++++++++------- lisp/ibuffer.el | 4 +- lisp/msb.el | 4 +- lisp/ses.el | 32 ++++++----- lisp/tabify.el | 4 +- lisp/thingatpt.el | 130 +++++++++++++++++++++------------------------ 15 files changed, 283 insertions(+), 253 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 15ff4e131a..4c55452e5b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,69 @@ 2013-08-10 Juanma Barranquero + * calculator.el (calculator): Mark unused argument. + (calculator-paste, calculator-quit, calculator-integer-p): + Use ignore-errors. + (calculator-string-to-number, calculator-decimal, calculator-exp) + (calculator-op-or-exp): Use string-match-p. + + * dired.el (dired-buffer-more-recently-used-p): Declare. + (dired-insert-set-properties, dired-insert-old-subdirs): + Use ignore-errors. + + * dired-aux.el (dired-compress): Use ignore-errors. + (dired-do-chxxx, dired-do-chmod, dired-trample-file-versions) + (dired-do-async-shell-command, dired-do-shell-command) + (dired-shell-stuff-it, dired-compress-file, dired-insert-subdir) + (dired-insert-subdir-validate): Use string-match-p. + (dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p. + (dired-add-entry): Use string-match-p, looking-at-p. + (dired-insert-subdir-newpos): Remove unused local variable. + + * filenotify.el (file-notify-callback): Remove unused local variable. + + * filesets.el (filesets-error): Mark unused argument. + (filesets-which-command-p, filesets-filter-dir-names) + (filesets-directory-files, filesets-get-external-viewer) + (filesets-ingroup-get-data): Use string-match-p. + + * find-file.el (ff-other-file-name, ff-other-file-name) + (ff-find-the-other-file, ff-cc-hh-converter): + Remove unused local variables. + (ff-get-file-name): Use string-match-p. + (ff-all-dirs-under): Use ignore-errors. + + * follow.el (follow-comint-scroll-to-bottom): Mark unused argument. + (follow-select-if-visible): Remove unused local variable. + + * forms.el (read-file-filter): Move declaration. + (forms--make-format, forms--make-parser, forms-insert-record): + Quote function with #'. + (forms--update): Use string-match-p. Quote function with #'. + + * help-mode.el (help-dir-local-var-def): Mark unused argument. + (help-make-xrefs): Use looking-at-p. + (help-xref-on-pp): Use looking-at-p, ignore-errors. + + * ibuffer.el (ibuffer-ext-visible-p): Declare. + (ibuffer-confirm-operation-on): Use string-match-p. + + * msb.el (msb-item-handler, msb-dired-item-handler): + Mark unused arguments. + + * ses.el (ses-decode-cell-symbol) + (ses-kill-override): Remove unused local variable. + (ses-create-cell-variable, ses-relocate-formula): Use string-match-p. + (ses-load): Use ignore-errors, looking-at-p. + (ses-jump-safe): Use ignore-errors. + (ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments. + + * tabify.el (untabify, tabify): Mark unused arguments. + + * thingatpt.el (thing-at-point--bounds-of-well-formed-url): + Mark unused argument. + (bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point) + (thing-at-point-newsgroup-p, form-at-point): Use ignore-errors. + * emacs-lisp/timer.el (timer--time): Define setter with gv-define-setter to avoid deprecation warning. diff --git a/lisp/calculator.el b/lisp/calculator.el index 8b253b810f..c9a7305471 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -708,7 +708,7 @@ See the documentation for `calculator-mode' for more information." ;; can't use 'noprompt, bug in electric.el (lambda () 'noprompt) nil - (lambda (x y) (calculator-update-display)))) + (lambda (_x _y) (calculator-update-display)))) (and calculator-buffer (catch 'calculator-done (calculator-quit))) (use-local-map old-l-map) @@ -905,9 +905,9 @@ The string is set not to exceed the screen width." value) (car (read-from-string (cond ((equal "." str) "0.0") - ((string-match "[eE][+-]?$" str) (concat str "0")) - ((string-match "\\.[0-9]\\|[eE]" str) str) - ((string-match "\\." str) + ((string-match-p "[eE][+-]?$" str) (concat str "0")) + ((string-match-p "\\.[0-9]\\|[eE]" str) str) + ((string-match-p "\\." str) ;; do this because Emacs reads "23." as an integer (concat str "0")) ((stringp str) (concat str ".0")) @@ -1366,7 +1366,7 @@ OP is the operator (if any) that caused this call." (or calculator-display-fragile (not (numberp (car calculator-stack)))) (not (and calculator-curnum - (string-match "[.eE]" calculator-curnum)))) + (string-match-p "[.eE]" calculator-curnum)))) ;; enter the period on the same condition as a digit, only if no ;; period or exponent entered yet (progn @@ -1382,7 +1382,7 @@ OP is the operator (if any) that caused this call." (if (and (or calculator-display-fragile (not (numberp (car calculator-stack)))) (not (and calculator-curnum - (string-match "[eE]" calculator-curnum)))) + (string-match-p "[eE]" calculator-curnum)))) ;; same condition as above, also no E so far (progn (calculator-clear-fragile) @@ -1452,7 +1452,7 @@ no need for negative numbers since these are handled by unary operators)." (interactive) (if (and (not calculator-display-fragile) calculator-curnum - (string-match "[eE]$" calculator-curnum)) + (string-match-p "[eE]$" calculator-curnum)) (calculator-digit) (calculator-op))) @@ -1661,8 +1661,7 @@ Used by `calculator-paste' and `get-register'." (setq str (concat (or (match-string 1 str) "0") (or (match-string 2 str) ".0") (or (match-string 3 str) "")))) - (condition-case nil (calculator-string-to-number str) - (error nil))))) + (ignore-errors (calculator-string-to-number str))))) (defun calculator-get-register (reg) "Get a value from a register REG." @@ -1728,13 +1727,11 @@ Used by `calculator-paste' and `get-register'." (interactive) (set-buffer calculator-buffer) (let ((inhibit-read-only t)) (erase-buffer)) - (if (not calculator-electric-mode) - (progn - (condition-case nil - (while (get-buffer-window calculator-buffer) - (delete-window (get-buffer-window calculator-buffer))) - (error nil)) - (kill-buffer calculator-buffer))) + (unless calculator-electric-mode + (ignore-errors + (while (get-buffer-window calculator-buffer) + (delete-window (get-buffer-window calculator-buffer)))) + (kill-buffer calculator-buffer)) (setq calculator-buffer nil) (message "Calculator done.") (if calculator-electric-mode (throw 'calculator-done nil))) @@ -1768,14 +1765,11 @@ To use this, apply a binary operator (evaluate it), then call this." (defun calculator-integer-p (x) "Non-nil if X is equal to an integer." - (condition-case nil - (= x (ftruncate x)) - (error nil))) + (ignore-errors (= x (ftruncate x)))) (defun calculator-expt (x y) "Compute X^Y, dealing with errors appropriately." - (condition-case - nil + (condition-case nil (expt x y) (domain-error 0.0e+NaN) (range-error diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index c12ac06868..31d0495175 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -286,7 +286,7 @@ List has a form of (file-name full-file-name (attribute-list))." (if (eq op-symbol 'touch) (list "-t" new-attribute) (list new-attribute))) - (if (string-match "gnu" system-configuration) + (if (string-match-p "gnu" system-configuration) '("--") nil)) files)) (dired-do-redisplay arg);; moves point if ARG is an integer @@ -327,7 +327,7 @@ into the minibuffer." ;; We used to treat empty input as DEFAULT, but that is not ;; such a good idea (Bug#9361). (error "No file mode specified")) - ((string-match "^[0-7]+" modes) + ((string-match-p "^[0-7]+" modes) (setq num-modes (string-to-number modes 8)))) (dolist (file files) @@ -500,7 +500,7 @@ with a prefix argument." (goto-char (point-min)) (while (not (eobp)) (save-excursion - (and (not (looking-at dired-re-dir)) + (and (not (looking-at-p dired-re-dir)) (not (eolp)) (setq file (dired-get-filename nil t)) ; nil on non-file (progn (end-of-line) @@ -530,7 +530,7 @@ with a prefix argument." dired-file-version-alist))))))) (defun dired-trample-file-versions (fn) - (let* ((start-vn (string-match "\\.~[0-9]+~$" fn)) + (let* ((start-vn (string-match-p "\\.~[0-9]+~$" fn)) base-version-list) (and start-vn (setq base-version-list ; there was a base version to which @@ -602,7 +602,7 @@ The output appears in the buffer `*Async Shell Command*'." (dired-read-shell-command "& on %s: " current-prefix-arg files) current-prefix-arg files))) - (unless (string-match "&[ \t]*\\'" command) + (unless (string-match-p "&[ \t]*\\'" command) (setq command (concat command " &"))) (dired-do-shell-command command arg file-list)) @@ -663,10 +663,10 @@ can be produced by `dired-get-marked-files', for example." (dired-read-shell-command "! on %s: " current-prefix-arg files) current-prefix-arg files))) - (let* ((on-each (not (string-match dired-star-subst-regexp command))) - (no-subst (not (string-match dired-quark-subst-regexp command))) - (star (string-match "\\*" command)) - (qmark (string-match "\\?" command))) + (let* ((on-each (not (string-match-p dired-star-subst-regexp command))) + (no-subst (not (string-match-p dired-quark-subst-regexp command))) + (star (string-match-p "\\*" command)) + (qmark (string-match-p "\\?" command))) ;; Get confirmation for wildcards that may have been meant ;; to control substitution of a file name or the file name list. (if (cond ((not (or on-each no-subst)) @@ -713,8 +713,8 @@ can be produced by `dired-get-marked-files', for example." (substring command 0 (match-beginning 0)) command)) (stuff-it - (if (or (string-match dired-star-subst-regexp command) - (string-match dired-quark-subst-regexp command)) + (if (or (string-match-p dired-star-subst-regexp command) + (string-match-p dired-quark-subst-regexp command)) (lambda (x) (let ((retval command)) (while (string-match @@ -840,9 +840,7 @@ command with a prefix argument (the value does not matter)." (if new-file (let ((start (point))) ;; Remove any preexisting entry for the name NEW-FILE. - (condition-case nil - (dired-remove-entry new-file) - (error nil)) + (ignore-errors (dired-remove-entry new-file)) (goto-char start) ;; Now replace the current line with an entry for NEW-FILE. (dired-update-file-line new-file) nil) @@ -883,7 +881,7 @@ Otherwise, the rule is a compression rule, and compression is done with gzip.") ;; See if any suffix rule matches this file name. (while suffixes (let (case-fold-search) - (if (string-match (car (car suffixes)) file) + (if (string-match-p (car (car suffixes)) file) (setq suffix (car suffixes) suffixes nil)) (setq suffixes (cdr suffixes)))) ;; If so, compute desired new name. @@ -1143,16 +1141,16 @@ files matching `dired-omit-regexp'." ;; Avoid calling ls for files that are going to be omitted anyway. (let ((omit-re (dired-omit-regexp))) (or (string= omit-re "") - (not (string-match omit-re - (cond - ((eq 'no-dir dired-omit-localp) - filename) - ((eq t dired-omit-localp) - (dired-make-relative filename)) - (t - (dired-make-absolute - filename - (file-name-directory filename))))))))) + (not (string-match-p omit-re + (cond + ((eq 'no-dir dired-omit-localp) + filename) + ((eq t dired-omit-localp) + (dired-make-relative filename)) + (t + (dired-make-absolute + filename + (file-name-directory filename))))))))) ;; Do it! (progn (setq filename (directory-file-name filename)) @@ -1180,7 +1178,7 @@ files matching `dired-omit-regexp'." ;; else try to find correct place to insert (if (dired-goto-subdir directory) (progn ;; unhide if necessary - (if (looking-at "\r") + (if (looking-at-p "\r") ;; Point is at end of subdir line. (dired-unhide-subdir)) ;; found - skip subdir and `total' line @@ -2090,7 +2088,7 @@ This function takes some pains to conform to `ls -lR' output." (and (not switches) cons (setq switches (cdr cons))) (dired-insert-subdir-validate dirname switches) ;; case-fold-search is nil now, so we can test for capital `R': - (if (setq switches-have-R (and switches (string-match "R" switches))) + (if (setq switches-have-R (and switches (string-match-p "R" switches))) ;; avoid duplicated subdirs (setq mark-alist (dired-kill-tree dirname t))) (if elt @@ -2128,8 +2126,8 @@ This function takes some pains to conform to `ls -lR' output." (mapcar (function (lambda (x) - (or (eq (null (string-match x real-switches)) - (null (string-match x dired-actual-switches))) + (or (eq (null (string-match-p x real-switches)) + (null (string-match-p x dired-actual-switches))) (error "Can't have dirs with and without -%s switches together" x)))) ;; all switches that make a difference to dired-get-filename: @@ -2170,7 +2168,7 @@ of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well." (defun dired-insert-subdir-newpos (new-dir) ;; Find pos for new subdir, according to tree order. ;;(goto-char (point-max)) - (let ((alist dired-subdir-alist) elt dir pos new-pos) + (let ((alist dired-subdir-alist) elt dir new-pos) (while alist (setq elt (car alist) alist (cdr alist) @@ -2421,7 +2419,7 @@ Lower levels are unaffected." (and selective-display (save-excursion (dired-goto-subdir dir) - (looking-at "\r")))) + (looking-at-p "\r")))) ;;;###autoload (defun dired-hide-subdir (arg) diff --git a/lisp/dired.el b/lisp/dired.el index 48f1b463f4..f830623a25 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -34,6 +34,9 @@ ;;; Code: +(declare-function dired-buffer-more-recently-used-p + "dired-x" (buffer1 buffer2)) + ;;; Customizable variables (defgroup dired nil @@ -1242,26 +1245,25 @@ see `dired-use-ls-dired' for more details.") (save-excursion (goto-char beg) (while (< (point) end) - (condition-case nil - (if (not (dired-move-to-filename)) - (put-text-property (line-beginning-position) - (1+ (line-end-position)) - 'invisible 'dired-hide-details-information) - (put-text-property (+ (line-beginning-position) 1) (1- (point)) - 'invisible 'dired-hide-details-detail) - (add-text-properties - (point) - (progn - (dired-move-to-end-of-filename) - (point)) - '(mouse-face - highlight - dired-filename t - help-echo "mouse-2: visit this file in other window")) - (when (< (+ (point) 4) (line-end-position)) - (put-text-property (+ (point) 4) (line-end-position) - 'invisible 'dired-hide-details-link))) - (error nil)) + (ignore-errors + (if (not (dired-move-to-filename)) + (put-text-property (line-beginning-position) + (1+ (line-end-position)) + 'invisible 'dired-hide-details-information) + (put-text-property (+ (line-beginning-position) 1) (1- (point)) + 'invisible 'dired-hide-details-detail) + (add-text-properties + (point) + (progn + (dired-move-to-end-of-filename) + (point)) + '(mouse-face + highlight + dired-filename t + help-echo "mouse-2: visit this file in other window")) + (when (< (+ (point) 4) (line-end-position)) + (put-text-property (+ (point) 4) (line-end-position) + 'invisible 'dired-hide-details-link)))) (forward-line 1)))) ;; Reverting a dired buffer @@ -1401,11 +1403,9 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (setq elt (car old-subdir-alist) old-subdir-alist (cdr old-subdir-alist) dir (car elt)) - (condition-case () - (progn - (dired-uncache dir) - (dired-insert-subdir dir)) - (error nil)))))) + (ignore-errors + (dired-uncache dir) + (dired-insert-subdir dir)))))) (defun dired-uncache (dir) "Remove directory DIR from any directory cache." @@ -3849,7 +3849,7 @@ Ask means pop up a menu for the user to select one of copy, move or link." ;;; Start of automatically extracted autoloads. -;;;### (autoloads nil "dired-aux" "dired-aux.el" "555c067fcab27f5a377536db407803ab") +;;;### (autoloads nil "dired-aux" "dired-aux.el" "04b4cb6bde3220f55574eb1d99ac0d29") ;;; Generated autoloads from dired-aux.el (autoload 'dired-diff "dired-aux" "\ diff --git a/lisp/filenotify.el b/lisp/filenotify.el index d2f37b9910..5a5435bb4c 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el @@ -92,7 +92,7 @@ car of that event, which is the symbol `file-notify'." (pending-event (assoc desc file-notify--pending-events)) (actions (nth 1 event)) (file (file-notify--event-file-name event)) - file1 cookie callback) + file1 callback) ;; Make actions a list. (unless (consp actions) (setq actions (cons actions nil))) diff --git a/lisp/filesets.el b/lisp/filesets.el index fbf28dbecb..82891770f1 100644 --- a/lisp/filesets.el +++ b/lisp/filesets.el @@ -214,8 +214,8 @@ key is supported." (defun filesets-which-command-p (cmd) "Call \"which CMD\" and return non-nil if the command was found." - (when (string-match (format "\\(/[^/]+\\)?/%s" cmd) - (filesets-which-command cmd)) + (when (string-match-p (format "\\(/[^/]+\\)?/%s" cmd) + (filesets-which-command cmd)) cmd)) (defun filesets-message (level &rest args) @@ -1082,7 +1082,7 @@ defined in `filesets-ingroup-patterns'." (require 'easymenu) - (defun filesets-error (class &rest args) + (defun filesets-error (_class &rest args) "`error' wrapper." (error "%s" (mapconcat 'identity args " "))) @@ -1093,10 +1093,10 @@ defined in `filesets-ingroup-patterns'." If NEGATIVE is non-nil, remove all directory names." (filesets-filter-list lst (lambda (x) - (and (not (string-match "^\\.+/$" x)) + (and (not (string-match-p "^\\.+/$" x)) (if negative - (not (string-match "[:/\\]$" x)) - (string-match "[:/\\]$" x)))))) + (not (string-match-p "[:/\\]$" x)) + (string-match-p "[:/\\]$" x)))))) (defun filesets-conditional-sort (lst &optional access-fn) "Return a sorted copy of LST, LST being a list of strings. @@ -1130,18 +1130,18 @@ Return full path if FULL-FLAG is non-nil." (dirs nil)) (dolist (this (file-name-all-completions "" dir)) (cond - ((string-match "^\\.+/$" this) + ((string-match-p "^\\.+/$" this) nil) - ((string-match "[:/\\]$" this) + ((string-match-p "[:/\\]$" this) (when (or (not match-dirs-flag) (not pattern) - (string-match pattern this)) + (string-match-p pattern this)) (filesets-message 5 "Filesets: matched dir %S with pattern %S" this pattern) (setq dirs (cons this dirs)))) (t (when (or (not pattern) - (string-match pattern this)) + (string-match-p pattern this)) (filesets-message 5 "Filesets: matched file %S with pattern %S" this pattern) (setq files (cons (if full-flag @@ -1249,7 +1249,7 @@ Return full path if FULL-FLAG is non-nil." (let ((filename (file-name-nondirectory file))) (filesets-some (lambda (entry) - (when (and (string-match (nth 0 entry) filename) + (when (and (string-match-p (nth 0 entry) filename) (filesets-eviewer-constraint-p entry)) entry)) filesets-external-viewers))) @@ -2004,7 +2004,7 @@ LOOKUP-NAME is used as lookup name for retrieving fileset specific settings." (fn (or fun (lambda (a b) (and (stringp a) (stringp b) - (string-match a b)))))) + (string-match-p a b)))))) (filesets-some (lambda (x) (if (funcall fn (car x) masterfile) (nth pos x) diff --git a/lisp/find-file.el b/lisp/find-file.el index 9f7d877ec3..d9a9f08f19 100644 --- a/lisp/find-file.el +++ b/lisp/find-file.el @@ -528,11 +528,9 @@ the `ff-ignore-include' variable." stub ;; name of the file without extension alist ;; working copy of the list of file extensions pathname ;; the pathname of the file or the #include line - default-name ;; file we should create if none found format ;; what we have to match found ;; name of the file or buffer found - nil if none - dirs ;; local value of ff-search-directories - no-match) ;; whether we know about this kind of file + dirs) ;; local value of ff-search-directories (message "Working...") @@ -545,7 +543,6 @@ the `ff-ignore-include' variable." (cond ((and (not ff-ignore-include) fname) - (setq default-name fname) (setq found (ff-get-file-name dirs fname nil))) ;; let's just get the corresponding file @@ -558,7 +555,6 @@ the `ff-ignore-include' variable." "/none.none")) (setq fname (file-name-nondirectory pathname) - no-match nil match (car alist)) ;; find the table entry corresponding to this file @@ -569,8 +565,7 @@ the `ff-ignore-include' variable." (setq pos (ff-string-match (car match) fname))) ;; no point going on if we haven't found anything - (if (not match) - (setq no-match t) + (when match ;; otherwise, suffixes contains what we need (setq suffixes (car (cdr match)) @@ -583,8 +578,7 @@ the `ff-ignore-include' variable." (progn (setq suffixes (funcall action (buffer-file-name)) match (cons (car match) (list suffixes)) - stub nil - default-name (car suffixes))) + stub nil)) ;; otherwise build our filename stub (cond @@ -599,11 +593,7 @@ the `ff-ignore-include' variable." (setq format (concat "\\(.+\\)" (car match))) (string-match format fname) (setq stub (substring fname (match-beginning 1) (match-end 1))) - )) - - ;; if we find nothing, we should try to get a file like this one - (setq default-name - (concat stub (car (car (cdr match)))))) + ))) ;; do the real work - find the file (setq found @@ -671,7 +661,7 @@ name of the first file found." (setq buf (buffer-name (car blist))) (while (and blist (not found)) - (if (string-match (concat filename "<[0-9]+>") buf) + (if (string-match-p (concat filename "<[0-9]+>") buf) (setq found (buffer-file-name (car blist)))) (setq blist (cdr blist)) @@ -797,20 +787,18 @@ See variable `ff-special-constructs'." "Get all the directory files under directory HERE. Exclude all files in the optional EXCLUDE list." (if (file-directory-p here) - (condition-case nil - (progn - (let ((files (directory-files here t)) - (dirlist (list)) - file) - (while files - (setq file (car files)) - (if (and - (file-directory-p file) - (not (member (ff-basename file) exclude))) - (setq dirlist (cons file dirlist))) - (setq files (cdr files))) - (setq dirlist (reverse dirlist)))) - (error nil)) + (ignore-errors + (let ((files (directory-files here t)) + (dirlist (list)) + file) + (while files + (setq file (car files)) + (if (and + (file-directory-p file) + (not (member (ff-basename file) exclude))) + (setq dirlist (cons file dirlist))) + (setq files (cdr files))) + (setq dirlist (reverse dirlist)))) nil)) (defun ff-switch-file (f1 f2 file &optional in-other-window new-file) @@ -892,9 +880,7 @@ Given START and/or END, checks between these characters." Build up a new file list based possibly on part of the directory name and the name of the file passed in." (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg) - (let ((path (if (match-beginning 1) - (substring arg (match-beginning 1) (match-end 1)) nil)) - (dire (if (match-beginning 2) + (let ((dire (if (match-beginning 2) (substring arg (match-beginning 2) (match-end 2)) nil)) (file (if (match-beginning 3) (substring arg (match-beginning 3) (match-end 3)) nil)) diff --git a/lisp/follow.el b/lisp/follow.el index 53b32e5703..3fcdf24f4f 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -515,7 +515,7 @@ Works like `scroll-up' when not in Follow mode." (declare-function comint-adjust-point "comint" (window)) (defvar comint-scroll-show-maximum-output) -(defun follow-comint-scroll-to-bottom (&optional window) +(defun follow-comint-scroll-to-bottom (&optional _window) "Scroll the bottom-most window in the current Follow chain. This is to be called by `comint-postoutput-scroll-to-bottom'." (let* ((buffer (current-buffer)) @@ -883,15 +883,14 @@ returned by `follow-windows-start-end'." (defun follow-select-if-visible (dest win-start-end) "Select and return a window, if DEST is visible in it. Return the selected window." - (let (win win-end wse) + (let (win wse) (while (and (not win) win-start-end) ;; Don't select a window that was just moved. This makes it ;; possible to later select the last window after a ;; `end-of-buffer' command. (setq wse (car win-start-end)) (when (follow-pos-visible dest (car wse) win-start-end) - (setq win (car wse) - win-end (nth 2 wse)) + (setq win (car wse)) (select-window win)) (setq win-start-end (cdr win-start-end))) win)) diff --git a/lisp/forms.el b/lisp/forms.el index 37914bf546..38fc0b320d 100644 --- a/lisp/forms.el +++ b/lisp/forms.el @@ -439,6 +439,8 @@ Also, initial position is at last record." (defvar forms--rw-face nil "Face used to represent read-write data on the screen.") +(defvar read-file-filter) ; bound in forms--intuit-from-file + ;;;###autoload (defun forms-mode (&optional primary) "Major mode to visit files in a field-structured manner using a form. @@ -913,7 +915,7 @@ Commands: Equivalent keys in read-only mode: `(lambda (arg) (let ((inhibit-read-only t)) ,@(apply 'append - (mapcar 'forms--make-format-elt-using-text-properties + (mapcar #'forms--make-format-elt-using-text-properties forms-format-list)) ;; Prevent insertion before the first text. ,@(if (numberp (car forms-format-list)) @@ -926,7 +928,7 @@ Commands: Equivalent keys in read-only mode: (setq forms--iif-start nil)) `(lambda (arg) ,@(apply 'append - (mapcar 'forms--make-format-elt forms-format-list))))) + (mapcar #'forms--make-format-elt forms-format-list))))) ;; We have tallied the number of markers and dynamic texts, ;; so we can allocate the arrays now. @@ -1098,7 +1100,7 @@ Commands: Equivalent keys in read-only mode: (goto-char (point-min)) ,@(apply 'append (mapcar - 'forms--make-parser-elt + #'forms--make-parser-elt (append forms-format-list (list nil))))))))) (forms--debug 'forms--parser)) @@ -1198,8 +1200,6 @@ Commands: Equivalent keys in read-only mode: (setq forms--field nil))) )) -(defvar read-file-filter) ; bound in forms--intuit-from-file - (defun forms--intuit-from-file () "Get number of fields and a default form using the data file." @@ -1569,10 +1569,10 @@ As a side effect: sets `forms--the-record-list'." ;; Build new record. (setq forms--the-record-list (forms--parse-form)) (setq the-record - (mapconcat 'identity forms--the-record-list forms-field-sep)) + (mapconcat #'identity forms--the-record-list forms-field-sep)) - (if (string-match (regexp-quote forms-field-sep) - (mapconcat 'identity forms--the-record-list "")) + (if (string-match-p (regexp-quote forms-field-sep) + (mapconcat #'identity forms--the-record-list "")) (error "Field separator occurs in record - update refused")) ;; Handle multi-line fields, if allowed. @@ -1580,7 +1580,7 @@ As a side effect: sets `forms--the-record-list'." (forms--trans the-record "\n" forms-multi-line)) ;; A final sanity check before updating. - (if (string-match "\n" the-record) + (if (string-match-p "\n" the-record) (error "Multi-line fields in this record - update refused")) (with-current-buffer forms--file-buffer @@ -1779,11 +1779,7 @@ after the current record." (setq the-list (cdr (append the-fields nil)))) (setq the-list (make-list forms-number-of-fields ""))) - (setq the-record - (mapconcat - 'identity - the-list - forms-field-sep)) + (setq the-record (mapconcat #'identity the-list forms-field-sep)) (with-current-buffer forms--file-buffer (forms--goto-record ln) diff --git a/lisp/help-mode.el b/lisp/help-mode.el index b56adc2a4a..5553556e03 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -268,7 +268,7 @@ The format is (FUNCTION ARGS...).") (define-button-type 'help-dir-local-var-def :supertype 'help-xref - 'help-function (lambda (var &optional file) + 'help-function (lambda (_var &optional file) ;; FIXME: this should go to the point where the ;; local variable was defined. (find-file file)) @@ -541,7 +541,7 @@ that." (while (and (not (eobp)) ;; Stop at a pair of blank lines. - (not (looking-at "\n\\s-*\n"))) + (not (looking-at-p "\n\\s-*\n"))) ;; Skip a single blank line. (and (eolp) (forward-line)) (end-of-line) @@ -605,26 +605,25 @@ See `help-make-xrefs'." (save-restriction (narrow-to-region from to) (goto-char (point-min)) - (condition-case nil - (while (not (eobp)) - (cond - ((looking-at "\"") (forward-sexp 1)) - ((looking-at "#<") (search-forward ">" nil 'move)) - ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)") - (let* ((sym (intern-soft (match-string 1))) - (type (cond ((fboundp sym) 'help-function) - ((or (memq sym '(t nil)) - (keywordp sym)) - nil) - ((and sym - (or (boundp sym) - (get sym - 'variable-documentation))) - 'help-variable)))) - (when type (help-xref-button 1 type sym))) - (goto-char (match-end 1))) - (t (forward-char 1)))) - (error nil))))))) + (ignore-errors + (while (not (eobp)) + (cond + ((looking-at-p "\"") (forward-sexp 1)) + ((looking-at-p "#<") (search-forward ">" nil 'move)) + ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)") + (let* ((sym (intern-soft (match-string 1))) + (type (cond ((fboundp sym) 'help-function) + ((or (memq sym '(t nil)) + (keywordp sym)) + nil) + ((and sym + (or (boundp sym) + (get sym + 'variable-documentation))) + 'help-variable)))) + (when type (help-xref-button 1 type sym))) + (goto-char (match-end 1))) + (t (forward-char 1)))))))))) ;; Additional functions for (re-)creating types of help buffers. diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 09d7c14334..ce29505d6f 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -53,6 +53,8 @@ (defvar ibuffer-tmp-hide-regexps) (defvar ibuffer-tmp-show-regexps) +(declare-function ibuffer-ext-visible-p "ibuf-ext" + (buf all &optional ibuffer-buf)) (declare-function ibuffer-mark-on-buffer "ibuf-ext" (func &optional ibuffer-mark-on-buffer-mark group)) (declare-function ibuffer-generate-filter-groups "ibuf-ext" @@ -1198,7 +1200,7 @@ a new window in the current frame, splitting vertically." (and (stringp (cadr err)) ;; This definitely falls in the ;; ghetto hack category... - (not (string-match "too small" (cadr err))))) + (not (string-match-p "too small" (cadr err))))) (signal (car err) (cdr err)) (enlarge-window 3)))))) (select-window (next-window)) diff --git a/lisp/msb.el b/lisp/msb.el index 4bde993ff8..110a427737 100644 --- a/lisp/msb.el +++ b/lisp/msb.el @@ -386,7 +386,7 @@ This is instead of the groups in `msb-menu-cond'." ;;; ;;; Some example function to be used for `msb-item-handling-function'. ;;; -(defun msb-item-handler (buffer &optional maxbuf) +(defun msb-item-handler (_buffer &optional _maxbuf) "Create one string item, concerning BUFFER, for the buffer menu. The item looks like: *% @@ -410,7 +410,7 @@ Optional second argument MAXBUF is completely ignored." (error "Unknown type of `dired-directory' in buffer %s" (buffer-name))))) -(defun msb-dired-item-handler (buffer &optional maxbuf) +(defun msb-dired-item-handler (_buffer &optional _maxbuf) "Create one string item, concerning a dired BUFFER, for the buffer menu. The item looks like: *% diff --git a/lisp/ses.el b/lisp/ses.el index bf88364456..5f48dd2f27 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -703,7 +703,6 @@ for this spreadsheet." (and (string-match "\\`\\([A-Z]+\\)\\([0-9]+\\)\\'" str) (let* ((col-str (match-string-no-properties 1 str)) (col 0) - (col-offset 0) (col-base 1) (col-idx (1- (length col-str))) (row (1- (string-to-number (match-string-no-properties 2 str))))) @@ -740,7 +739,7 @@ row and column of the cell, with numbering starting from 0. Return nil in case of failure." (unless (local-variable-p sym) (make-local-variable sym) - (if (let (case-fold-search) (string-match "\\`[A-Z]+[0-9]+\\'" (symbol-name sym))) + (if (let (case-fold-search) (string-match-p "\\`[A-Z]+[0-9]+\\'" (symbol-name sym))) (put sym 'ses-cell (cons row col)) (put sym 'ses-cell :ses-named) (setq ses--named-cell-hashmap (or ses--named-cell-hashmap (make-hash-table :test 'eq))) @@ -1474,7 +1473,7 @@ Sets `ses-relocate-return' to 'delete if cell-references were removed." (let (rowcol result) (if (or (atom formula) (eq (car formula) 'quote)) (if (and (setq rowcol (ses-sym-rowcol formula)) - (string-match "\\`[A-Z]+[0-9]+\\'" (symbol-name formula))) + (string-match-p "\\`[A-Z]+[0-9]+\\'" (symbol-name formula))) (ses-relocate-symbol formula rowcol startrow startcol rowincr colincr) formula) ; Pass through as-is. @@ -1735,7 +1734,7 @@ Does not execute cell formulas or print functions." (search-backward ";; Local Variables:\n" nil t) (backward-list 1) (setq ses--params-marker (point-marker)) - (let ((params (condition-case nil (read (current-buffer)) (error nil)))) + (let ((params (ignore-errors (read (current-buffer))))) (or (and (= (safe-length params) 3) (numberp (car params)) (numberp (cadr params)) @@ -1761,7 +1760,7 @@ Does not execute cell formulas or print functions." ;; Skip over print area, which we assume is correct. (goto-char (point-min)) (forward-line ses--numrows) - (or (looking-at ses-print-data-boundary) + (or (looking-at-p ses-print-data-boundary) (error "Missing marker between print and data areas")) (forward-char 1) (setq ses--data-marker (point-marker)) @@ -1774,12 +1773,12 @@ Does not execute cell formulas or print functions." (dotimes (col ses--numcols) (let* ((x (read (current-buffer))) (sym (car-safe (cdr-safe x)))) - (or (and (looking-at "\n") + (or (and (looking-at-p "\n") (eq (car-safe x) 'ses-cell) (ses-create-cell-variable sym row col)) (error "Cell-def error")) (eval x))) - (or (looking-at "\n\n") + (or (looking-at-p "\n\n") (error "Missing blank line between rows"))) ;; Load global parameters. (let ((widths (read (current-buffer))) @@ -1805,8 +1804,8 @@ Does not execute cell formulas or print functions." (1value (eval head-row))) ;; Should be back at global-params. (forward-char 1) - (or (looking-at (replace-regexp-in-string "1" "[0-9]+" - ses-initial-global-parameters)) + (or (looking-at-p (replace-regexp-in-string "1" "[0-9]+" + ses-initial-global-parameters)) (error "Problem with column-defs or global-params")) ;; Check for overall newline count in definitions area. (forward-line 3) @@ -2077,9 +2076,8 @@ Based on the current set of columns and `window-hscroll' position." (defun ses-jump-safe (cell) "Like `ses-jump', but no error if invalid cell." - (condition-case nil - (ses-jump cell) - (error))) + (ignore-errors + (ses-jump cell))) (defun ses-reprint-all (&optional nonarrow) "Recreate the display area. Calls all printer functions. Narrows to @@ -2789,7 +2787,7 @@ We clear the killed cells instead of deleting them." ;; For some reason, the text-read-only error is not caught by `delete-region', ;; so we have to use subterfuge. (let ((buffer-read-only t)) - (1value (condition-case x + (1value (condition-case nil (noreturn (funcall (lookup-key (current-global-map) (this-command-keys)) beg end)) @@ -3014,13 +3012,13 @@ spot, or error signal if user requests cancel." (ses-col-printer (1- ses--numcols))))) rowcol)) -(defun ses-export-tsv (beg end) +(defun ses-export-tsv (_beg _end) "Export values from the current range, with tabs between columns and newlines between rows. Result is placed in kill ring." (interactive "r") (ses-export-tab nil)) -(defun ses-export-tsf (beg end) +(defun ses-export-tsf (_beg _end) "Export formulas from the current range, with tabs between columns and newlines between rows. Result is placed in kill ring." (interactive "r") @@ -3298,7 +3296,7 @@ highlighted range in the spreadsheet." (let* ((x (ses-sym-rowcol ref)) (xcell (ses-get-cell (car x) (cdr x)))) (ses-cell-references-aset xcell - (cons new-name (delq sym + (cons new-name (delq sym (ses-cell-references xcell)))))) (push new-name ses--renamed-cell-symb-list) (set new-name (symbol-value sym)) @@ -3579,7 +3577,7 @@ current column and continues until the next nonblank column." current column and continues until the next nonblank column." (ses-center-span value ?~)) -(defun ses-unsafe (value) +(defun ses-unsafe (_value) "Substitute for an unsafe formula or printer." (error "Unsafe formula or printer")) diff --git a/lisp/tabify.el b/lisp/tabify.el index a90bf801bc..44a233717d 100644 --- a/lisp/tabify.el +++ b/lisp/tabify.el @@ -28,7 +28,7 @@ ;;; Code: ;;;###autoload -(defun untabify (start end &optional arg) +(defun untabify (start end &optional _arg) "Convert all tabs in region to multiple spaces, preserving columns. If called interactively with prefix ARG, convert for the entire buffer. @@ -61,7 +61,7 @@ Usually this will be \" [ \\t]+\" to match a space followed by whitespace. \"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.") ;;;###autoload -(defun tabify (start end &optional arg) +(defun tabify (start end &optional _arg) "Convert multiple spaces in region to tabs when possible. A group of spaces is partially replaced by tabs when this can be done without changing the column they end at. diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index b7ecdb513f..b67a32a24f 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -84,48 +84,47 @@ positions of the thing found." (if (get thing 'bounds-of-thing-at-point) (funcall (get thing 'bounds-of-thing-at-point)) (let ((orig (point))) - (condition-case nil - (save-excursion - ;; Try moving forward, then back. - (funcall ;; First move to end. - (or (get thing 'end-op) - (lambda () (forward-thing thing 1)))) - (funcall ;; Then move to beg. - (or (get thing 'beginning-op) - (lambda () (forward-thing thing -1)))) - (let ((beg (point))) - (if (<= beg orig) - ;; If that brings us all the way back to ORIG, - ;; it worked. But END may not be the real end. - ;; So find the real end that corresponds to BEG. - ;; FIXME: in which cases can `real-end' differ from `end'? - (let ((real-end - (progn - (funcall - (or (get thing 'end-op) - (lambda () (forward-thing thing 1)))) - (point)))) - (when (and (<= orig real-end) (< beg real-end)) - (cons beg real-end))) - (goto-char orig) - ;; Try a second time, moving backward first and then forward, - ;; so that we can find a thing that ends at ORIG. - (funcall ;; First, move to beg. - (or (get thing 'beginning-op) - (lambda () (forward-thing thing -1)))) - (funcall ;; Then move to end. - (or (get thing 'end-op) - (lambda () (forward-thing thing 1)))) - (let ((end (point)) - (real-beg + (ignore-errors + (save-excursion + ;; Try moving forward, then back. + (funcall ;; First move to end. + (or (get thing 'end-op) + (lambda () (forward-thing thing 1)))) + (funcall ;; Then move to beg. + (or (get thing 'beginning-op) + (lambda () (forward-thing thing -1)))) + (let ((beg (point))) + (if (<= beg orig) + ;; If that brings us all the way back to ORIG, + ;; it worked. But END may not be the real end. + ;; So find the real end that corresponds to BEG. + ;; FIXME: in which cases can `real-end' differ from `end'? + (let ((real-end (progn (funcall - (or (get thing 'beginning-op) - (lambda () (forward-thing thing -1)))) + (or (get thing 'end-op) + (lambda () (forward-thing thing 1)))) (point)))) - (if (and (<= real-beg orig) (<= orig end) (< real-beg end)) - (cons real-beg end)))))) - (error nil))))) + (when (and (<= orig real-end) (< beg real-end)) + (cons beg real-end))) + (goto-char orig) + ;; Try a second time, moving backward first and then forward, + ;; so that we can find a thing that ends at ORIG. + (funcall ;; First, move to beg. + (or (get thing 'beginning-op) + (lambda () (forward-thing thing -1)))) + (funcall ;; Then move to end. + (or (get thing 'end-op) + (lambda () (forward-thing thing 1)))) + (let ((end (point)) + (real-beg + (progn + (funcall + (or (get thing 'beginning-op) + (lambda () (forward-thing thing -1)))) + (point)))) + (if (and (<= real-beg orig) (<= orig end) (< real-beg end)) + (cons real-beg end)))))))))) ;;;###autoload (defun thing-at-point (thing &optional no-properties) @@ -217,21 +216,19 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." \[Internal function used by `bounds-of-thing-at-point'.]" (save-excursion (let ((opoint (point)) - (beg (condition-case nil - (progn (up-list -1) - (point)) - (error nil)))) - (condition-case nil - (if beg - (progn (forward-sexp) - (cons beg (point))) - ;; Are we are at the beginning of a top-level sexp? - (forward-sexp) - (let ((end (point))) - (backward-sexp) - (if (>= opoint (point)) - (cons opoint end)))) - (error nil))))) + (beg (ignore-errors + (up-list -1) + (point)))) + (ignore-errors + (if beg + (progn (forward-sexp) + (cons beg (point))) + ;; Are we are at the beginning of a top-level sexp? + (forward-sexp) + (let ((end (point))) + (backward-sexp) + (if (>= opoint (point)) + (cons opoint end)))))))) ;; Defuns @@ -358,7 +355,7 @@ the bounds of a possible ill-formed URI (one lacking a scheme)." (if found (cons (match-beginning 1) (match-end 1)))))) -(defun thing-at-point--bounds-of-well-formed-url (beg end pt) +(defun thing-at-point--bounds-of-well-formed-url (beg end _pt) (save-excursion (goto-char beg) (let (url-beg paren-end regexp) @@ -453,16 +450,14 @@ looks like an email address, \"ftp://\" if it starts with htb ret) (while htbs (setq htb (car htbs) htbs (cdr htbs)) - (condition-case nil - (progn - ;; errs: htb symbol may be unbound, or not a hash-table. - ;; gnus-gethash is just a macro for intern-soft. - (and (symbol-value htb) - (intern-soft string (symbol-value htb)) - (setq ret string htbs nil)) - ;; If we made it this far, gnus is running, so ignore "heads": - (setq heads nil)) - (error nil))) + (ignore-errors + ;; errs: htb symbol may be unbound, or not a hash-table. + ;; gnus-gethash is just a macro for intern-soft. + (and (symbol-value htb) + (intern-soft string (symbol-value htb)) + (setq ret string htbs nil)) + ;; If we made it this far, gnus is running, so ignore "heads": + (setq heads nil))) (or ret (not heads) (let ((head (string-match "\\`\\([[:lower:]]+\\)\\." string))) (and head (setq head (substring string 0 (match-end 1))) @@ -566,9 +561,8 @@ Signal an error if the entire string was not used." (car read-data)))) (defun form-at-point (&optional thing pred) - (let ((sexp (condition-case nil - (read-from-whole-string (thing-at-point (or thing 'sexp))) - (error nil)))) + (let ((sexp (ignore-errors + (read-from-whole-string (thing-at-point (or thing 'sexp)))))) (if (or (not pred) (funcall pred sexp)) sexp))) ;;;###autoload -- 2.20.1