unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01  6:57 bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc) Jambunathan K
@ 2002-01-01  0:28 ` Jambunathan K
  2013-04-01  7:42 ` Leo Liu
  2013-04-04  1:08 ` Stefan Monnier
  2 siblings, 0 replies; 18+ messages in thread
From: Jambunathan K @ 2002-01-01  0:28 UTC (permalink / raw)
  To: 14110-done


OP here.  I have a local fix that works for me.  Closing it.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
@ 2013-04-01  6:57 Jambunathan K
  2002-01-01  0:28 ` Jambunathan K
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Jambunathan K @ 2013-04-01  6:57 UTC (permalink / raw)
  To: 14110

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]


Add support for opening files outside of Emacs (use xdg-open, open etc).
This is something that I sorely missed or continue to miss.

Here is an (initial) patch...


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: open-file.diff --]
[-- Type: text/x-diff, Size: 4532 bytes --]

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2013-03-31 15:19:19 +0000
+++ lisp/ChangeLog	2013-04-01 06:50:35 +0000
@@ -1,3 +1,13 @@
+2013-04-01  Jambunathan K  <kjambunathan@gmail.com>
+
+	* files.el (open-file-command): New user option.
+	(open-file): New command.
+	(ctl-x-map): Bind it to `C-S-f'.
+
+	* dired-aux.el (dired-do-open): New command
+
+	* dired.el (dired-mode-map): Bind it to `C-S-f'.
+
 2013-03-31  Roland Winkler  <winkler@gnu.org>
 
 	* emacs-lisp/crm.el (completing-read-multiple): Doc fix.

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2013-02-28 21:51:11 +0000
+++ lisp/dired-aux.el	2013-04-01 05:44:57 +0000
@@ -426,6 +426,18 @@ Uses the shell command coming from varia
 		   'print arg file-list)))
     (dired-run-shell-command (dired-shell-stuff-it command file-list nil))))
 
+;;;###autoload
+(defun dired-do-open (&optional arg)
+  "Open the marked (or next ARG) files (presumably) outside of Emacs.
+Use shell command coming from variable `open-file-command' to
+open the file."
+  (interactive "P")
+  (let* ((file-list (dired-get-marked-files t arg))
+	 (command (dired-mark-read-string "Open %s with: " 
+					  (eval (cadr (assq system-type open-file-command)))
+					  t arg file-list)))
+    (dired-run-shell-command (dired-shell-stuff-it command file-list t))))
+
 (defun dired-mark-read-string (prompt initial op-symbol arg files
 			       &optional default-value collection)
   "Read args for a Dired marked-files command, prompting with PROMPT.

=== modified file 'lisp/dired.el'
--- lisp/dired.el	2013-02-28 21:51:11 +0000
+++ lisp/dired.el	2013-04-01 06:52:10 +0000
@@ -1426,6 +1426,7 @@ Do so according to the former subdir ali
     (define-key map "C" 'dired-do-copy)
     (define-key map "B" 'dired-do-byte-compile)
     (define-key map "D" 'dired-do-delete)
+    (define-key map [33554438] 'dired-do-open) ; C-S-f
     (define-key map "G" 'dired-do-chgrp)
     (define-key map "H" 'dired-do-hardlink)
     (define-key map "L" 'dired-do-load)
@@ -3958,6 +3959,13 @@ Uses the shell command coming from varia
 
 \(fn &optional ARG)" t nil)
 
+(autoload 'dired-do-open "dired-aux" "\
+Open the marked (or next ARG) files (presumably) outside of Emacs.
+Use shell command coming from variable `open-file-command' to
+open the file.
+
+\(fn &optional ARG)" t nil)
+
 (autoload 'dired-clean-directory "dired-aux" "\
 Flag numerical backups for deletion.
 Spares `dired-kept-versions' latest versions, and `kept-old-versions' oldest.

=== modified file 'lisp/files.el'
--- lisp/files.el	2013-03-24 06:42:25 +0000
+++ lisp/files.el	2013-04-01 06:05:45 +0000
@@ -6805,6 +6805,54 @@ Otherwise, trash FILENAME using the free
 		   (rename-file fn new-fn)))))))))
 
 \f
