diff options
| author | Richard M. Stallman | 2002-04-10 15:15:23 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-04-10 15:15:23 +0000 |
| commit | b70ebe3751ea73ee1dbc1c65f89776e4668dc57b (patch) | |
| tree | 1fc04b193384c18a7f5a7ab768290d408b48e2aa | |
| parent | 2d246c716210704f126c26c711d2b338d78d345d (diff) | |
| download | emacs-b70ebe3751ea73ee1dbc1c65f89776e4668dc57b.tar.gz emacs-b70ebe3751ea73ee1dbc1c65f89776e4668dc57b.zip | |
(dired-view-command-alist): New variable.
(dired-view-file): Use external viewers for some files names.
| -rw-r--r-- | lisp/dired.el | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 75cc631c0a4..8bf10e0cef8 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -1373,17 +1373,38 @@ Creates a buffer if necessary." | |||
| 1373 | (select-window (posn-window (event-end event))) | 1373 | (select-window (posn-window (event-end event))) |
| 1374 | (find-file-other-window (file-name-sans-versions file t)))) | 1374 | (find-file-other-window (file-name-sans-versions file t)))) |
| 1375 | 1375 | ||
| 1376 | (defcustom dired-view-command-alist | ||
| 1377 | '(("[.]ps\\'" . "gv -spartan -color -watch") | ||
| 1378 | ("[.]pdf\\'" . "xpdf") | ||
| 1379 | ("[.]dvi\\'" . "xdvi -sidemargin 0.5 -topmargin 1")) | ||
| 1380 | "Alist specifying how to view special types of files. | ||
| 1381 | Each element has the form (REGEXP . SHELL-COMMAND). | ||
| 1382 | When the file name matches REGEXP, `dired-view-file' | ||
| 1383 | invokes SHELL-COMMAND to view the file, putting the file name | ||
| 1384 | at the end of the command." | ||
| 1385 | :group 'dired | ||
| 1386 | :type '(alist :key-type regexp :value-type string) | ||
| 1387 | :version 21.4) | ||
| 1388 | |||
| 1376 | (defun dired-view-file () | 1389 | (defun dired-view-file () |
| 1377 | "In Dired, examine a file in view mode, returning to dired when done. | 1390 | "In Dired, examine a file in view mode, returning to dired when done. |
| 1378 | When file is a directory, show it in this buffer if it is inserted; | 1391 | When file is a directory, show it in this buffer if it is inserted. |
| 1379 | otherwise, display it in another buffer." | 1392 | Some kinds of files are displayed using external viewer programs; |
| 1393 | see `dired-view-command-alist'. Otherwise, display it in another buffer." | ||
| 1380 | (interactive) | 1394 | (interactive) |
| 1381 | (let ((file (dired-get-file-for-visit))) | 1395 | (let ((file (dired-get-file-for-visit))) |
| 1382 | (if (file-directory-p file) | 1396 | (if (file-directory-p file) |
| 1383 | (or (and (cdr dired-subdir-alist) | 1397 | (or (and (cdr dired-subdir-alist) |
| 1384 | (dired-goto-subdir file)) | 1398 | (dired-goto-subdir file)) |
| 1385 | (dired file)) | 1399 | (dired file)) |
| 1386 | (view-file file)))) | 1400 | (let (cmd) |
| 1401 | ;; Look for some other way to view a certain file. | ||
| 1402 | (dolist (elt dired-view-command-alist) | ||
| 1403 | (if (string-match (car elt) file) | ||
| 1404 | (setq cmd (cdr elt)))) | ||
| 1405 | (if cmd | ||
| 1406 | (dired-run-shell-command (concat cmd " " file)) | ||
| 1407 | (view-file file)))))) | ||
| 1387 | 1408 | ||
| 1388 | (defun dired-find-file-other-window () | 1409 | (defun dired-find-file-other-window () |
| 1389 | "In Dired, visit this file or directory in another window." | 1410 | "In Dired, visit this file or directory in another window." |
| @@ -2983,6 +3004,8 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." | |||
| 2983 | If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is | 3004 | If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is |
| 2984 | true then the type of the file linked to by FILE is printed instead." | 3005 | true then the type of the file linked to by FILE is printed instead." |
| 2985 | t) | 3006 | t) |
| 3007 | |||
| 3008 | (autoload 'dired-run-shell-command "dired-aux") | ||
| 2986 | 3009 | ||
| 2987 | (if (eq system-type 'vax-vms) | 3010 | (if (eq system-type 'vax-vms) |
| 2988 | (load "dired-vms")) | 3011 | (load "dired-vms")) |