* dired-guess-shell-alist-user: How to match folders instead of file types?
@ 2013-06-25 11:24 Marius Hofert
2013-06-25 11:42 ` Peter Dyballa
2013-06-25 14:35 ` Doug Lewan
0 siblings, 2 replies; 13+ messages in thread
From: Marius Hofert @ 2013-06-25 11:24 UTC (permalink / raw)
To: Emacs help
Hi,
I use ...
(setq dired-guess-shell-alist-user
'(("\\.zip\\'" "(unzip ? &>/dev/null &)")
("\\.tar.gz\\'" "(tar xzf ? &>/dev/null &)")))
... to execute the corresponding command from dired-mode (on
M-!). I am wondering how one can match *folders* (in contrast to
file types such as .zip, .tar.gz), such that M-! suggests a
command to be executed on folders?
Cheers,
Marius
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
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:35 ` Doug Lewan
1 sibling, 1 reply; 13+ messages in thread
From: Peter Dyballa @ 2013-06-25 11:42 UTC (permalink / raw)
To: Marius Hofert; +Cc: Emacs help
Am 25.06.2013 um 13:24 schrieb Marius Hofert:
> I am wondering how one can match *folders* (in contrast to
> file types such as .zip, .tar.gz), such that M-! suggests a
> command to be executed on folders?
Insert a pair of a ^directory name\' (or a full path name, whatever is necessary) instead of a regular expression and an action and see what happens!
--
Mit friedvollen Grüßen
Pete
Without vi there is only GNU Emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
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
0 siblings, 2 replies; 13+ messages in thread
From: Marius Hofert @ 2013-06-25 12:02 UTC (permalink / raw)
To: Peter Dyballa; +Cc: Emacs help
Dear Pete,
Thanks for helping.
I am not looking for a particular directory, I am rather looking for
the name of the directory the point is on (in dired-mode).
If the point is on foo.tar.gz and I use M-!, I already get the
suggestion to 'untar' the file the point is on. I am looking for the
same feature, but in the case where the point is on a directory in
order to, say, to zip it. For this, I have to match directories but I
am not sure how this can be done.
Cheers,
Marius
On Tue, Jun 25, 2013 at 1:42 PM, Peter Dyballa <Peter_Dyballa@web.de> wrote:
>
> Am 25.06.2013 um 13:24 schrieb Marius Hofert:
>
>> I am wondering how one can match *folders* (in contrast to
>> file types such as .zip, .tar.gz), such that M-! suggests a
>> command to be executed on folders?
>
> Insert a pair of a ^directory name\' (or a full path name, whatever is necessary) instead of a regular expression and an action and see what happens!
>
> --
> Mit friedvollen Grüßen
>
> Pete
>
> Without vi there is only GNU Emacs
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-25 12:02 ` Marius Hofert
@ 2013-06-25 14:00 ` Peter Dyballa
2013-06-25 19:28 ` Stephen Berman
1 sibling, 0 replies; 13+ messages in thread
From: Peter Dyballa @ 2013-06-25 14:00 UTC (permalink / raw)
To: Marius Hofert; +Cc: Emacs help
Am 25.06.2013 um 14:02 schrieb Marius Hofert:
> For this, I have to match directories but I am not sure how this can be done.
Aren't there only two choices: a regular expression or a simple text string?
--
Mit friedvollen Grüßen
Pete
"Klingons do not believe in indentation - except perhaps in the skulls of their project managers."
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: dired-guess-shell-alist-user: How to match folders instead of file types?
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 14:35 ` Doug Lewan
1 sibling, 0 replies; 13+ messages in thread
From: Doug Lewan @ 2013-06-25 14:35 UTC (permalink / raw)
To: Marius Hofert, Emacs help
Well, thanks for this thread.
Now I know about dired-x.
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?
-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of Marius Hofert
Sent: Tuesday, 2013 June 25 07:25
To: Emacs help
Subject: dired-guess-shell-alist-user: How to match folders instead of file types?
Hi,
I use ...
(setq dired-guess-shell-alist-user
'(("\\.zip\\'" "(unzip ? &>/dev/null &)")
("\\.tar.gz\\'" "(tar xzf ? &>/dev/null &)")))
... to execute the corresponding command from dired-mode (on
M-!). I am wondering how one can match *folders* (in contrast to
file types such as .zip, .tar.gz), such that M-! suggests a
command to be executed on folders?
Cheers,
Marius
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
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
1 sibling, 1 reply; 13+ messages in thread
From: Stephen Berman @ 2013-06-25 19:28 UTC (permalink / raw)
To: Marius Hofert; +Cc: Emacs help
On Tue, 25 Jun 2013 14:02:21 +0200 Marius Hofert <marius.hofert@math.ethz.ch> wrote:
> I am not looking for a particular directory, I am rather looking for
> the name of the directory the point is on (in dired-mode).
>
> If the point is on foo.tar.gz and I use M-!, I already get the
> suggestion to 'untar' the file the point is on. I am looking for the
> same feature, but in the case where the point is on a directory in
> order to, say, to zip it. For this, I have to match directories but I
> am not sure how this can be done.
Try adding this to dired-guess-shell-alist-user as the first element in
the list (replacing the shell command invocation with what you want):
(".*" (when (file-directory-p (dired-get-filename))
"(tar czf ? &>/dev/null &)"))
Steve Berman
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-25 19:28 ` Stephen Berman
@ 2013-06-25 20:34 ` Marius Hofert
2013-06-27 11:22 ` Marius Hofert
0 siblings, 1 reply; 13+ messages in thread
From: Marius Hofert @ 2013-06-25 20:34 UTC (permalink / raw)
To: Stephen Berman; +Cc: Emacs help
Works like a charm, thanks Steve!
On Tue, Jun 25, 2013 at 9:28 PM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Tue, 25 Jun 2013 14:02:21 +0200 Marius Hofert <marius.hofert@math.ethz.ch> wrote:
>
>> I am not looking for a particular directory, I am rather looking for
>> the name of the directory the point is on (in dired-mode).
>>
>> If the point is on foo.tar.gz and I use M-!, I already get the
>> suggestion to 'untar' the file the point is on. I am looking for the
>> same feature, but in the case where the point is on a directory in
>> order to, say, to zip it. For this, I have to match directories but I
>> am not sure how this can be done.
>
> Try adding this to dired-guess-shell-alist-user as the first element in
> the list (replacing the shell command invocation with what you want):
>
> (".*" (when (file-directory-p (dired-get-filename))
> "(tar czf ? &>/dev/null &)"))
>
> Steve Berman
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-25 20:34 ` Marius Hofert
@ 2013-06-27 11:22 ` Marius Hofert
2013-06-27 11:48 ` Stephen Berman
0 siblings, 1 reply; 13+ messages in thread
From: Marius Hofert @ 2013-06-27 11:22 UTC (permalink / raw)
To: Stephen Berman; +Cc: Emacs help
... 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.
Do you know why this happens? [this is with the latest snapshot: GNU
Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4)]
Cheers,
Marius
On Tue, Jun 25, 2013 at 10:34 PM, Marius Hofert
<marius.hofert@math.ethz.ch> wrote:
> Works like a charm, thanks Steve!
>
>
>
> On Tue, Jun 25, 2013 at 9:28 PM, Stephen Berman <stephen.berman@gmx.net> wrote:
>> On Tue, 25 Jun 2013 14:02:21 +0200 Marius Hofert <marius.hofert@math.ethz.ch> wrote:
>>
>>> I am not looking for a particular directory, I am rather looking for
>>> the name of the directory the point is on (in dired-mode).
>>>
>>> If the point is on foo.tar.gz and I use M-!, I already get the
>>> suggestion to 'untar' the file the point is on. I am looking for the
>>> same feature, but in the case where the point is on a directory in
>>> order to, say, to zip it. For this, I have to match directories but I
>>> am not sure how this can be done.
>>
>> Try adding this to dired-guess-shell-alist-user as the first element in
>> the list (replacing the shell command invocation with what you want):
>>
>> (".*" (when (file-directory-p (dired-get-filename))
>> "(tar czf ? &>/dev/null &)"))
>>
>> Steve Berman
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-27 11:22 ` Marius Hofert
@ 2013-06-27 11:48 ` Stephen Berman
2013-06-27 12:25 ` Marius Hofert
0 siblings, 1 reply; 13+ messages in thread
From: Stephen Berman @ 2013-06-27 11:48 UTC (permalink / raw)
To: Marius Hofert; +Cc: Emacs help
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. 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, you could wrap the command
expresion in the corresponding entry in an `unless' form, e.g.:
(".xyz" (unless (file-directory-p (dired-get-filename)) "shell-command")
Hope that helps.
Steve Berman
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-27 11:48 ` Stephen Berman
@ 2013-06-27 12:25 ` Marius Hofert
2013-06-27 13:33 ` Stephen Berman
0 siblings, 1 reply; 13+ messages in thread
From: Marius Hofert @ 2013-06-27 12:25 UTC (permalink / raw)
To: Stephen Berman; +Cc: Emacs help
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.
> you could wrap the command
> expresion in the corresponding entry in an `unless' form, e.g.:
> (".xyz" (unless (file-directory-p (dired-get-filename)) "shell-command")
>
okay, thanks.
Marius
> Hope that helps.
>
> Steve Berman
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-27 12:25 ` Marius Hofert
@ 2013-06-27 13:33 ` Stephen Berman
2013-06-27 14:28 ` Marius Hofert
2013-06-30 19:38 ` Marius Hofert
0 siblings, 2 replies; 13+ messages in thread
From: Stephen Berman @ 2013-06-27 13:33 UTC (permalink / raw)
To: Marius Hofert; +Cc: Emacs help
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-27 13:33 ` Stephen Berman
@ 2013-06-27 14:28 ` Marius Hofert
2013-06-30 19:38 ` Marius Hofert
1 sibling, 0 replies; 13+ messages in thread
From: Marius Hofert @ 2013-06-27 14:28 UTC (permalink / raw)
To: Stephen Berman; +Cc: Emacs help
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: dired-guess-shell-alist-user: How to match folders instead of file types?
2013-06-27 13:33 ` Stephen Berman
2013-06-27 14:28 ` Marius Hofert
@ 2013-06-30 19:38 ` Marius Hofert
1 sibling, 0 replies; 13+ messages in thread
From: Marius Hofert @ 2013-06-30 19:38 UTC (permalink / raw)
To: Stephen Berman; +Cc: Emacs help
Hi Steve,
If I have marked ('m') several files in dired-mode and use '!', I get
"No file on this line" and no choice to put in a command. I think it
has to do with the "(when (file-directory-p (dired-get-filename)))".
If you just use (".*" "(tar czf all.tar.gz ? &>/dev/null &)") as last
entry, for example, this problem does not appear.
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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-06-30 19:38 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-06-27 14:28 ` Marius Hofert
2013-06-30 19:38 ` Marius Hofert
2013-06-25 14:35 ` Doug Lewan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).