+;; Open files outside of Emacs
+(defcustom open-file-command '((gnu "xdg-open *")
+			       (gnu/linux "xdg-open *")
+			       (gnu/kfreebsd "xdg-open *")
+			       (darwin "open *")
+			       (windows-nt "open *")
+			       (cygwin "open *")
+			       (ms-dos nil))
+  "Shell commands for opening files generically.
+
+Each element of this list looks like
+
+    (SYSTEM-TYPE COMMAND...)
+
+SYSTEM-TYPE is one of `system-type's.
+
+COMMAND can either be a string or a Lisp expression that
+evaluates to a string.  It follows the same semantics as the
+COMMAND param of `dired-do-shell-command'."
+	    :type '(alist :key-type symbol :value-type (group sexp)
+			  :options ((gnu "xdg-open &")
+				    (gnu/linux "xdg-open &")
+				    (gnu/kfreebsd "xdg-open &")
+				    (darwin "open &")
+				    (windows-nt "open &")
+				    (cygwin "open &")
+				    (ms-dos nil)))
+	    :version "24.4"
+	    :group 'file)
+
+(eval-when-compile
+  (require 'dired-aux))
+
+(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)))))
+
+\f
+(define-key ctl-x-map [33554438] 'open-file) ; C-x C-S-f
 (define-key ctl-x-map "\C-f" 'find-file)
 (define-key ctl-x-map "\C-r" 'find-file-read-only)
 (define-key ctl-x-map "\C-v" 'find-alternate-file)


[-- Attachment #3: Type: text/plain, Size: 375 bytes --]


In GNU Emacs 24.3.50.7 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-04-01 on debian-6.05
Bzr revision: 112204 jay.p.belanger@gmail.com-20130331202740-d1t6qedxr13vmnzc
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
Important settings:
  value of $LANG: en_IN
  locale-coding-system: iso-latin-1-unix
  default enable-multibyte-characters: t


^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01  6:57 bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc) Jambunathan K
  2002-01-01  0:28 ` Jambunathan K
@ 2013-04-01  7:42 ` Leo Liu
  2013-04-01  8:06   ` Jambunathan K
  2013-04-04  1:08 ` Stefan Monnier
  2 siblings, 1 reply; 18+ messages in thread
From: Leo Liu @ 2013-04-01  7:42 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

On 2013-04-01 14:57 +0800, Jambunathan K wrote:
> Add support for opening files outside of Emacs (use xdg-open, open etc).
> This is something that I sorely missed or continue to miss.

See dired-x

Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01  7:42 ` Leo Liu
@ 2013-04-01  8:06   ` Jambunathan K
  2013-04-01 13:31     ` Leo Liu
  0 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2013-04-01  8:06 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14110

Leo Liu <sdl.web@gmail.com> writes:

> On 2013-04-01 14:57 +0800, Jambunathan K wrote:
>> Add support for opening files outside of Emacs (use xdg-open, open etc).
>> This is something that I sorely missed or continue to miss.
>
> See dired-x

Be specific.  Where exactly?

> Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01  8:06   ` Jambunathan K
@ 2013-04-01 13:31     ` Leo Liu
  2013-04-01 20:23       ` Jambunathan K
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Liu @ 2013-04-01 13:31 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

On 2013-04-01 16:06 +0800, Jambunathan K wrote:
> Be specific.  Where exactly?

You can start with dired-guess-shell-alist-user

Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01 13:31     ` Leo Liu
@ 2013-04-01 20:23       ` Jambunathan K
  0 siblings, 0 replies; 18+ messages in thread
From: Jambunathan K @ 2013-04-01 20:23 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14110

Leo Liu <sdl.web@gmail.com> writes:

> On 2013-04-01 16:06 +0800, Jambunathan K wrote:
>> Be specific.  Where exactly?
>
> You can start with dired-guess-shell-alist-user

Ok, That is a variable not a command.  My patch introduces two (useful)
commands.  

I suggest that you start with looking at my patch.

> Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-01  6:57 bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc) Jambunathan K
  2002-01-01  0:28 ` Jambunathan K
  2013-04-01  7:42 ` Leo Liu
@ 2013-04-04  1:08 ` Stefan Monnier
  2013-04-04  3:25   ` Jambunathan K
  2 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2013-04-04  1:08 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

> 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.


        Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04  1:08 ` Stefan Monnier
@ 2013-04-04  3:25   ` Jambunathan K
  2013-04-04 12:22     ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2013-04-04  3:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14110

Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04  3:25   ` Jambunathan K
@ 2013-04-04 12:22     ` Stefan Monnier
  2013-04-04 14:34       ` Jambunathan K
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2013-04-04 12:22 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

> (Hint: The COMMAND is a sexp.  It can theoretically be a `cond'
> or a `case' statement.)

If you want such customizability, then please use a function:
funcall/apply is great, but eval is evil.


        Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 12:22     ` Stefan Monnier
@ 2013-04-04 14:34       ` Jambunathan K
  2013-04-04 16:24         ` Stefan Monnier
  2013-04-05  6:53         ` Leo Liu
  0 siblings, 2 replies; 18+ messages in thread
From: Jambunathan K @ 2013-04-04 14:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14110

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> (Hint: The COMMAND is a sexp.  It can theoretically be a `cond'
>> or a `case' statement.)
>
> If you want such customizability, then please use a function:
> funcall/apply is great, but eval is evil.

(It will be improper for me to provide a patch.)

Leo suggests `dired-guess-shell-alist-user'.  COMMAND there is a sexp,
btw. So the above variable is also evil.

There is one another reason why `dired-guess-shell-alist-user' will be
improper to be used for Open semantics.  IIRC, running a shell command
.tex file compiles it.  So equating shell command with open is
confusing, btw.

,----[ C-h v dired-guess-shell-alist-user RET ]
| dired-guess-shell-alist-user is a variable defined in `dired-x.el'.
| Its value is nil
| 
| Documentation:
| User-defined alist of rules for suggested commands.
| These rules take precedence over the predefined rules in the variable
| `dired-guess-shell-alist-default' (to which they are prepended).
| 
| Each element of this list looks like
| 
|     (REGEXP COMMAND...)
| 
| where each COMMAND can either be a string or a Lisp expression that evaluates
| to a string.  If several COMMANDs are given, the first one will be the default
| and the rest will be added temporarily to the history and can be retrieved
| with M-x previous-history-element (M-p) .
| 
| The variable `dired-guess-shell-case-fold-search' controls whether
| REGEXP is matched case-sensitively.
| 
| You can set this variable in your ~/.emacs.  For example, to add rules for
| `.foo' and `.bar' files, write
| 
|  (setq dired-guess-shell-alist-user
|         '(("\\.foo\\'" "FOO-COMMAND")
|           ("\\.bar\\'"
|            (if condition
|               "BAR-COMMAND-1"
|             "BAR-COMMAND-2"))))
| 
| You can customize this variable.
| 
| [back]
`----


>         Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 14:34       ` Jambunathan K
@ 2013-04-04 16:24         ` Stefan Monnier
  2013-04-04 17:52           ` Jambunathan K
  2013-04-05  6:53         ` Leo Liu
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2013-04-04 16:24 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

> Leo suggests `dired-guess-shell-alist-user'.  COMMAND there is a sexp,
> btw. So the above variable is also evil.

Yes.  I also plead guilty of doing that a few times in the past.
It's still evil.

> There is one another reason why `dired-guess-shell-alist-user' will be
> improper to be used for Open semantics.  IIRC, running a shell command
> .tex file compiles it.  So equating shell command with open is
> confusing, btw.

I tend to agree, but:
- I can't think of anything useful "open" could do with a .tex file
  other than pass it back to Emacs (which you can already do better by
  opening the file in Emacs without going through "open").
  While this might not apply to all cases, I suspect that most cases are
  like that.
- That doesn't preclude using dired-guess-shell.  It might just mean
  that we should have maybe an alist for "run command" and another alist
  for "open command" (and maybe a third alist to share the many common
  cases between the two).


        Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 16:24         ` Stefan Monnier
@ 2013-04-04 17:52           ` Jambunathan K
  2013-04-04 18:20             ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2013-04-04 17:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14110

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Leo suggests `dired-guess-shell-alist-user'.  COMMAND there is a sexp,
>> btw. So the above variable is also evil.
>
> Yes.  I also plead guilty of doing that a few times in the past.
> It's still evil.
>
>> There is one another reason why `dired-guess-shell-alist-user' will be
>> improper to be used for Open semantics.  IIRC, running a shell command
>> .tex file compiles it.  So equating shell command with open is
>> confusing, btw.
>
> I tend to agree, but:
> - I can't think of anything useful "open" could do with a .tex file
>   other than pass it back to Emacs (which you can already do better by
>   opening the file in Emacs without going through "open").
>   While this might not apply to all cases, I suspect that most cases are
>   like that.

`open-file' command (as I see it) will do what a "double click" in
Windows Explorer or Thunar will do.  Note that each popular
`system-type' already has a open command.

In Windows + MikTex, double-clicking on a .tex will open a specialized
viewer (IIRC, it is called yap).  

More importantly, `open-file' on a directory will launch Windows
explorer or Thunar or Nautilus.

> - That doesn't preclude using dired-guess-shell.  It might just mean
>   that we should have maybe an alist for "run command" and another alist
>   for "open command" (and maybe a third alist to share the many common
>   cases between the two).

Big NO for having an alist (within Emacs) for the open command.

The alist is already maintained by the user's desktop (likely via
Explore->`Open with' -> `Always use this application for these files').
Emacs should at no point in time have any knowledge of this association.

To accommodate other systems which are non-desktopy (DOS?), we can
enhance the shell-command history var to be a (cons FILE-EXTENSION
VIEWER).  This will be an exception rather than the norm.

>         Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 17:52           ` Jambunathan K
@ 2013-04-04 18:20             ` Eli Zaretskii
  2013-04-05  4:58               ` Jambunathan K
  2013-04-05  6:03               ` Thierry Volpiatto
  0 siblings, 2 replies; 18+ messages in thread
From: Eli Zaretskii @ 2013-04-04 18:20 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

> From: Jambunathan K <kjambunathan@gmail.com>
> Date: Thu, 04 Apr 2013 23:22:37 +0530
> Cc: 14110@debbugs.gnu.org
> 
> The alist is already maintained by the user's desktop (likely via
> Explore->`Open with' -> `Always use this application for these files').
> Emacs should at no point in time have any knowledge of this association.

Emacs can easily know about the associations, at least on Windows.

> To accommodate other systems which are non-desktopy (DOS?), we can
> enhance the shell-command history var to be a (cons FILE-EXTENSION
> VIEWER).  This will be an exception rather than the norm.

That's meaningless on DOS, which is a single-process system.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 18:20             ` Eli Zaretskii
@ 2013-04-05  4:58               ` Jambunathan K
  2013-04-05  6:03               ` Thierry Volpiatto
  1 sibling, 0 replies; 18+ messages in thread
From: Jambunathan K @ 2013-04-05  4:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14110

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Jambunathan K <kjambunathan@gmail.com>
>> Date: Thu, 04 Apr 2013 23:22:37 +0530
>> Cc: 14110@debbugs.gnu.org
>> 
>> The alist is already maintained by the user's desktop (likely via
>> Explore->`Open with' -> `Always use this application for these files').
>> Emacs should at no point in time have any knowledge of this association.
>
> Emacs can easily know about the associations, at least on Windows.

On my Debian/Squeeze, this is what I have ended up with.

,----
| $ xdg-mime query filetype images/vanilla-emacs.png 
| image/png; charset=binary
`----

,----
| $ xdg-mime query default image/png
| gimp.desktop
`----

,----
| $ dpkg -L gimp | grep desktop
| /usr/lib/gimp/2.0/plug-ins/file-desktop-link
| /usr/share/applications/gimp.desktop
`----

,----
| $ cat /usr/share/applications/gimp.desktop | grep Exec
| Exec=gimp-2.6 %U
| TryExec=gimp-2.6
`----

,----
| $ gimp-
| gimp-2.6          gimp-console      gimp-console-2.6 
`----

There should be a way to go directly from *.desktop file to Exec entry.
I haven't figured it out or it is in the works.

Surprisingly, the above sequence fails for ODT files.

,----
| $ xdg-mime query filetype book.odt
| application/vnd.oasis.opendocument.text; charset=binary
`----

,----
| $ xdg-mime query default application/vnd.oasis.opendocument.text
| <NOTHING WHATSOEVER>
`----

I believe xdg-stuff is in it's initial stages and not so reliable at
this moment.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 18:20             ` Eli Zaretskii
  2013-04-05  4:58               ` Jambunathan K
@ 2013-04-05  6:03               ` Thierry Volpiatto
  2013-04-10  4:30                 ` Jambunathan K
  1 sibling, 1 reply; 18+ messages in thread
From: Thierry Volpiatto @ 2013-04-05  6:03 UTC (permalink / raw)
  To: 14110

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Jambunathan K <kjambunathan@gmail.com>
>> Date: Thu, 04 Apr 2013 23:22:37 +0530
>> Cc: 14110@debbugs.gnu.org
>> 
>> The alist is already maintained by the user's desktop (likely via
>> Explore->`Open with' -> `Always use this application for these files').
>> Emacs should at no point in time have any knowledge of this association.
>
> Emacs can easily know about the associations, at least on Windows.

Here what I do in helm:

Default action to open a file is always edit the file in emacs with the
right mode.

Use another command to open file externally (async).
This command can use a prefix to choose program to use (with
completion).
Once you choose this program your choice is stored in an alist with
customize. (So no need for user to customize complex alist)
Each time you want to change, you can press C-u to make another choice.
If you answer yes, this new program will replace the precedent in alist,
no will use the new program without storing it.
If you don't press C-u the last program used for this kind of file is
used.
If the command is called with no choice (not C-u) and nothing for this
file extension is found in alist helm looks for mailcap entries.

It is good to be able to change program at any time, e.g for foo.jpg,
you may use sometimes imagemagick, ristretto, or gimp etc....

I also have a command that use default tool with no choice (xdg-open)
but I don't like it.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-04 14:34       ` Jambunathan K
  2013-04-04 16:24         ` Stefan Monnier
@ 2013-04-05  6:53         ` Leo Liu
  1 sibling, 0 replies; 18+ messages in thread
From: Leo Liu @ 2013-04-05  6:53 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

On 2013-04-04 22:34 +0800, Jambunathan K wrote:
> Leo suggests `dired-guess-shell-alist-user'.  COMMAND there is a sexp,
> btw. So the above variable is also evil.

dired-x provides a general way for doing these sorts of things including
those you try to achieve in your patches. I merely point you to the
entry. It has a few glitches such as using eval and maybe others but
nothing major.

Leo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-05  6:03               ` Thierry Volpiatto
@ 2013-04-10  4:30                 ` Jambunathan K
  2013-04-10  5:39                   ` Thierry Volpiatto
  0 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2013-04-10  4:30 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 14110



> I also have a command that use default tool with no choice (xdg-open)
> but I don't like it.

What are the problems with `xdg-open'?





^ permalink raw reply	[flat|nested] 18+ messages in thread

* bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc)
  2013-04-10  4:30                 ` Jambunathan K
@ 2013-04-10  5:39                   ` Thierry Volpiatto
  0 siblings, 0 replies; 18+ messages in thread
From: Thierry Volpiatto @ 2013-04-10  5:39 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 14110

Jambunathan K <kjambunathan@gmail.com> writes:

>> I also have a command that use default tool with no choice (xdg-open)
>> but I don't like it.
>
> What are the problems with `xdg-open'?

Less flexibility, no choice.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-04-10  5:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01  6:57 bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc) Jambunathan K
2002-01-01  0:28 ` Jambunathan K
2013-04-01  7:42 ` Leo Liu
2013-04-01  8:06   ` Jambunathan K
2013-04-01 13:31     ` Leo Liu
2013-04-01 20:23       ` Jambunathan K
2013-04-04  1:08 ` Stefan Monnier
2013-04-04  3:25   ` Jambunathan K
2013-04-04 12:22     ` Stefan Monnier
2013-04-04 14:34       ` Jambunathan K
2013-04-04 16:24         ` Stefan Monnier
2013-04-04 17:52           ` Jambunathan K
2013-04-04 18:20             ` Eli Zaretskii
2013-04-05  4:58               ` Jambunathan K
2013-04-05  6:03               ` Thierry Volpiatto
2013-04-10  4:30                 ` Jambunathan K
2013-04-10  5:39                   ` Thierry Volpiatto
2013-04-05  6:53         ` Leo Liu

Code repositories for project(s) associated with this public inbox

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

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).