GNU bug report logs -
#18132
Time for a smarter dired-guess-shell-alist-default? (dired-x.el)
Previous Next
Reported by: Reuben Thomas <rrt <at> sc3d.org>
Date: Mon, 28 Jul 2014 18:27:01 UTC
Severity: wishlist
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Such a command emulates what double clicking on an icon does
> which most of the time is what a user wants (because it's
> configured it do what their most common app need is).
Such a command is long overdue. I used the following command
for a long time, and forgot it's not in dired-x. I don't suggest
to use this implementation, but something like this. Then like
clicking the right mouse button on a file shows a list of
available apps to open the file in, and M-& does practically the same
with the keyboard. Then like double clicking on an icon,
some key should use the default command to open the file.
#+begin_src emacs-lisp
(define-key dired-mode-map [(control return)] 'my-dired-run-find-file)
(defun my-dired-run-find-file ()
"View file for dired."
(interactive)
(let* ((file (dired-get-filename)))
(cond
((let* ((command
(and (functionp 'mm-mime-info)
(mm-mime-info
(mm-extension-to-mime (file-name-extension file))))))
(if (and command (stringp command))
;; always return ‘t’ for ‘cond’
(or (ignore (async-shell-command (concat (format command file) "&")))
t))))
((string-match "\\.html?$" file)
(cond
((fboundp 'browse-url)
(browse-url file))))
((string-match "\\.elc?$" file)
(load-file file))
((string-match "\\.info?$" file)
(info file))
((let* ((file-list (list (dired-get-filename)))
(command (dired-guess-default file-list))
(async-shell-command-display-buffer nil))
(if (listp command)
(setq command (car command)))
(if command
(async-shell-command
(dired-shell-stuff-it command file-list nil 0)))))
(t
(message "%s" file)))))
#+end_src
This bug report was last modified 363 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.