[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple useful function
From: |
Dan Davison |
Subject: |
Re: Simple useful function |
Date: |
Mon, 05 Jul 2010 18:58:57 -0400 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
Deniz Dogan <deniz.a.m.dogan@gmail.com> writes:
> 2010/7/5 Andrea Crotti <andrea.crotti.0@gmail.com>:
>> 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
Is there a way to do this sort of stuff with dired (perhaps involving
magit)? E.g. how would one limit dired to showing just the files that
git is tracking?
Dan
>>
>> --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))
- Simple useful function, Andrea Crotti, 2010/07/05
- Re: Simple useful function, Deniz Dogan, 2010/07/05
- Re: Simple useful function,
Dan Davison <=
- Re: Simple useful function, Andrea Crotti, 2010/07/06
- Re: Simple useful function, Lennart Borgman, 2010/07/06
- Re: Simple useful function, Andrea Crotti, 2010/07/06
- Re: Simple useful function, Lennart Borgman, 2010/07/06