unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* About `current-directory-list'
@ 2012-12-23  1:58 Xue Fuqiao
  2012-12-23  2:25 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Xue Fuqiao @ 2012-12-23  1:58 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

In node 14.9.2 of Bob's `An Introduction to Programming in Emacs Lisp'(http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/Files-List.html#Files-List), there is a function called `files-in-below-directory' that lists the .el files in a directory and its subdirs.

The varlist of the `let' special form is:
(el-files-list
 (current-directory-list
  (directory-files-and-attributes directory t)))

I don't know what does `current-directory-list' means, in my Emacs(24.2), there isn't a function named `current-directory-list'.  Can anybody help?
-- 
Best regards.

[-- Attachment #2: filelist.el --]
[-- Type: application/octet-stream, Size: 1715 bytes --]

(defun files-in-below-directory (directory)
  "List the .el files in DIRECTORY and in its sub-directories."
  ;; Although the function will be used non-interactively,
  ;; it will be easier to test if we make it interactive.
  ;; The directory will have a name such as
  ;;  "/usr/local/share/emacs/22.1.1/lisp/"
  (interactive "DDirectory name: ")
  (let (el-files-list
        (current-directory-list
         (directory-files-and-attributes directory t)))
    ;; while we are in the current directory
    (while current-directory-list
      (cond
       ;; check to see whether filename ends in `.el'
       ;; and if so, append its name to a list.
       ((equal ".el" (substring (car (car current-directory-list)) -3))
        (setq el-files-list
              (cons (car (car current-directory-list)) el-files-list)))
       ;; check whether filename is that of a directory
       ((eq t (car (cdr (car current-directory-list))))
        ;; decide whether to skip or recurse
        (if
            (equal "."
                   (substring (car (car current-directory-list)) -1))
            ;; then do nothing since filename is that of
            ;;   current directory or parent, "." or ".."
            ()
          ;; else descend into the directory and repeat the process
          (setq el-files-list
                (append
                 (files-in-below-directory
                  (car (car current-directory-list)))
                 el-files-list)))))
      ;; move to the next filename in the list; this also
      ;; shortens the list so the while loop eventually comes to an end
      (setq current-directory-list (cdr current-directory-list)))
    ;; return the filenames
    el-files-list))

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-23  2:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-23  1:58 About `current-directory-list' Xue Fuqiao
2012-12-23  2:25 ` Drew Adams
2012-12-23  2:42   ` Xue Fuqiao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).