]> code.delx.au - gnu-emacs/blobdiff - lisp/find-lisp.el
Simplify ‘delete-trailing-whitespace’ by not treating \n as whitespace
[gnu-emacs] / lisp / find-lisp.el
index cacfd57e9fb72f7239a06f4448e82ff0e89363b4..8591eb841c122ffef4dc0544d02334066b78221c 100644 (file)
@@ -4,7 +4,7 @@
 ;; Created: Fri Mar 26 1999
 ;; Keywords: unix
 
-;; Copyright (C) 1999-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -53,7 +53,7 @@
   "Internal variable.")
 
 (defconst find-lisp-line-indent "  "
-  "Indentation for dired file lines.")
+  "Indentation for Dired file lines.")
 
 (defvar find-lisp-file-predicate nil
   "Predicate for choosing to include files.")
@@ -118,7 +118,7 @@ Argument DIR is the directory containing FILE."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun find-lisp-find-files (directory regexp)
-  "Find files in DIRECTORY which match REGEXP."
+  "Find files under DIRECTORY, recursively, that match REGEXP."
   (let ((file-predicate      'find-lisp-default-file-predicate)
        (directory-predicate 'find-lisp-default-directory-predicate)
        (find-lisp-regexp regexp))
@@ -192,7 +192,6 @@ It is a function which takes two arguments, the directory and its parent."
                                          directory-predicate buffer-name)
   "Run find (Lisp version) and go into Dired mode on a buffer of the output."
   (let ((dired-buffers dired-buffers)
-       buf
        (regexp find-lisp-regexp))
     ;; Expand DIR ("" means default-directory), and make sure it has a
     ;; trailing slash.
@@ -203,7 +202,7 @@ It is a function which takes two arguments, the directory and its parent."
     (or
      (and (buffer-name)
          (string= buffer-name (buffer-name)))
-       (switch-to-buffer (setq buf (get-buffer-create buffer-name))))
+       (switch-to-buffer (get-buffer-create buffer-name)))
     (widen)
     (kill-all-local-variables)
     (setq buffer-read-only nil)
@@ -223,7 +222,7 @@ It is a function which takes two arguments, the directory and its parent."
     (make-local-variable 'revert-buffer-function)
     (setq revert-buffer-function
          (function
-          (lambda(ignore1 ignore2)
+          (lambda (_ignore1 _ignore2)
             (find-lisp-insert-directory
              default-directory
              find-lisp-file-predicate
@@ -246,10 +245,10 @@ It is a function which takes two arguments, the directory and its parent."
     (goto-char (point-min))
     (dired-goto-next-file)))
 
-(defun find-lisp-insert-directory  (dir
-                                   file-predicate
-                                   directory-predicate
-                                   sort-function)
+(defun find-lisp-insert-directory (dir
+                                   file-predicate
+                                   directory-predicate
+                                  _sort-function)
   "Insert the results of `find-lisp-find-files' in the current buffer."
   (let ((buffer-read-only nil)
        (files (find-lisp-find-files-internal
@@ -269,7 +268,7 @@ It is a function which takes two arguments, the directory and its parent."
     ;; Run the find function
     (mapc
      (function
-      (lambda(file)
+      (lambda (file)
        (find-lisp-find-dired-insert-file
         (substring file len)
         (current-buffer))))
@@ -281,7 +280,7 @@ It is a function which takes two arguments, the directory and its parent."
 
 ;;;###autoload
 (defun find-lisp-find-dired-filter (regexp)
-  "Change the filter on a find-lisp-find-dired buffer to REGEXP."
+  "Change the filter on a `find-lisp-find-dired' buffer to REGEXP."
   (interactive "sSet filter to regexp: ")
   (setq find-lisp-regexp regexp)
   (revert-buffer))
@@ -298,6 +297,9 @@ It is a function which takes two arguments, the directory and its parent."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun find-lisp-format (file-name file-attr switches now)
+  "Format one line of long ls output for file FILE-NAME.
+FILE-ATTR and FILE-SIZE give the file's attributes and size.
+SWITCHES and TIME-INDEX give the full switch list and time data."
   (let ((file-type (nth 0 file-attr)))
     (concat (if (memq ?i switches)     ; inode number
                (format "%6d " (nth 10 file-attr)))
@@ -326,7 +328,7 @@ It is a function which takes two arguments, the directory and its parent."
            "\n")))
 
 (defun find-lisp-time-index (switches)
-  ;; Return index into file-attributes according to ls SWITCHES.
+  "Return index into file-attributes according to ls SWITCHES."
   (cond
    ((memq ?c switches) 6)              ; last mode change
    ((memq ?u switches) 4)              ; last access
@@ -334,10 +336,11 @@ It is a function which takes two arguments, the directory and its parent."
    (t 5)))
 
 (defun find-lisp-format-time (file-attr switches now)
-  ;; Format time string for file with attributes FILE-ATTR according
-  ;; to SWITCHES (a list of ls option letters of which c and u are recognized).
-  ;; Use the same method as `ls' to decide whether to show time-of-day or year,
-  ;; depending on distance between file date and NOW.
+  "Format time string for file.
+This is done with attributes FILE-ATTR according to SWITCHES (a
+list of ls option letters of which c and u are recognized).  Use
+the same method as \"ls\" to decide whether to show time-of-day or
+year, depending on distance between file date and NOW."
   (let* ((time (nth (find-lisp-time-index switches) file-attr))
         (diff16 (- (car time) (car now)))
         (diff (+ (ash diff16 16) (- (car (cdr time)) (car (cdr now)))))