1

Using emacs on cygwin, one shell command I use very often from dired buffers using ! bound to dired-do-shell-command is cygstart, .e.g to open a Word document or a Visual Studio project or whatever.

But hitting ! on current directory entry, ., results in error Cannot operate on.' or ..'.

I wanted to find out before I bypass it and allow the command to be run on current and parent directories. Is there any reason for this restriction?

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133

2 Answers2

1

dired-do-shell-command calls dired-get-filename.

If you take a look on the dired-get-filename doc you will see

(dired-get-filename &optional LOCALP NO-ERROR-IF-NOT-FILEP)

In Dired, return name of file mentioned on this line.

...

Optional arg NO-ERROR-IF-NOT-FILEP means treat .' and ..' as regular filenames and return nil if no filename on this line. Otherwise, an error occurs in these cases.

dired-get-filename is called without NO-ERROR-IF-NOT-FILEP argument

Oleg Pavliv
  • 20,462
  • 7
  • 59
  • 75
  • And that is my question...why is `dired-get-filename` is called without `NO-ERROR-IF-NOT-FILEP` argument? – Miserable Variable Oct 24 '12 at 19:26
  • Because it's called from dired-get-marked-files. This function is often used to copy/delete/etc marked files which makes no sense for . and .. files – Oleg Pavliv Oct 24 '12 at 19:39
  • I can't agree with that logic, though you may be right. Why punish `dired-do-shell-command` for sometimes-convenience of copy/delete marked files. – Miserable Variable Oct 24 '12 at 20:01
0

This restriction has been lifted since the question was asked.

In the current stable release of Emacs (24.3), you can use dired-do-shell-command on . and ..

phils
  • 71,335
  • 11
  • 153
  • 198