[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dired changes

From: Juri Linkov
Subject: Re: Dired changes
Date: Wed, 31 Mar 2004 23:59:38 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Dave Love <address@hidden> writes in dired.el:
> +;; Fixme: This should use mailcap.
>  (defcustom dired-view-command-alist
>    '(("[.]\\(ps\\|ps_pages\\|eps\\)\\'" . "gv -spartan -color -watch %s")
>      ("[.]pdf\\'" . "xpdf %s")

I had this feature for a long time in .emacs, and it's really a useful thing.
It could be added to dired.el, but I'm not sure where to add it.
One possibility is to add directly to the `dired-view-file' like:

diff -u -r1.280 dired.el
--- emacs/lisp/dired.el 31 Mar 2004 16:29:46 -0000      1.280
+++ emacs/lisp/dired.el 31 Mar 2004 19:34:25 -0000
@@ -1489,11 +1489,22 @@
        (dolist (elt dired-view-command-alist)
          (if (string-match (car elt) file)
              (setq cmd (cdr elt))))
+        (unless cmd
+          (require 'mailcap)
+          (require 'mm-decode)
+          (mailcap-parse-mailcaps)
+          (let* ((ext (file-name-extension file))
+                 (mime (and ext (mailcap-extension-to-mime ext)))
+                 (info (and mime (mailcap-mime-info mime))))
+            (if (stringp info)
+                (setq cmd (mm-mailcap-command info file (list mime))))))
        (if cmd
            (call-process shell-file-name nil 0 nil

But it may be undesirable to call external programs for some system-wide
defined extensions.

Perhaps it's better to make a separate command `dired-view-file-externally'
and to bind it, for example, to V.

Or to add this code to the `dired-guess-shell-command' from dired-x.el.

Juri Linkov

reply via email to

[Prev in Thread] Current Thread [Next in Thread]