[Top][All Lists]

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

Re: Simple useful function

From: Andrea Crotti
Subject: Re: Simple useful function
Date: Tue, 06 Jul 2010 13:03:48 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (darwin)

"Drew Adams" <address@hidden> writes:
> If you have an Emacs function that returns those file names (absolute or
> relative), then you can open a Dired buffer for just those files.
> You do that by calling `dired' with a cons arg: the list of file names.  If 
> the
> files are not all in the same directory, then use absolute names.  For 
> example:
>  (dired "My GIT Files" '("/my/first/file" "/my/2nd/file"...))
> `C-h f dired':

Very nice, I simply did something like:

--8<---------------cut here---------------start------------->8---
(defun open-git-files ()
  "Visit all the files in the current git project"
      (file (ls-git-files))
    (message "Opening %s" file)
    ;; we have to keep the original position
    (save-excursion (find-file file))))

(defun dired-git-files ()
  (dired (ls-git-files)))

(defun ls-git-files ()
      (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?

reply via email to

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