home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / MouseAndMenuEmacs / dired-x.el < prev    next >
Encoding:
Text File  |  1990-05-31  |  2.6 KB  |  65 lines

  1. ;;;; A [file of] X mouse function[s] for use in Dired mode [, more later..].
  2. ;;;; Russell Ritchie, Scottish HCI Centre, <russell@uk.ac.strath.hci>.
  3. ;;;; Tue Jul 19 12:01:30 1988 
  4.  
  5. (provide 'dired-x)
  6.  
  7. (defun x-mouse-inspect-file (arg &optional other-window-p)
  8.   "Inspect the file the mouse is pointing at:
  9.        if it ends in \".dvi\", use TeX-screen-print-command to show it
  10.        otherwise do a dired-find-file on it.
  11. If optional second arg OTHER-WINDOW-P is non-nil do it in another window."
  12.   (eval-in-window
  13.     x-mouse-window
  14.     (x-mouse-set-point arg)
  15.     (let ((filename (dired-get-filename)))
  16.       (cond
  17.        ((string-match "\.dvi$" filename) 
  18.     (let* ((preview-program (if (boundp 'TeX-screen-print-command) 
  19.                     TeX-screen-print-command
  20.                   ;; Load TeX-mode to bind TeX-screen-print-command
  21.                   (require 'TeX-mode)
  22.                   TeX-screen-print-command))
  23.            (preview-prog-and-args
  24.         (let ((program-and-args nil)
  25.               (result nil))
  26.           (while (string-match "[ \t\n]" preview-program)
  27.             (setq program-and-args
  28.               (cons 
  29.                (substring preview-program 0 (1- (match-end 0))) program-and-args))
  30.             (setq preview-program (substring preview-program (match-end 0))))
  31.           (setq program-and-args
  32.             (nreverse (if (string= "" preview-program)
  33.                       program-and-args
  34.                     (cons preview-program program-and-args))))
  35.           (if (string= "" (car program-and-args))
  36.               (cdr program-and-args)
  37.             program-and-args)))
  38.            (previewer (car preview-prog-and-args)))
  39.       (if previewer
  40.           (if (file-exists-path-p previewer exec-path)
  41.           ;; TeX-screen-print-command could contain options separated by whitespace,
  42.           ;; check only up to the end of the first 'word' which *should* be
  43.           ;; the program name.
  44.           (apply 
  45.            'start-process
  46.            previewer nil previewer (append (cdr preview-prog-and-args) (list filename)))
  47.         (error
  48.          "%s cannot be found in the current environment. Wrong $PATH?" previewer))
  49.         (if (file-exists-path-p preview-program exec-path)
  50.         (start-process preview-program nil preview-program filename)))))
  51.        (t (if (save-excursion
  52.         (beginning-of-line)
  53.         (looking-at "  d"))    ; If it's a directory use dired on it.
  54.           (if other-window-p
  55.           (dired-other-window filename)
  56.         (dired filename))
  57.         (if other-window-p
  58.         (find-file-other-window filename)
  59.           (find-file filename))))))))
  60.  
  61. (defun x-mouse-inspect-file-other-window (arg)
  62.   "Inspect the file the mouse is pointing at in another window:
  63.        if it ends in \".dvi\", use TeX-screen-print-command to show it
  64.        otherwise do a dired-find-file-other-window on it."
  65.   (x-mouse-inspect-file arg t))