all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Marius Hofert <marius.hofert@math.ethz.ch>
Cc: Emacs help <help-gnu-emacs@gnu.org>
Subject: Re: dired-guess-shell-alist-user: How to match folders instead of file types?
Date: Thu, 27 Jun 2013 15:33:38 +0200	[thread overview]
Message-ID: <87wqpfu18t.fsf@rosalinde.fritz.box> (raw)
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")

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	other threads:[~2013-06-27 13:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25 11:24 dired-guess-shell-alist-user: How to match folders instead of file types? Marius Hofert
2013-06-25 11:42 ` Peter Dyballa
2013-06-25 12:02   ` Marius Hofert
2013-06-25 14:00     ` Peter Dyballa
2013-06-25 19:28     ` Stephen Berman
2013-06-25 20:34       ` Marius Hofert
2013-06-27 11:22         ` Marius Hofert
2013-06-27 11:48           ` Stephen Berman
2013-06-27 12:25             ` Marius Hofert
2013-06-27 13:33               ` Stephen Berman [this message]
2013-06-27 14:28                 ` Marius Hofert
2013-06-30 19:38                 ` Marius Hofert
2013-06-25 14:35 ` Doug Lewan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqpfu18t.fsf@rosalinde.fritz.box \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=marius.hofert@math.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.