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

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

Re: Simple useful function


From: Lennart Borgman
Subject: Re: Simple useful function
Date: Tue, 6 Jul 2010 13:11:49 +0200

On Tue, Jul 6, 2010 at 1:03 PM, Andrea Crotti <address@hidden> wrote:
>
> (defun ls-git-files ()
>  (if
>      (file-exists-p ".git")
>      (split-string (shell-command-to-string "git ls-files"))
>    (message "not a git repo")))
> --8<---------------cut here---------------end--------------->8---
>
> Any improvement is welcome ;)
> Does ls-git-files "returns" nil automatically if ".git" is not found?

No. The last statement run will be (message ...) and the doc string
for message says "Return the message".

Just add nil if you want it to return nil:

(defun ls-git-files ()
 (if
     (file-exists-p ".git")
     (split-string (shell-command-to-string "git ls-files"))
   (message "not a git repo")
   nil))



reply via email to

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