home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.sources
- Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!eff!world!barryn
- From: barryn@world.std.com (Barry N. Nelson)
- Subject: visit the file at point pickf.el
- Message-ID: <BARRYN.92Nov12110458@world.std.com>
- Sender: barryn@world.std.com (barry n nelson)
- Organization: The World
- Distribution: gnu
- Date: Thu, 12 Nov 1992 16:04:58 GMT
- Lines: 68
-
- I am not a good lisp programmer. I hope someone will take my ideas,
- rewrite the code and incorporate them into the next releases of
- appropriate packages. We use this function whenever we edit C files,
- and we want to jump quickly to one of its include files.
-
- ;; ============================================
- ;; pickf.el - visit the file pointed by the mouse.
- ;;
- ;; Author: Jamie Tan, General Signal Corp./Drytek
- ;; <barryn@world.std.com>
- ;;
- ;; USAGE:
- ;; Visit a file by placing the mouse at the filename in any
- ;; buffer and double clicking the middle button or pressing C-c C-f.
- ;;
- ;; You have to set your own search path in the variable 'pickf-path'
- ;; If you don't have the imouse package. Remove the first line and the
- ;; last line. You can still use the key bindings.
-
- (require 'imouse)
-
- (defvar pickf-path
- "pick-file search path")
-
- (setq pickf-path '("./" "../" "../../" "/drytek/vw/h/"))
-
- (defun pick-file-default ()
- "returns the base file name of the picked file"
- (save-excursion
- (while (looking-at "[0-9A-Za-z_/\.\-]")
- (forward-char 1))
- (setq endpoint (point))
- (if (re-search-backward "[^0-9A-Za-z_/\.\-]" nil t)
- (progn (forward-char 1)
- (buffer-substring (point) endpoint)))))
-
- (defun pick-file ()
- "visit the file pointed by the mouse."
- (interactive)
- (setq base-name (pick-file-default))
- (setq path pickf-path)
- (setq found-file nil)
- (while path
- (setq fname (concat (car path) base-name))
- (if (file-attributes (expand-file-name fname))
- (progn
- (setq path nil)
- (setq found-file t))
- (setq path (cdr path))))
- (if found-file
- (find-file (expand-file-name (expand-file-name fname)))
- (message (concat base-name " not found"))))
-
- (global-set-key "\C-c\C-f" 'pick-file)
-
- (defun extend-mouse-drag-or-pickf (mdata)
- "Set point at mouse. With double-click, call pick-file,
- with one click call extend-mouse-drag."
- (case mouse::clicks
- (1 (extend-mouse-drag mdata))
- (2 (pick-file))))
-
- (global-set-mouse mouse-modify mouse-down 'extend-mouse-drag-or-pickf)
- --
- Barry N. Nelson --------- __o __o __o __o
- barryn@world.std.com ------- _`\<,_ _`\<,_ _`\<,_ _`\<,_
- Drytek (508) 657-3933 X4317 ------ (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*)
- A Unit of General Signal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-