From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Stephen Berman <stephen.berman@gmx.net>
Newsgroups: gmane.emacs.help
Subject: Re: dired-guess-shell-alist-user: How to match folders instead of
	file types?
Date: Thu, 27 Jun 2013 15:33:38 +0200
Message-ID: <87wqpfu18t.fsf@rosalinde.fritz.box>
References: <CAM3-KjajDPxZmCF1FoJ0Y+zsQ1LbxrQ2JwoqJaGAJhgR8P=n6Q@mail.gmail.com>
	<792EB2D2-E2CF-446E-ADF4-5B5BD92C8146@Web.DE>
	<CAM3-KjZxQogVRoGS+fwPz7r5V50XwzDrOMU8Bm6p4J70XYJiEw@mail.gmail.com>
	<87r4fq56t1.fsf@rosalinde.fritz.box>
	<CAM3-KjZjH=8am8i=GJLjUhq62YehXRB+a26_oWk-BbTvFtLkNw@mail.gmail.com>
	<CAM3-KjbRHzNVB=JHTQYrLtvXnJVwM0nKM+tRj7D26_OHKwb=qw@mail.gmail.com>
	<874ncjvknu.fsf@rosalinde.fritz.box>
	<CAM3-KjaGZAS=pCgZ4PHwTjstt2Npr57C+ceW+Arnd7Azt=gO5Q@mail.gmail.com>
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: ger.gmane.org 1372340047 18282 80.91.229.3 (27 Jun 2013 13:34:07 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 27 Jun 2013 13:34:07 +0000 (UTC)
Cc: Emacs help <help-gnu-emacs@gnu.org>
To: Marius Hofert <marius.hofert@math.ethz.ch>
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 27 15:34:07 2013
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1UsCKt-0002c2-Hm
	for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 15:34:07 +0200
Original-Received: from localhost ([::1]:34336 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1UsCKt-00015D-5o
	for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 09:34:07 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33879)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@gmx.net>) id 1UsCKX-0000yh-Ky
	for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 09:33:52 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephen.berman@gmx.net>) id 1UsCKT-0003dg-Bt
	for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 09:33:45 -0400
Original-Received: from mout.gmx.net ([212.227.15.18]:53051)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@gmx.net>) id 1UsCKT-0003dP-1m
	for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 09:33:41 -0400
Original-Received: from mailout-de.gmx.net ([10.1.76.19]) by mrigmx.server.lan
	(mrigmx002) with ESMTP (Nemesis) id 0LuZtm-1UANCV3YpM-00zobs for
	<help-gnu-emacs@gnu.org>; Thu, 27 Jun 2013 15:33:39 +0200
Original-Received: (qmail invoked by alias); 27 Jun 2013 13:33:39 -0000
Original-Received: from i59F5577E.versanet.de (EHLO rosalinde.fritz.box) [89.245.87.126]
	by mail.gmx.net (mp019) with SMTP; 27 Jun 2013 15:33:39 +0200
X-Authenticated: #20778731
X-Provags-ID: V01U2FsdGVkX1+9sqs67kq91qbwhf5A6AzmpqVAFSI/FIC8YdjzzQ
	haarwnHh1qy+Hf
In-Reply-To: <CAM3-KjaGZAS=pCgZ4PHwTjstt2Npr57C+ceW+Arnd7Azt=gO5Q@mail.gmail.com>
	(Marius Hofert's message of "Thu, 27 Jun 2013 14:25:20 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
X-Y-GMX-Trusted: 0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-Received-From: 212.227.15.18
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:91772
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/91772>

On Thu, 27 Jun 2013 14:25:20 +0200 Marius Hofert <marius.hofert@math.ethz.ch> wrote:

> On Thu, Jun 27, 2013 at 1:48 PM, Stephen Berman <stephen.berman@gmx.net> wrote:
>> On Thu, 27 Jun 2013 13:22:00 +0200 Marius Hofert
>> <marius.hofert@math.ethz.ch> wrote:
>>
>>> ... I was too fast. It does indeed work now for the point being on
>>> directories. However, for the other assignments (like using unzip on
>>> .zip files) I don't get the corresponding suggestion anymore...
>>>
>>> I put your code in the beginning of 'dired-guess-shell-alist-user' as you said.
>>
>> Sorry, I made a silly mistake: the regexp `.*' matches any file, so the
>> entry needs to be the *last* one in dired-guess-shell-alist-user.
>
> Thanks, Steve.
>
>>  But then you have to be sure that none of the preceding entries match a
>> directory.  This will probably be true of any file ending in `.zip',
>> `.tgz', etc.  If you do have any directories whose names have endings
>> that could also be used for non-directory files,
>
> Including or excluding the dot '.'? There are rarely directories named
> 'My.zip", but I could imagine a directory Myzip to exist.

`Myzip' would be matched by ".*" (the dot here is a special character in
the regexp, matching any character).  But if you have a directory
`My.zip' it would have already been matched by "\.zip\'", so here you'll
have to add the Lisp expression to prevent the wrong shell command from
applying to it.  However, what I wrote previously was insufficient: once
the match is satisfied, no further patterns are tested.  So if you want
the shell command suggestion with `!' in Dired to be unzip on a
non-directory file "Myfile.zip" and to be zip on a directory
"Mydir.zip", the entry in dired-guess-shell-alist-user should be this
(modulo whatever your actual shell commands are):

("\\.zip\\'" (if (file-directory-p (dired-get-filename))
                  "(zip ? &>/dev/null &)"
                "(unzip ? &>/dev/null &)"))

(This time I actually tested it, so I hope it now really works for you!)

Steve Berman