GNU bug report logs -
#14110
24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
Previous Next
Reported by: Jambunathan K <kjambunathan <at> gmail.com>
Date: Mon, 1 Apr 2013 07:02:02 UTC
Severity: wishlist
Found in version 24.3.50
Done: Jambunathan K <kjambunathan <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 14110 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> Add support for opening files outside of Emacs (use xdg-open, open etc).
>> This is something that I sorely missed or continue to miss.
>
> For those people who find xdg-open not customizable enough, I think
> open-file deserves an alist associating different commands to different
> file kinds.
> I guess in this sense I agree with Leo, that it should probably use
> dired-guess-shell or something like that.
I have looked at the variable that Leo mentions, prior to preparting the
patch. (Hint: The COMMAND is a sexp. It can theoretically be a `cond'
or a `case' statement.) I want the new customization to be simple and
not over-engineered and in a way that is welcoming of the new user while
giving power to the more experienced.
To allow for a possibility that a generic open command may not be
available, I have arranged for a `read-shell-command' and remembering
the command name so entered in `dired-shell-command-history'.
Furthermore, the open command need not be xdg-open, it could be
gnome-open or kde-open. (If you look xdg-open you will see that it
internally checks for desktop open and calls the native open method.)
(defun open-file (filename)
"Open FILENAME (presumably) outside of Emacs.
Use shell command from `open-file-command' to open the file."
(interactive "fOpen file:")
(require 'dired-aux)
(let* ((default-directory (file-name-directory filename))
(filename (file-name-nondirectory filename))
| (command (or (eval (cadr (assq system-type open-file-command)))
| (read-shell-command (format "Open %s with: " filename) nil
| 'dired-shell-command-history))))
(when (and command (string-match "\\S-" command))
(dired-run-shell-command (dired-shell-stuff-it command (list filename) t)))))
> Stefan
This bug report was last modified 11 years and 249 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.