all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

* RE: About `current-directory-list'
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2012-12-23  2:25 UTC (permalink / raw)
  To: 'Xue Fuqiao', help-gnu-emacs

> 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?

It is a local variable bound in that `let'.  You show two bindings:

1. `el-files-list' is bound to nil (implicitly).
2. `current-directory-list' is bound to (directory-files-and...).

I, for one, prefer to write any implicit bindings last, after the explicit ones:

(let ((current-directory-list  (directory-files-...))
      el-files-list)

I think that is more readable.  And if I want to draw attention to an initial
value of nil then I use an explicit binding.  And if it is a list variable then
I use (); if a Boolean or other I use nil.  E.g.:

(let ((el-files-list  ())
      (found          nil))




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

* Re: About `current-directory-list'
  2012-12-23  2:25 ` Drew Adams
@ 2012-12-23  2:42   ` Xue Fuqiao
  0 siblings, 0 replies; 3+ messages in thread
From: Xue Fuqiao @ 2012-12-23  2:42 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

On Sat, 22 Dec 2012 18:25:58 -0800
"Drew Adams" <drew.adams@oracle.com> wrote:

> 1. `el-files-list' is bound to nil (implicitly).
> 2. `current-directory-list' is bound to (directory-files-and...).
Thanks, I read it wrong(carelessly).

-- 
Best regards.



^ 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.