From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.help Subject: Re: Simple useful function Date: Mon, 5 Jul 2010 23:56:50 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1278367081 17454 80.91.229.12 (5 Jul 2010 21:58:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Jul 2010 21:58:01 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Andrea Crotti Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 05 23:57:59 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 1OVtfr-0003ep-0V for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Jul 2010 23:57:59 +0200 Original-Received: from localhost ([127.0.0.1]:39201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVtfq-0001An-Kt for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Jul 2010 17:57:58 -0400 Original-Received: from [140.186.70.92] (port=39146 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVtfH-00019w-6H for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 17:57:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVtfF-0002lp-Ni for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 17:57:23 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:33182) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVtfF-0002ld-IP for help-gnu-emacs@gnu.org; Mon, 05 Jul 2010 17:57:21 -0400 Original-Received: by fxm20 with SMTP id 20so117870fxm.0 for ; Mon, 05 Jul 2010 14:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=KQnZXRXROw7W7uJj7LtCxX7atRQ6MBot+pCdKgAacyA=; b=JVdnvfWTH4IPuwWiDFF7OmEEv+cBSZddHlaeitnwYmvl+1wwgCYdlmlOcMEA6FhAlT OPRzXmsgDUnYAqgo0iYwB+mkry6wCqOqFlGH5cFXVM7fTm6JH5P7RUynsGp8NLwLfkHC 88kUv+m7ZCk8lYlFDNoVwKW6eYOzlyQG93+fo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=ANkhruakiksbBrj54SwsoXBMSC+rMLVLrBT0yiVhS+3mvF/F7nbpKBQMji1fQDHLiP KwtNDMZ4GwFQp7kEg2EkCXYvHRKf6C+w3s2sYc50ZdzBahXqPv/74vaYHLSp+FrquPLY Q8WhKWZPx5a3D+7yzfsOoC3V3nVvxWzwH8jb0= Original-Received: by 10.239.162.129 with SMTP id l1mr276358hbd.7.1278367040154; Mon, 05 Jul 2010 14:57:20 -0700 (PDT) Original-Received: by 10.239.160.139 with HTTP; Mon, 5 Jul 2010 14:56:50 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:74083 Archived-At: 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 > > --8<---------------cut here---------------start------------->8--- > (defun open-git-files () > =A0"Visit all the files in the current git project" > =A0(interactive) > =A0(dolist > =A0 =A0 =A0(file (split-string (shell-command-to-string "git ls-files"))) > =A0 =A0(message "Opening %s" file) > =A0 =A0;; we have to keep the original position > =A0 =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)) --=20 Deniz Dogan