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

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

Re: Simple useful function


From: Deniz Dogan
Subject: Re: Simple useful function
Date: Mon, 5 Jul 2010 23:56:50 +0200

2010/7/5 Andrea Crotti <address@hidden>:
> I write it here because I hope someone will find it useful...
>
> I wrote this function to open all the files listed in my git repository
>
> --8<---------------cut here---------------start------------->8---
> (defun open-git-files ()
>  "Visit all the files in the current git project"
>  (interactive)
>  (dolist
>      (file (split-string (shell-command-to-string "git ls-files")))
>    (message "Opening %s" file)
>    ;; we have to keep the original position
>    (find-file file)))
> --8<---------------cut here---------------end--------------->8---
>
> The problem is that if I understand well when I find the file I also
> change the current directory, and then nothing works anymore...
>
> I also tried to store the start point and concatenate it but it also
> doesn't work.
>
> Is there a smarter way to do it? (maybe not using git ls-files at all?)
>
>
>

Just wrap the call to `find-file' in `save-excursion' and you're good.

(save-excursion
  (find-file file))

-- 
Deniz Dogan



reply via email to

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