home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / help-lucid-emacs / text0312.txt < prev    next >
Encoding:
Text File  |  1993-07-14  |  1.6 KB  |  54 lines

  1.  
  2.  
  3. I presume that you want to be able to find a file by clicking a mouse
  4. button on a line in a dired buffer. Here's how I do it.
  5.  
  6.   ;;
  7.   ;; Make middle button find file on that line in dired
  8.   ;; (this makes dired mode more like buffer edit mode)
  9.   ;;
  10.   (defun dired-track-mouse-and-find-file (event)
  11.     (interactive "e")
  12.     (let (filname)
  13.       (save-excursion
  14.     (mouse-track event)
  15.     (setq filename (dired-get-filename)))
  16.       (if (file-directory-p filename)
  17.       (kill-buffer (current-buffer)))
  18.       (find-file filename)))
  19.   (defun my-dired-mode-setup nil
  20.     (setq mode-motion-hook 'mode-motion-highlight-line)
  21.     (local-set-key 'button2 'dired-track-mouse-and-find-file))
  22.   (setq dired-mode-hook 'my-dired-mode-setup)
  23.  
  24. Note that if you click on a directory the current dired buffer is killed. I
  25. find that this helps stop proliferation of dired buffer when I'm looking over
  26. directory trees. If you don't want this then omit the two lines
  27.  
  28.       (if (file-directory-p filename)
  29.       (kill-buffer (current-buffer)))
  30.  
  31. It's useful to do the same in tar mode as well. The details differ slightly -
  32. try 
  33.   ;;
  34.   ;; ditto for tar-mode
  35.   ;;
  36.   (defun tar-track-mouse-and-extract-file (event)
  37.     (interactive "e")
  38.     (let (buffer)
  39.       (save-excursion
  40.     (mouse-track event)
  41.     (tar-extract)
  42.     (setq buffer (current-buffer)))
  43.       (switch-to-buffer buffer)))
  44.   (defun my-tar-mode-setup nil
  45.     (setq mode-motion-hook 'mode-motion-highlight-line)
  46.     (local-set-key 'button2 'tar-track-mouse-and-extract-file))
  47.   (setq tar-mode-hook 'my-tar-mode-setup)
  48.  
  49. --
  50. Paul Flinders            Mail: ptf@delcam.co.uk
  51. Delcam International PLC.    Tel:  +44 21 766 5544    Fax: +44 21 766 5511
  52.  
  53.  
  54.