help-gnu-emacs
[Top][All Lists]
Advanced

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

elisp: returning a local variable


From: Glen Stark
Subject: elisp: returning a local variable
Date: Sun, 10 Mar 2013 10:39:53 +0000 (UTC)
User-agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)

Hi everyone.

I'm doing some stuff in elisp, largely in an effort to become competent 
in it.  I would like to obtain a list of subdirectories in the current 
working directory.  I couldn't find a method that does this, so I tried 
writing my own.  I got this far:


(defun get-all-subdirectories ()
  "Returns a list of directories in the current working folder"
  (interactive)
  (let ((src-list (file-expand-wildcards "*"))
        (retval ()))
    (dolist (fname src-list)
      (when (file-directory-p fname) (push fname retval))
      )
    )
  )     

Which does indeed assemble a list of subdirectories into retval, but I 
can't figure out how to return it as the return value of the function 
(yes, I could setq to global variable, but I prefer not to do this).

Can anyone help me out here?  
        1)  how do I accomplish this?  
        2)  Is there an existing method that does this?

Thanks for your help.

Glen





reply via email to

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