From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.help Subject: Re: Simple useful function Date: Tue, 6 Jul 2010 13:11:49 +0200 Message-ID: References: <87vd8tk026.fsf@stats.ox.ac.uk> 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 1278414759 13909 80.91.229.12 (6 Jul 2010 11:12:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Jul 2010 11:12:39 +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 Tue Jul 06 13:12:37 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 1OW64r-0002c0-Bt for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Jul 2010 13:12:37 +0200 Original-Received: from localhost ([127.0.0.1]:43302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OW64p-0007vF-Ra for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Jul 2010 07:12:35 -0400 Original-Received: from [140.186.70.92] (port=38283 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OW64R-0007v1-Nl for help-gnu-emacs@gnu.org; Tue, 06 Jul 2010 07:12:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OW64Q-0002Zt-DJ for help-gnu-emacs@gnu.org; Tue, 06 Jul 2010 07:12:11 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:45282) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OW64Q-0002Zk-AR for help-gnu-emacs@gnu.org; Tue, 06 Jul 2010 07:12:10 -0400 Original-Received: by iwn2 with SMTP id 2so6234631iwn.0 for ; Tue, 06 Jul 2010 04:12:09 -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=UkRYY7MrxuogCp7z9cCJJPGwszdelOmYg9NFRwjTJ04=; b=EyIuXyxmHQh9vPg6Ae8tLhAAlcR3fSCbnZHtKyQgquaCwipIzMwtQq6LGClcUR8o/4 S1EXDo3KyAPSmSEhjajVhEKFtjt+EeU0RKwNhyEG9CXJw3yy0iKVqZTDrEFgIj5Ux4z0 PVrP3b3JUaImTlx9n5jCrGRyzdvnmgT/+QK1o= 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=LVWpSgzhfFMUdJeeTw95PVddgAYsyQfP4GGauPmZbloQf832UzJoH6oltqxJsHmplu KoXiuiWEQ1kWQPkoYpC0ZkMaxHu9W+7OlpcldPYFgRQSAaEiNfSW7xUMb9wHJgUDLuuQ 5MDt3lPMGcqsLMRcMS7Mp5xOKea+8L4DcMkCI= Original-Received: by 10.231.191.66 with SMTP id dl2mr4951404ibb.101.1278414729505; Tue, 06 Jul 2010 04:12:09 -0700 (PDT) Original-Received: by 10.231.170.83 with HTTP; Tue, 6 Jul 2010 04:11:49 -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:74096 Archived-At: On Tue, Jul 6, 2010 at 1:03 PM, Andrea Crotti w= rote: > > (defun ls-git-files () > =C2=A0(if > =C2=A0 =C2=A0 =C2=A0(file-exists-p ".git") > =C2=A0 =C2=A0 =C2=A0(split-string (shell-command-to-string "git ls-files"= )) > =C2=A0 =C2=A0(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? No. The last statement run will be (message ...) and the doc string for message says "Return the message". Just add nil if you want it to return nil: (defun ls-git-files () (if (file-exists-p ".git") (split-string (shell-command-to-string "git ls-files")) (message "not a git repo") nil))