From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Davison Newsgroups: gmane.emacs.help Subject: Re: Simple useful function Date: Mon, 05 Jul 2010 18:58:57 -0400 Message-ID: <87vd8tk026.fsf@stats.ox.ac.uk> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1278370773 27910 80.91.229.12 (5 Jul 2010 22:59:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Jul 2010 22:59:33 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, Andrea Crotti To: Deniz Dogan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 06 00:59:31 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OVudN-0000sx-HF for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Jul 2010 00:59:29 +0200 Original-Received: from localhost ([127.0.0.1]:36841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVudM-0000m3-JD for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Jul 2010 18:59:28 -0400 Original-Received: from [140.186.70.92] (port=45244 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVucy-0000ly-7b for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 18:59:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVucw-0005gM-Tg for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 18:59:04 -0400 Original-Received: from markov.stats.ox.ac.uk ([163.1.210.1]:55965) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVucw-0005g1-Lc for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 18:59:02 -0400 Original-Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o65Mwxnr014724; Mon, 5 Jul 2010 23:58:59 +0100 (BST) Original-Received: by blackcap.stats.ox.ac.uk (Postfix, from userid 5158) id 62B0421A24; Mon, 5 Jul 2010 23:58:59 +0100 (BST) In-Reply-To: (Deniz Dogan's message of "Mon, 5 Jul 2010 23:56:50 +0200") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Solaris 8 (1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74084 Archived-At: Deniz Dogan writes: > 2010/7/5 Andrea Crotti : >> 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 () >> =C2=A0"Visit all the files in the current git project" >> =C2=A0(interactive) >> =C2=A0(dolist >> =C2=A0 =C2=A0 =C2=A0(file (split-string (shell-command-to-string "git ls= -files"))) >> =C2=A0 =C2=A0(message "Opening %s" file) >> =C2=A0 =C2=A0;; we have to keep the original position >> =C2=A0 =C2=A0(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))