help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired-guess-shell-alist-user: How to match folders instead of file t


From: Marius Hofert
Subject: Re: dired-guess-shell-alist-user: How to match folders instead of file types?
Date: Thu, 27 Jun 2013 16:28:08 +0200

Thanks, Steve.

Cheers,

Marius

On Thu, Jun 27, 2013 at 3:33 PM, Stephen Berman <stephen.berman@gmx.net> wrote:
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]