emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master e820f16: Added file-tree-walk to files.el.


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master e820f16: Added file-tree-walk to files.el.
Date: Wed, 03 Dec 2014 10:31:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> +(defun file-tree-walk (dir action &rest args)
> +  "Walk DIR executing ACTION.  Each call gets as arguments DIR, a file path,

The first line should be self-sufficient, so better add a newline after
the ".".

> +and optional ARGS. The ACTION is applied to each subdirectory
                    ^^
Use two spaces to separate sentences.

> +before descending into it, and if nil is returned at that point
> +the descent will be prevented.  Directory entries are sorted with
> +string-lessp"
             ^^^
Don't forget to punctuate your docstrings.

I think C-u M-x checkdoc-current-buffer RET would have caught all those.

We really should try and setup flymake.el automatically for Elisp
buffers to flag those things on-the-fly.

> +  (cond ((file-directory-p dir)
> +      (or (char-equal ?/ (aref dir (1- (length dir))))
> +          (setq dir (file-name-as-directory dir)))
> +      (let ((lst (directory-files dir nil nil t))

Experience taught me that file-name-all-completions followed by testing
the presence of a trailing "/" is *much* faster because calling
file-directory-p on each entry ends up costly.

I got this trick from Eshell's code for ** globbing, where the speed
difference was a factor 10 when I tested it.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]