0
|
1 ;;; func-menu.el --- Jump to a function within a buffer.
|
|
2 ;;;
|
151
|
3 ;;; David Hughes <d.hughes@videonetworks.com>
|
82
|
4 ;;; Last modified: David Hughes 13th January 1997
|
|
5 ;;; Version: 2.45
|
0
|
6 ;;; Keywords: tools, c, lisp
|
|
7 ;;;
|
|
8 ;;; This program is free software; you can redistribute it and/or modify
|
|
9 ;;; it under the terms of the GNU General Public License as published by
|
|
10 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;;; any later version.
|
|
12 ;;;
|
|
13 ;;; This program is distributed in the hope that it will be useful,
|
|
14 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 ;;; GNU General Public License for more details.
|
|
17 ;;;
|
|
18 ;;; You should have received a copy of the GNU General Public License
|
|
19 ;;; along with this program; if not, write to the Free Software
|
|
20 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21 ;;;
|
|
22 ;;; Synched up with: Not in FSF.
|
|
23 ;;;
|
|
24 ;;; Installation:
|
|
25 ;;; =============
|
|
26 ;;; (require 'func-menu)
|
|
27 ;;; (define-key global-map 'f8 'function-menu)
|
|
28 ;;; (add-hook 'find-file-hooks 'fume-add-menubar-entry)
|
|
29 ;;; (define-key global-map "\C-cl" 'fume-list-functions)
|
|
30 ;;; (define-key global-map "\C-cg" 'fume-prompt-function-goto)
|
|
31 ;;; (define-key global-map '(shift button3) 'mouse-function-menu)
|
|
32 ;;; (define-key global-map '(meta button1) 'fume-mouse-function-goto)
|
|
33 ;;;
|
|
34 ;;; Description:
|
|
35 ;;; ============
|
|
36 ;;; Suppose you have a file with a lot of functions in it. Well, this package
|
|
37 ;;; makes it easy to jump to any of those functions. The names of the
|
|
38 ;;; functions in the current buffer are automatically put into a popup menu,
|
|
39 ;;; you select one of the function-names and the point is moved to that very
|
|
40 ;;; function. The mark is pushed on the mark-ring, so you can easily go back
|
|
41 ;;; to where you were. Alternatively, you can use enter the name of the
|
|
42 ;;; desired function via the minibuffer which offers completing read input. In
|
|
43 ;;; addition, the name of the function before point is optionally displayed in
|
|
44 ;;; the modeline.
|
|
45 ;;;
|
82
|
46 ;;; Support for non X Window versions of Emacs:
|
|
47 ;;; ===========================================
|
0
|
48 ;;; This package can also be used for non X versions of Emacs. In this case,
|
|
49 ;;; only modeline display and completing read input from the minibuffer are
|
|
50 ;;; possible.
|
|
51 ;;;
|
|
52 ;;; Modes supported:
|
|
53 ;;; ================
|
|
54 ;;; Ada, Assembly, Bacis2, BibTex, C++, C, Dired, Ehdm, ELisp, FORTRAN, Ksh,
|
|
55 ;;; Latex, Lelisp, Makefile, Maple, Modula2, Modula3, Outline, Pascal, Perl,
|
|
56 ;;; Postscript, Prolog, PVS, Python, SGML, Scheme, Tcl, Verilog
|
|
57 ;;;
|
|
58 ;;; Acknowledgements:
|
|
59 ;;; =================
|
|
60 ;;;
|
82
|
61 ;;; Fix to fume-function-name-regexp-c
|
|
62 ;;; Jonathan Edwards <edwards@intranet.com>
|
|
63 ;;;
|
|
64 ;;; Speedup for fume-cc-inside-comment
|
|
65 ;;; Peter Pezaris <pez@dwwc.com>
|
|
66 ;;;
|
|
67 ;;; Made menu placement more flexible
|
151
|
68 ;;; Bob Weiner <weiner@altrasoft.com>
|
82
|
69 ;;;
|
0
|
70 ;;; Fortran90 regexp
|
|
71 ;;; John Turner <turner@xdiv.lanl.gov>
|
|
72 ;;;
|
|
73 ;;; Patch to error trap in fume-rescan-buffer
|
|
74 ;;; Andy Piper <andyp@parallax.co.uk>
|
|
75 ;;;
|
|
76 ;;; Java support
|
151
|
77 ;;; Bob Weiner <weiner@altrasoft.com>
|
0
|
78 ;;; Heddy Boubaker <boubaker@dgac.fr>
|
|
79 ;;;
|
|
80 ;;; Patch for fume-rescan-buffer{-trigger}
|
|
81 ;;; Christoph Wedler <wedler@vivaldi.fmi.uni-passau.de>
|
|
82 ;;;
|
|
83 ;;; Patch for fume-tickle-f-to-b
|
|
84 ;;; Michael Sperber <sperber@informatik.uni-tuebingen.de>
|
|
85 ;;;
|
|
86 ;;; Cleanup suggestions
|
|
87 ;;; Jonathan Stigelman <stig@hackvan.com>
|
|
88 ;;;
|
|
89 ;;; Idea for jumping directly with a mouse click
|
|
90 ;;; Marc Paquette <Marc.Paquette@Softimage.COM>
|
|
91 ;;;
|
|
92 ;;; Prolog mode additions based on functions for Postscript mode
|
|
93 ;;; Laszlo Teleki <laszlo@ipb.uni-bonn.de>
|
|
94 ;;;
|
|
95 ;;; Idea for displaying function name in modeline
|
|
96 ;;; Paul Filipski <filipski@blackhawk.com>
|
|
97 ;;;
|
|
98 ;;; Fame mode support
|
|
99 ;;; Cooper Vertz <cooper@prod2.imsi.com>
|
|
100 ;;;
|
|
101 ;;; Made fume-match-find-next-function-name iterative, not recursive, to avoid
|
|
102 ;;; blowing out the emacs stack on big files with lots of prototypes.
|
|
103 ;;; Joe Marshall <jrm@odi.com>
|
|
104 ;;;
|
|
105 ;;; Verilog support
|
|
106 ;;; Matt Sale <mdsale@icdc.delcoelect.com>
|
|
107 ;;;
|
|
108 ;;; Minibuffer interface & Pascal support
|
|
109 ;;; Espen Skoglund <espensk@stud.cs.uit.no>
|
|
110 ;;;
|
|
111 ;;; Python support
|
|
112 ;;; Shuichi Koga <skoga@virginia.edu>
|
|
113 ;;;
|
|
114 ;;; Maple support
|
|
115 ;;; Luc Tancredi <Luc.Tancredi@sophia.inria.fr>
|
|
116 ;;;
|
|
117 ;;; Combined Tcl and C++ function finder
|
|
118 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
119 ;;;
|
|
120 ;;; Perl Support
|
|
121 ;;; Alex Rezinsky <alexr@msil.sps.mot.com>
|
|
122 ;;; Michael Lamoureux <lamour@engin.umich.edu>
|
|
123 ;;;
|
|
124 ;;; Suggested mouse interface
|
|
125 ;;; Raymond L. Toy <toy@soho.crd.ge.com>
|
|
126 ;;;
|
|
127 ;;; Dired support
|
|
128 ;;; Improved modula support
|
|
129 ;;; Numerous code cleanups
|
|
130 ;;; Norbert Kiesel <norbert@i3.informatik.rwth-aachen.de>
|
|
131 ;;;
|
|
132 ;;; Makefile support
|
|
133 ;;; Suggested multi-choice sublisting
|
|
134 ;;; Paul Filipski & Anthony Girardin <{filipski,girardin}@blackhawk.com>
|
|
135 ;;;
|
|
136 ;;; Suggestions for menubar entry
|
|
137 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
138 ;;;
|
|
139 ;;; Ada support
|
|
140 ;;; Scott Evans <gse@ocsystems.com>
|
|
141 ;;; Michael Polo <mikep@polo.mn.org> <mikep@cfsmo.honeywell.com>
|
|
142 ;;;
|
|
143 ;;; Scheme, BibTeX, Ehdm & PVS support
|
|
144 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
145 ;;;
|
|
146 ;;; Modula support
|
|
147 ;;; Geoffrey Wyant <gwyant@cloyd.east.sun.com>
|
|
148 ;;;
|
|
149 ;;; SGML support; submenu indexing
|
|
150 ;;; Thomas Plass <thomas.plass@mid-heidelberg.de>
|
|
151 ;;;
|
|
152 ;;; Extensions to fume-function-name-regexp-lisp
|
82
|
153 ;;; Vladimir Alexiev <vladimir@cs.ualberta.ca>
|
0
|
154 ;;; Kari Heinola <kph@dpe.fi>
|
|
155 ;;; Milo A. Chan <chan@jpmorgan.com>
|
|
156 ;;; Jack Repenning <jackr@step7.informix.com>
|
|
157 ;;; Cedric Beust <Cedric.Beust@sophia.inria.fr>
|
|
158 ;;; Joachim Krumnow <krumnow@srsir02.ext.sap-ag.de>
|
|
159 ;;;
|
|
160 ;;; ksh support
|
|
161 ;;; Philippe Bondono <bondono@vnet.ibm.com>
|
|
162 ;;;
|
|
163 ;;; FORTRAN support
|
|
164 ;;; Paul Emsley <paule@chem.gla.ac.uk>
|
|
165 ;;; Raymond L. Toy <toy@soho.crd.ge.com>
|
|
166 ;;; Richard Cognot <cognot@elfgrc.co.uk>
|
|
167 ;;; Greg Sjaardema <gdsjaar@sandia.gov>
|
|
168 ;;;
|
|
169 ;;; Latex support
|
|
170 ;;; Wolfgang Mettbach <wolle@uni-paderborn.de>
|
|
171 ;;; Paolo Frasconi <paolo@mcculloch.ing.unifi.it>
|
|
172 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
173 ;;; Philippe Queinnec <queinnec@cenatls.cena.dgac.fr>
|
|
174 ;;;
|
|
175 ;;; Assembly support
|
151
|
176 ;;; Bob Weiner <weiner@altrasoft.com>
|
0
|
177 ;;;
|
|
178 ;;; Removal of cl dependencies
|
|
179 ;;; Russell Ritchie <russell@gssec.bt.co.uk>
|
|
180 ;;;
|
|
181 ;;; C++ mode enhancemencements for func-menu
|
|
182 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
183 ;;; Kevin R. Powell <powell@csl.ncsa.uiuc.edu>
|
|
184 ;;; Mats Lidell <mats.lidell@eua.ericsson.se>
|
|
185 ;;; Mike Battaglia <mbattagl@spd.dsccc.com>
|
|
186 ;;; Oliver Schittko <schittko@fokus.gmd.de>
|
|
187 ;;; Tom Murray <tmurray@hpindck.cup.hp.com>
|
|
188 ;;; Russell Ritchie <russell@gssec.bt.co.uk>
|
|
189 ;;;
|
|
190 ;;; Tcl mode additions for func-menu
|
|
191 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
192 ;;; Jean-Michel Augusto <augusto@eurecom.fr>
|
|
193 ;;; Dr P.G. Sjoerdsma <pgs1002@esc.cam.ac.uk>
|
|
194 ;;;
|
|
195 ;;; Postscript mode additions for func-menu
|
|
196 ;;; Leigh Klotz <klotz@adoc.xerox.com>
|
|
197 ;;;
|
|
198 ;;; Suggestions for popup menu positioning
|
|
199 ;;; Marc Gemis <makke@wins.uia.ac.be>
|
|
200 ;;;
|
|
201 ;;; Original FSF package
|
|
202 ;;; Ake Stenhoff <etxaksf@aom.ericsson.se>
|
|
203
|
|
204 ;;; Code
|
|
205
|
|
206 (eval-when-compile
|
|
207 (byte-compiler-options
|
|
208 (optimize t)
|
|
209 (new-bytecodes t)
|
|
210 (warnings (- free-vars unresolved))))
|
|
211
|
|
212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
213 ;;;;;;;;;;;;;;;;;;;;;;;; Environment Initialisation ;;;;;;;;;;;;;;;;;;;;;;
|
|
214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
215
|
82
|
216 (defconst fume-version "2.45")
|
0
|
217
|
134
|
218 (defgroup fume nil
|
|
219 "Jump to a function within a buffer."
|
|
220 :tag "Func Menu"
|
|
221 :group 'tools)
|
|
222
|
151
|
223 (defconst fume-developer "David Hughes <d.hughes@videonetworks.com>")
|
0
|
224
|
|
225 (defun fume-about ()
|
|
226 (interactive)
|
|
227 (sit-for 0)
|
82
|
228 (message "Func-Menu version %s, © 1996 %s" fume-version fume-developer))
|
0
|
229
|
|
230 (defconst fume-running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
|
|
231
|
|
232 (defmacro fume-defvar-local (var value &optional doc)
|
|
233 "Defines SYMBOL as an advertised variable.
|
|
234 Performs a defvar, then executes `make-variable-buffer-local' on
|
|
235 the variable. Also sets the `permanent-local' property, so that
|
|
236 `kill-all-local-variables' (called by major-mode setting commands)
|
|
237 won't destroy func-menu control variables."
|
|
238 (` (progn
|
|
239 (if (, doc)
|
|
240 (defvar (, var) (, value) (, doc))
|
|
241 (defvar (, var) (, value)))
|
|
242 (make-variable-buffer-local '(, var))
|
|
243 (put '(, var) 'permanent-local t))))
|
|
244
|
|
245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
246 ;;;;;;;; Backward compatibility hacks for older versions of XEmacs ;;;;;;;
|
|
247 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
248
|
|
249 (or (fboundp 'defalias)
|
|
250 ;; poor man's defalias
|
|
251 (defun defalias (sym newdef)
|
|
252 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.
|
|
253 Associates the function with the current load file, if any."
|
|
254 (fset sym (symbol-function newdef))))
|
|
255
|
|
256 (or (fboundp 'selected-frame)
|
|
257 (defalias 'selected-frame 'selected-screen))
|
|
258
|
|
259 (if (fboundp 'locate-window-from-coordinates)
|
|
260 ;; Older versions of XEmacs need a more robust version of 'event-window'
|
|
261 (defun fume-event-window (event)
|
|
262 (or (event-window event)
|
|
263 (locate-window-from-coordinates
|
|
264 (selected-frame) (list (event-x event) (event-y event)))
|
|
265 (locate-window-from-coordinates
|
|
266 (selected-frame) (list (event-x event) (1- (event-y event))))))
|
|
267 ;; In post 19.11 versions of XEmacs 'event-window' now works acceptably
|
|
268 (defalias 'fume-event-window 'event-window))
|
|
269
|
|
270 (or (fboundp 'shrink-window-if-larger-than-buffer)
|
|
271 ;; Win-Emacs doesn't have this goodie
|
|
272 (defun shrink-window-if-larger-than-buffer (&optional window reqd-height)
|
|
273 "Shrink WINDOW to the smallest no of lines needed to display its buffer,
|
|
274 or to optional REQUIRED-HEIGHT if and only if that is larger. Does nothing if
|
|
275 the buffer contains more lines than the present window height."
|
|
276 (interactive)
|
|
277 (let* ((OriginalWindow (selected-window))
|
|
278 (TargetWindow (select-window (or window OriginalWindow))))
|
|
279 (or (one-window-p t)
|
|
280 (and reqd-height (>= reqd-height (window-height)))
|
|
281 (< (window-height) (1+ (count-lines (point-min) (point-max))))
|
|
282 (let ((calc-reqd-height
|
|
283 (if truncate-lines
|
|
284 (1+ (count-lines (point-min) (point-max)))
|
|
285 (save-excursion
|
|
286 (let ((count 0)
|
|
287 linew
|
|
288 (windw (window-width)))
|
|
289 (goto-char (point-min))
|
|
290 (while (not (eobp))
|
|
291 (setq linew (1+ (progn (end-of-line)
|
|
292 (current-column)))
|
|
293 count (+ count
|
|
294 (/ linew windw)
|
|
295 (min (% linew windw) 1)))
|
|
296 (beginning-of-line 2))
|
|
297 count)))))
|
|
298 (setq reqd-height (1+ (max calc-reqd-height
|
|
299 (1- window-min-height)
|
|
300 (or reqd-height 0))))
|
|
301 (if (> (window-height) reqd-height)
|
|
302 (let* (wc spare bonus share wins shrunkwins)
|
|
303 (walk-windows
|
|
304 '(lambda (w)
|
|
305 (select-window w)
|
|
306 (if (or (eq w TargetWindow)
|
|
307 (> (1+ (count-lines (point-min) (point-max)))
|
|
308 (1- (window-height w))))
|
|
309 (setq wins (cons w wins))
|
|
310 (if (= (1+ (count-lines (point-min) (point-max)))
|
|
311 (1- (window-height w)))
|
|
312 (setq shrunkwins (cons w shrunkwins)))))
|
|
313 'nomini)
|
|
314 (setq wc (1- (length wins))
|
|
315 spare (- (window-height TargetWindow) reqd-height)
|
|
316 share (if (> wc 0) (/ spare wc))
|
|
317 bonus (if (> wc 0) (% spare wc))
|
|
318 shrunkwins (if (zerop wc) nil shrunkwins)
|
|
319 wins (mapcar (function
|
|
320 (lambda (w)
|
|
321 (cons w (list
|
|
322 (if (eq w TargetWindow)
|
|
323 reqd-height
|
|
324 (+ (window-height w)
|
|
325 share
|
|
326 (if (zerop bonus)
|
|
327 0
|
|
328 (setq bonus
|
|
329 (1- bonus))
|
|
330 1)))
|
|
331 (window-start w)))))
|
|
332 wins))
|
|
333 (let (ok (trys 2))
|
|
334 (while (and (not ok) (> trys 0))
|
|
335 (setq trys (1- trys))
|
|
336 (mapcar
|
|
337 (function
|
|
338 (lambda (info)
|
|
339 (select-window (car info))
|
|
340 (enlarge-window
|
|
341 (- (car (cdr info)) (window-height)))))
|
|
342 wins)
|
|
343 (setq ok t)
|
|
344 (mapcar
|
|
345 (function
|
|
346 (lambda (info)
|
|
347 (setq ok
|
|
348 (and ok
|
|
349 (<= (abs (- (car (cdr info))
|
|
350 (window-height
|
|
351 (car info))))
|
|
352 1)))))
|
|
353 wins)))
|
|
354 (mapcar
|
|
355 (function
|
|
356 (lambda (info)
|
|
357 (select-window (car info))
|
|
358 (if (eq (car info) TargetWindow)
|
|
359 (shrink-window
|
|
360 (- (window-height TargetWindow) reqd-height)))
|
|
361 (set-window-start (car info) (car (cdr (cdr info))))))
|
|
362 wins)
|
|
363 (mapcar
|
|
364 (function
|
|
365 (lambda (w)
|
|
366 (select-window w)
|
|
367 (if (< (1+ (count-lines (point-min) (point-max)))
|
|
368 (1- (window-height w)))
|
|
369 (shrink-window-if-larger-than-buffer))))
|
|
370 shrunkwins)))))
|
|
371 (select-window OriginalWindow))))
|
|
372
|
|
373 (defconst fume-modeline-buffer-identification
|
|
374 (if (boundp 'modeline-buffer-identification)
|
|
375 'modeline-buffer-identification
|
|
376 'mode-line-buffer-identification))
|
|
377
|
|
378 (defconst fume-use-local-post-command-hook
|
|
379 (boundp 'local-post-command-hook))
|
|
380
|
|
381 (cond ((fboundp 'add-submenu)
|
|
382 (defconst fume-add-submenu 'add-submenu)
|
|
383 (defun fume-munge-menu-args (menu-name submenu before)
|
82
|
384 (list fume-menu-path (cons menu-name submenu) before)))
|
0
|
385 (t
|
|
386 (defconst fume-add-submenu 'add-menu)
|
|
387 (defun fume-munge-menu-args (menu-name submenu before)
|
82
|
388 (list fume-menu-path menu-name submenu before))))
|
0
|
389
|
|
390 (defun fume-add-submenu (menu-name submenu before)
|
|
391 (apply fume-add-submenu (fume-munge-menu-args menu-name submenu before)))
|
|
392
|
110
|
393 ;; this seems to really be `should I try to change the menubar'
|
0
|
394 (defconst fume-not-tty
|
110
|
395 (or (featurep 'menubar) ;; XEmacs
|
|
396 (featurep 'menu-bar))) ;; GNU Emacs
|
0
|
397
|
|
398 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
399 ;;;;;;;;;;;;;;;;;;;;;;;;;; Customizable Variables ;;;;;;;;;;;;;;;;;;;;;;;;
|
|
400 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
401
|
134
|
402 (defcustom fume-auto-position-popup t
|
0
|
403 "*Set to nil if you don't want the menu to appear in the corner of the window
|
134
|
404 in which case it will track the mouse position instead."
|
|
405 :type 'boolean
|
|
406 :group 'fume)
|
0
|
407
|
|
408 (fume-defvar-local fume-display-in-modeline-p t
|
|
409 "*Set to nil if you don't want the function name appearing in the modeline.
|
|
410 If your modeline is already full, then you can set this variable to something
|
|
411 besides nil or t and the current function will replace the normal
|
|
412 modeline-buffer-identification
|
|
413
|
|
414 Note, this is a buffer-local variable.")
|
|
415
|
|
416 (defvar fume-buffer-name "*Function List*"
|
|
417 "Name of buffer used to list functions when fume-list-functions called")
|
|
418
|
134
|
419 (defcustom fume-menubar-menu-name "Functions"
|
|
420 "*Set this to the string you want to appear in the menubar"
|
|
421 :type 'string
|
|
422 :group 'fume)
|
0
|
423
|
151
|
424 ;;; Bob Weiner <weiner@altrasoft.com>
|
82
|
425 (defvar fume-menu-path nil
|
|
426 "Menubar menu under which the function menu should be installed.
|
|
427 Nil means install it on the menubar itself. Otherwise, it should be a list
|
|
428 of strings, each string names a successively deeper menu under which the
|
|
429 new menu should be located.")
|
|
430
|
134
|
431 (defcustom fume-menubar-menu-location "Buffers"
|
0
|
432 "*Set this nil if you want the menu to appear last on the menubar.
|
134
|
433 Otherwise set this to the menu you want \"Functions\" to appear in front of."
|
|
434 :type '(choice (const :tag "Last" nil) (string :format "%v"))
|
|
435 :group 'fume)
|
0
|
436
|
134
|
437 (defcustom fume-max-items 24
|
|
438 "*Maximum number of elements in a function (sub)menu."
|
|
439 :type 'integer
|
|
440 :group 'fume)
|
0
|
441
|
134
|
442 (defcustom fume-fn-window-position 3
|
0
|
443 "*Number of lines from top of window at which to show function.
|
134
|
444 If nil, display function start from the centre of the window."
|
|
445 :type '(choice (const :tag "Center" nil) integer)
|
|
446 :group 'fume)
|
0
|
447
|
134
|
448 (defcustom fume-index-method 3
|
0
|
449 "*Set this to the method number you want used.
|
|
450
|
|
451 Methods currently supported:
|
|
452 0 = if you want submenu names to be numbered
|
|
453 1 = if you want submenu range indicated by first character
|
|
454 2 = if you want submenu range indicated by first 12 characters
|
134
|
455 3 = if you want submenu range indicated by as many characters as needed"
|
|
456 :type '(radio (const :tag "Numbered" 0)
|
|
457 (const :tag "Indicated by first character" 1)
|
|
458 (const :tag "Indicated by first 12 characters" 2)
|
|
459 (const :tag "Indicated by as many characters as needed" 3))
|
|
460 :group 'fume)
|
0
|
461
|
134
|
462 (defcustom fume-scanning-message "Scanning buffer... (%3d%%)"
|
0
|
463 "*Set to nil if you don't want progress messages during manual scanning
|
134
|
464 of the buffer."
|
|
465 :type '(choice (const :tag "None" nil) string)
|
|
466 :group 'fume)
|
0
|
467
|
134
|
468 (defcustom fume-rescanning-message nil
|
0
|
469 "*Set to non-nil if you want progress messages during automatic scanning
|
134
|
470 of the buffer. For example \"Re-Scanning buffer...\""
|
|
471 :type '(choice (const :tag "None" nil) string)
|
|
472 :group 'fume)
|
0
|
473
|
|
474 (defvar fume-rescan-trigger-counter-buffer-size 10000
|
|
475 "Used to tune the frequency of automatic checks on the buffer.
|
|
476 The function fume-rescan-buffer-trigger only works whenever the value of the
|
|
477 variable fume-rescan-trigger-counter reaches zero, whereupon it gets reset to
|
100
|
478 the maximum of a) buffer-size/fume-rescan-trigger-counter-buffer-size
|
|
479 or b) fume-rescan-trigger-counter-min")
|
|
480
|
|
481 (defvar fume-rescan-trigger-counter-min 50
|
|
482 "Used to tune the frequency of automatic checks on the buffer.
|
|
483 The function fume-rescan-buffer-trigger only works whenever the value of the
|
|
484 variable fume-rescan-trigger-counter reaches zero, whereupon it gets reset to
|
|
485 the maximum of a) buffer-size/fume-rescan-trigger-counter-buffer-size
|
|
486 or b) fume-rescan-trigger-counter-min")
|
0
|
487
|
|
488 (fume-defvar-local
|
|
489 fume-sort-function 'fume-sort-by-name
|
|
490 "*The function to use for sorting the function menu.
|
|
491
|
|
492 Set this to nil if you don't want any sorting (faster).
|
|
493 The items in the menu are then presented in the order they were found
|
|
494 in the buffer.
|
|
495
|
|
496 The function should take two arguments and return T if the first
|
|
497 element should come before the second. The arguments are cons cells;
|
|
498 (NAME . POSITION). Look at 'fume-sort-by-name' for an example.")
|
|
499
|
|
500 (fume-defvar-local
|
|
501 fume-rescan-buffer-hook nil
|
|
502 "*Buffer local hook to call at the end of each buffer rescan")
|
|
503
|
|
504 ;;; This hook is provided for outl-mouse and must not be made buffer local as
|
|
505 ;;; this appears to break outl-mouse for some reason.
|
|
506 ;;;
|
|
507 (defvar fume-found-function-hook nil
|
|
508 "*Hook to call after every function match.")
|
|
509
|
|
510 ;;; Idea for jumping directly with a mouse click
|
|
511 ;;; Marc Paquette <Marc.Paquette@Softimage.COM>
|
|
512 ;;;
|
|
513 (defvar fume-no-prompt-on-valid-default nil
|
|
514 "*Set non-nil if 'fume-prompt-function-goto' should jump without prompting
|
|
515 when a valid default exists.")
|
|
516
|
|
517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
518 ;;;;;;;;;;;;;;;;;;;;;;;;;; Buffer local variables ;;;;;;;;;;;;;;;;;;;;;;;;
|
|
519 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
520
|
|
521 (fume-defvar-local
|
|
522 fume-auto-rescan-buffer-p t
|
|
523 "Buffer local variable which if non-nil permits automatic buffer rescanning
|
|
524 by func-menu.
|
|
525
|
|
526 Usage:
|
|
527 By default, fume-auto-rescan-buffer-p is set to non-nil. If you feel that
|
|
528 a given mode 'foo' is becoming too slow as a result of automatic rescanning
|
|
529 by func-menu, then do something along the lines of the following:
|
|
530
|
|
531 (defun remove-func-menu-auto-rescan ()
|
|
532 (setq fume-auto-rescan-buffer-p nil))
|
|
533
|
|
534 (add-hook 'foo-mode-hook 'remove-func-menu-auto-rescan)")
|
|
535
|
|
536 (fume-defvar-local
|
|
537 fume-funclist nil
|
|
538 "The latest list of function names in the buffer")
|
|
539
|
|
540 (fume-defvar-local
|
|
541 fume-function-name-regexp nil
|
|
542 "The keywords to show in a menu")
|
|
543
|
|
544 (fume-defvar-local
|
|
545 fume-find-next-function-name-method nil
|
|
546 "The function to use to find the next function name in the buffer")
|
|
547
|
|
548 (fume-defvar-local
|
|
549 fume-modeline-funclist nil
|
|
550 "The latest list of function names in the buffer to display in the modeline")
|
|
551
|
|
552 (fume-defvar-local
|
|
553 fume-funclist-dirty-p nil
|
|
554 "Flags whether the buffer is in need of a fresh scan")
|
|
555
|
|
556 (fume-defvar-local
|
|
557 fume-rescan-inhibit-p nil
|
|
558 "Internal variable only. DO NOT TOUCH.")
|
|
559
|
|
560 (fume-defvar-local
|
|
561 fume-rescan-trigger-counter 0
|
|
562 "Used in large buffers to optimise checking frequency")
|
|
563
|
|
564 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
565 ;;;;;;;;;;;;;;;;;;;;; Mode specific regexp's and hooks ;;;;;;;;;;;;;;;;;;;
|
|
566 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
567
|
|
568 ;;; Every fume-function-name-regexp-<language> should uniquely identify a
|
|
569 ;;; function for that certain language.
|
|
570
|
|
571 ;;; Lisp
|
|
572 ;;;
|
82
|
573 ;;; Vladimir Alexiev <vladimir@cs.ualberta.ca>
|
102
|
574 ;;; JTL: 24. Feb. 97 added "/" as part of function names
|
0
|
575 (defvar fume-function-name-regexp-lisp
|
|
576 (concat
|
82
|
577 "^[ \t]*" ; Allow whitespace |(or (fboundp 'foo)
|
|
578 ; for the construct | (defun foo ()
|
|
579 "(\\(def[^vc][a-z]*\\)" ; Allow (def* except (defvar, (defconst
|
|
580 "\\s-+" ; At least one whitespace
|
102
|
581 "'?[#:?/A-Za-z0-9_+>-]+" ; Allow (defalias 'foo 'bar)
|
82
|
582 "\\s-*" ; Whitespace
|
|
583 "\\(nil\\|(\\)" ; nil or (arg list
|
0
|
584 )
|
|
585 "Expression to get lisp function names")
|
|
586
|
|
587 ;;; C
|
|
588 ;;;
|
|
589 ;;; Danny Bar-Dov <danny@acet02.amil.co.il>
|
151
|
590 ;;; Bob Weiner <weiner@altrasoft.com> added #define macro support.
|
0
|
591 (defvar fume-function-name-regexp-c
|
|
592 (concat
|
151
|
593 "^\\([a-zA-Z0-9]+\\|#define\\)\\s-?" ; type specs; there can be no
|
82
|
594 "\\([a-zA-Z0-9_*]+\\s-+\\)?" ; more than 3 tokens, right?
|
0
|
595 "\\([a-zA-Z0-9_*]+\\s-+\\)?"
|
82
|
596 "\\([*&]+\\s-*\\)?" ; pointer
|
|
597 "\\([a-zA-Z0-9_*]+\\)[ \t\n]*(" ; name
|
0
|
598 )
|
|
599 "Expression to get C function names")
|
|
600
|
|
601 ;;; C++
|
|
602 ;;;
|
|
603 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
604 ;;; Kevin R. Powell <powell@csl.ncsa.uiuc.edu>
|
|
605 ;;; Mats Lidell <mats.lidell@eua.ericsson.se>
|
|
606 ;;; Mike Battaglia <mbattagl@spd.dsccc.com>
|
|
607 ;;; Oliver Schittko <schittko@fokus.gmd.de>
|
|
608 ;;; Tom Murray <tmurray@hpindck.cup.hp.com>
|
151
|
609 ;;; Bob Weiner <weiner@altrasoft.com> added #define macro support.
|
0
|
610 (defvar fume-function-name-regexp-c++
|
|
611 (cons
|
|
612 (concat
|
151
|
613 "^\\(#define\\s-+\\|"
|
|
614 "\\(template\\s-+<[^>]+>\\s-+\\)?" ; template formals
|
0
|
615 "\\([a-zA-Z0-9_*&<,>:]+\\s-+\\)?" ; type specs; there can be no
|
|
616 "\\([a-zA-Z0-9_*&<,>\"]+\\s-+\\)?" ; more than 3 tokens, right?
|
151
|
617 "\\([a-zA-Z0-9_*&<,>]+\\s-+\\)?\\)"
|
0
|
618 "\\(\\([a-zA-Z0-9_&~:<,>*]\\|\\(\\s +::\\s +\\)\\)+\\)"
|
|
619 "\\(o?perator\\s *.[^(]*\\)?\\(\\s-\\|\n\\)*(" ; name
|
151
|
620 ) 6)
|
0
|
621 "Expression to get C++ function names")
|
|
622
|
|
623 ;;; FORTRAN
|
|
624 ;;;
|
|
625 ;;; Paul Emsley <paule@chem.gla.ac.uk>
|
|
626 ;;; Raymond L. Toy <toy@soho.crd.ge.com>
|
|
627 ;;; Richard Cognot <cognot@elfgrc.co.uk>
|
|
628 ;;; Greg Sjaardema <gdsjaar@sandia.gov>
|
|
629 (defvar fume-function-name-regexp-fortran
|
|
630 (concat
|
|
631 ;; >= six spaces
|
|
632 "^ \\s-*"
|
|
633 ;; type specs
|
|
634 "+[a-zA-Z0-9*]*\\s-*"
|
|
635 ;; continuation lines
|
|
636 "\\(\n [^ 0]\\s-*\\)*"
|
|
637 ;; function or subroutine
|
|
638 "\\(entry\\|ENTRY\\|function\\|FUNCTION\\|subroutine\\|SUBROUTINE\\)\\s-*"
|
|
639 ;; continuation lines
|
|
640 "\\(\n [^ 0]\\s-*\\)*"
|
|
641 )
|
|
642 "Expression to get Fortran 77 function and subroutine names")
|
|
643
|
|
644 ;;; John Turner <turner@xdiv.lanl.gov>
|
|
645 (defvar fume-function-name-regexp-fortran90
|
|
646 (concat
|
|
647 ;; type specs
|
|
648 "+[a-zA-Z0-9*]*\\s-*"
|
|
649 ;; function or subroutine
|
|
650 "\\(entry\\|ENTRY\\|function\\|FUNCTION\\|module\\|MODULE\\|subroutine\\|SUBROUTINE\\)\\s-*"
|
|
651 )
|
|
652 "Expression to get Fortran 90 function, module and subroutine names")
|
|
653
|
|
654 ;;; Modula
|
|
655 (defvar fume-function-name-regexp-modula
|
|
656 "^\\s-*PROCEDURE\\s-+[A-Za-z0-9_-]+"
|
|
657 "Expression to get Modula function names")
|
|
658
|
|
659 ;;; Bacis2
|
|
660 ;;;
|
|
661 ;;; CV MEDUSA's 4th generation language
|
|
662 (defvar fume-function-name-regexp-bacis
|
|
663 "module_define(!\\|define_constant(!\\|sys_sysdefine(!\\|<<dbgid +\\s-*"
|
|
664 "Expression to get Bacis2 function names")
|
|
665
|
|
666 ;;; Maple
|
|
667 ;;;
|
|
668 ;;; Luc Tancredi <Luc.Tancredi@sophia.inria.fr>
|
|
669 (defvar fume-function-name-regexp-maple
|
|
670 "^[ \t]*[a-zA-Z0-9_]+[ \t]*:=[ \t]*proc[ \t]*("
|
|
671 "Expression to get maple function/procedure names")
|
|
672
|
|
673 ;;; Tcl
|
|
674 ;;;
|
|
675 ;;; Andy Piper <ajp@eng.cam.ac.uk>
|
|
676 ;;; Jean-Michel Augusto <augusto@eureecom.fr>
|
|
677 ;;; Dr P.G. Sjoerdsma <pgs1002@esc.cam.ac.uk>
|
|
678 (defvar fume-function-name-regexp-tcl
|
|
679 (cons "^\\s *proc\\s +\\(\\S-+\\)\\s *{" 1)
|
|
680 "Expression to get Tcl function Names")
|
|
681
|
|
682 ;;; Java
|
|
683 ;;;
|
|
684 ;;; Heddy Boubaker <boubaker@dgac.fr>
|
|
685 (defvar fume-function-name-regexp-java
|
|
686 "\\s-+\\([A-Za-z_][A-Za-z0-9_]+\\)[\n \t\r]*\\((\\)"
|
|
687 "Expression to get Java methods names")
|
|
688
|
|
689 ;;; Perl
|
|
690 ;;;
|
|
691 ;;; Alex Rezinsky <alexr@msil.sps.mot.com>
|
|
692 ;;; Michael Lamoureux <lamour@engin.umich.edu>
|
|
693 (defvar fume-function-name-regexp-perl "^sub[ \t]+\\([A-Za-z0-9_]+\\)"
|
|
694 "Expression to get Perl function Names")
|
|
695
|
|
696 ;;; Python support
|
|
697 ;;; Shuichi Koga <skoga@virginia.edu>
|
|
698 ;;;
|
|
699 (defvar fume-function-name-regexp-python
|
|
700 "^\\s-*\\(class\\|def\\)+\\s-*\\([A-Za-z0-9_]+\\)\\s-*[(:]"
|
|
701 "Expression to get Python class and function names")
|
|
702
|
|
703 ;;; Postscript
|
|
704 ;;;
|
|
705 ;;; Leigh L. Klotz <klotz@adoc.xerox.com>
|
|
706 (defvar fume-function-name-regexp-postscript
|
|
707 "^/[^][ \t{}<>]*"
|
|
708 "Expression to get postscript function names")
|
|
709
|
|
710 ;;; Prolog
|
|
711 ;;;
|
|
712 ;;; Laszlo Teleki <laszlo@ipb.uni-bonn.de>
|
|
713 (defvar fume-function-name-regexp-prolog
|
|
714 "^[a-z][a-zA-Z0-9_]+"
|
|
715 "Expression to get prolog fact and clause names")
|
|
716
|
|
717 ;;; Ehdm
|
|
718 ;;;
|
|
719 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
720 (defvar fume-function-name-regexp-ehdm
|
|
721 (concat
|
|
722 "[A-Za-z0-9_]*:[ ]*"
|
|
723 "\\([Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn]\\|"
|
|
724 "[Ll][Ee][Mm][Mm][Aa]\\|"
|
|
725 "[Aa][Xx][Ii][Oo][Mm]\\|"
|
|
726 "[Pp][Rr][Oo][Vv][Ee]\\|"
|
|
727 "[Tt][Hh][Ee][Oo][Rr][Ee][Mm]"
|
|
728 "\\)"
|
|
729 )
|
|
730 "*Expression to get Ehdm function, theorems, axioms, lemmas, and proofs.")
|
|
731
|
|
732 ;;; PVS
|
|
733 ;;;
|
|
734 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
735 (defvar fume-function-name-regexp-pvs
|
|
736 (concat
|
|
737 "\\([A-Za-z0-9_]*:[ ]*"
|
|
738 "\\([Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn]\\|"
|
|
739 "[Ll][Ee][Mm][Mm][Aa]\\|"
|
|
740 "[Aa][Xx][Ii][Oo][Mm]\\|"
|
|
741 "[Tt][Hh][Ee][Oo][Rr][Ee][Mm]\\|"
|
|
742 "[Ff][Or][Rr][Mm][Uu][La][Aa]"
|
|
743 "\\|"
|
|
744 "\\[.*\\]"
|
|
745 "\\)\\)\\|"
|
|
746 "[A-Za-z0-9_]*(.*)[ ]*:"
|
|
747 )
|
|
748 "*Expression to get PVS functions, theorems, axioms, lemmas")
|
|
749
|
|
750 ;;; Tex, LaTex
|
|
751 ;;;
|
|
752 ;;; Philippe Queinnec <queinnec@cenatls.cena.dgac.fr>
|
|
753 ;;; Paolo Frasconi <paolo@mcculloch.ing.unifi.it>
|
|
754 (fume-defvar-local fume-tex-chapter 0)
|
|
755 (fume-defvar-local fume-tex-section 0)
|
|
756 (fume-defvar-local fume-tex-subsection 0)
|
|
757 (fume-defvar-local fume-tex-subsubsection 0)
|
|
758
|
|
759 (defun fume-tex-rescan-buffer-hook ()
|
|
760 (setq fume-tex-chapter 0
|
|
761 fume-tex-section 0
|
|
762 fume-tex-subsection 0
|
|
763 fume-tex-subsubsection 0))
|
|
764
|
|
765 (defun fume-tweak-tex-mode ()
|
|
766 (setq fume-sort-function nil)
|
|
767 (add-hook 'fume-rescan-buffer-hook 'fume-tex-rescan-buffer-hook))
|
|
768
|
|
769 (add-hook 'tex-mode-hook 'fume-tweak-tex-mode)
|
|
770 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
771 (add-hook 'TeX-mode-hook 'fume-tweak-tex-mode)
|
|
772 ;;; Wolfgang Mettbach <wolle@uni-paderborn.de>
|
|
773 (add-hook 'latex-mode-hook 'fume-tweak-tex-mode)
|
|
774 (add-hook 'LaTeX-mode-hook 'fume-tweak-tex-mode)
|
|
775
|
|
776 ;;; Philippe Queinnec <queinnec@cenatls.cena.dgac.fr>
|
|
777 (defvar fume-section-name-regexp-latex
|
|
778 (concat
|
|
779 "^\\s-*\\\\\\("
|
|
780 "\\(sub\\)*section\\|chapter\\)"
|
|
781 "\\*?\\(\\[[^]]*\\]\\)?{\\([^}]*\\)}"
|
|
782 )
|
|
783 "Expression to get latex section names")
|
|
784
|
|
785 ;;; ksh
|
|
786 ;;;
|
|
787 ;;; Philippe Bondono <bondono@vnet.ibm.com>
|
|
788 (defvar fume-function-name-regexp-ksh
|
|
789 (concat
|
|
790 "\\(^\\s-*function\\s-+[A-Za-z_][A-Za-z_0-9]*\\)"
|
|
791 "\\|"
|
|
792 "\\(^\\s-*[A-Za-z_][A-Za-z_0-9]*\\s-*()\\)")
|
|
793 "Expression to get ksh function names")
|
|
794
|
|
795 ;;; Scheme
|
|
796 ;;;
|
|
797 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
798 (defvar fume-function-name-regexp-scheme
|
|
799 "^(define [ ]*"
|
|
800 "Expression to get Scheme function names")
|
|
801
|
|
802 ;;; BibTeX
|
|
803 ;;;
|
|
804 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
805 (defvar fume-function-name-regexp-bibtex
|
|
806 ;; "^@[A-Za-z]*[({]\\([A-Za-z0-9:;&-]*\\),"
|
|
807 ;; Christoph Wedler <wedler@fmi.uni-passau.de>
|
|
808 ;; According to the LaTeX Companion, this should be
|
116
|
809 "^@[A-Za-z]*[({]\\([A-Za-z][^ \t\n\"#%'(),={}]*\\),"
|
0
|
810 "Expression to get bibtex citation headers.")
|
|
811
|
|
812 ;;; SGML
|
|
813 ;;;
|
|
814 ;;; Thomas Plass <thomas.plass@mid-heidelberg.de>
|
|
815 (defvar fume-function-name-regexp-sgml
|
|
816 "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)"
|
|
817 "Expression to find declaration of SGML element or entity")
|
|
818
|
|
819 ;;; Ada
|
|
820 ;;;
|
|
821 ;;; Michael Polo <mikep@polo.mn.org> <mikep@cfsmo.honeywell.com>
|
|
822 (defvar fume-function-name-regexp-ada
|
|
823 (cons "^[ \t]*\\(procedure\\|PROCEDURE\\|function\\|FUNCTION\\)[ \n\t]+\\([a-zA-Z0-9_]+\\|\"[^\"]\"\\)" 2)
|
|
824 "Expression to find declaration of Ada function")
|
|
825
|
|
826 ;;; ignore prototypes, 'renames', 'is new' to eliminate clutter
|
|
827 ;;;
|
|
828 ;;; Scott Evans <gse@ocsystems.com>
|
|
829 (defvar fume-function-name-regexp-ada-ignore
|
|
830 "[ \n\t]*\\(([^()]+)[ \n\t]*\\)?\\(return[ \t\n]+[^ \t\n;]+[ \n\t]*\\)?\\(;\\|is[ \n\t]+new[ \n\t]\\|renames\\)"
|
|
831 "ignore if ada function name matches this string")
|
|
832
|
|
833 ;;; Makefiles
|
|
834 ;;;
|
|
835 ;;; Paul Filipski & Anthony Girardin <{filipski,girardin}@blackhawk.com>
|
|
836 (defvar fume-function-name-regexp-make
|
|
837 "^\\(\\(\\$\\s(\\)?\\(\\w\\|\\.\\)+\\(:sh\\)?\\(\\s)\\)?\\)\\s *\\(::?\\|\\+?=\\)"
|
|
838 "Expression to get makefile target names")
|
82
|
839 (add-hook 'makefile-mode-hook 'fume-add-menubar-entry)
|
0
|
840
|
|
841 ;;; Directory Listings
|
|
842 ;;;
|
|
843 ;;; Norbert Kiesel <norbert@i3.informatik.rwth-aachen.de>
|
|
844 ;;; regexp stolen from font-lock-mode
|
|
845 (defvar fume-function-name-regexp-dired
|
|
846 "^. +d.*\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\) +[0-9]+ +[0-9:]+ \\(.*\\)$"
|
|
847 "Expression to get directory names")
|
|
848
|
|
849 ;;; Pascal
|
|
850 ;;;
|
|
851 ;;; Espen Skoglund <espensk@stud.cs.uit.no>
|
|
852 (defvar fume-function-name-regexp-pascal
|
|
853 "^\\(function\\|procedure\\)[ \t]+\\([_a-zA-Z][_a-zA-Z0-9]*\\)"
|
|
854 "Expression to get function/procedure names in pascal.")
|
|
855
|
|
856
|
|
857 ;;; Fame
|
|
858 ;;;
|
|
859 ;;; Cooper Vertz <cooper@prod2.imsi.com>
|
|
860 (defvar fume-function-name-regexp-fame
|
|
861 "^\\(function\\|procedure\\)[ \t]+\\([#\\$%_a-zA-Z][#\\$%_a-zA-Z0-9]*\\)"
|
|
862 "Expression to get function/procedure names in fame.")
|
|
863
|
|
864
|
|
865 ;;; Verilog
|
|
866 ;;;
|
|
867 ;;; Matt Sale <mdsale@icdc.delcoelect.com>
|
|
868 (defvar fume-function-name-regexp-verilog
|
|
869 "^\\(task\\|function\\|module\\|primitive\\)[ \t]+\\([A-Za-z0-9_+-]*\\)[ \t]*(?"
|
|
870 "Expression to get verilog module names")
|
|
871
|
82
|
872 ;;; Idl
|
|
873 ;;;
|
|
874 ;;; Lubos Pochman <lubos@rsinc.com>
|
|
875 (defvar fume-function-name-regexp-idl
|
|
876 (cons "^\\s *\\([pP][rR][oO]\\|[fF][uU][nN][cC][tT][iI][oO][nN]\\)\\s +\\([A-Za-z][A-Za-z0-9_$]*\\)" 2)
|
|
877 "Expression to get Idl function Names")
|
0
|
878
|
|
879 ;;; Assembly
|
|
880 (defvar fume-function-name-regexp-asm
|
|
881 "^\\([a-zA-Z_.$][a-zA-Z0-9_.$]*\\)[ \t]*:"
|
|
882 "Expression to get assembly label names")
|
|
883
|
|
884 ;;; This is where the mode specific regexp's are hooked in
|
|
885 ;;;
|
|
886 (defvar fume-function-name-regexp-alist
|
|
887 '(;; Lisp
|
|
888 (emacs-lisp-mode . fume-function-name-regexp-lisp)
|
|
889 (common-lisp-mode . fume-function-name-regexp-lisp)
|
|
890 (fi:common-lisp-mode . fume-function-name-regexp-lisp)
|
|
891 (fi:emacs-lisp-mode . fume-function-name-regexp-lisp)
|
|
892 (fi:franz-lisp-mode . fume-function-name-regexp-lisp)
|
|
893 (fi:inferior-common-lisp-mode . fume-function-name-regexp-lisp)
|
|
894 (fi:inferior-franz-lisp-mode . fume-function-name-regexp-lisp)
|
|
895 (fi:lisp-listener-mode . fume-function-name-regexp-lisp)
|
|
896 (lisp-mode . fume-function-name-regexp-lisp)
|
|
897 (lisp-interaction-mode . fume-function-name-regexp-lisp)
|
|
898
|
|
899 ;; C
|
|
900 (c-mode . fume-function-name-regexp-c)
|
|
901 (elec-c-mode . fume-function-name-regexp-c)
|
|
902 (c++-c-mode . fume-function-name-regexp-c)
|
|
903
|
|
904 ;; C++
|
|
905 (c++-mode . fume-function-name-regexp-c++)
|
|
906
|
|
907 ;; Fortran
|
|
908 (fortran-mode . fume-function-name-regexp-fortran)
|
|
909 (f90-mode . fume-function-name-regexp-fortran90)
|
|
910
|
|
911 ;; Modula
|
|
912 (modula-2-mode . fume-function-name-regexp-modula)
|
|
913 (modula-3-mode . fume-function-name-regexp-modula)
|
|
914
|
|
915 ;; Bacis2
|
|
916 (bacis-mode . fume-function-name-regexp-bacis)
|
|
917
|
|
918 ;; Maple
|
|
919 (maple-mode . fume-function-name-regexp-maple)
|
|
920
|
|
921 ;; Perl
|
|
922 (perl-mode . fume-function-name-regexp-perl)
|
|
923
|
|
924 ;; Java
|
|
925 (java-mode . fume-function-name-regexp-java)
|
|
926
|
|
927 ;; Python
|
|
928 (alice-mode . fume-function-name-regexp-python)
|
|
929 (python-mode . fume-function-name-regexp-python)
|
|
930
|
|
931 ;; Postscript
|
|
932 (postscript-mode . fume-function-name-regexp-postscript)
|
|
933
|
|
934 ;; Prolog
|
|
935 (prolog-mode . fume-function-name-regexp-prolog)
|
|
936
|
|
937 ;; Tcl
|
|
938 (tcl-mode . fume-function-name-regexp-tcl)
|
|
939
|
|
940 ;; ksh
|
|
941 (ksh-mode . fume-function-name-regexp-ksh)
|
|
942
|
|
943 ;; LaTeX
|
|
944 (latex-mode . fume-section-name-regexp-latex)
|
|
945 (LaTeX-mode . fume-section-name-regexp-latex)
|
|
946
|
|
947 ;; Scheme
|
|
948 (scheme-mode . fume-function-name-regexp-scheme)
|
|
949
|
|
950 ;; BibTeX
|
|
951 (bibtex-mode . fume-function-name-regexp-bibtex)
|
|
952
|
|
953 ;; Ehdm & PVS
|
|
954 (ehdm-mode . fume-function-name-regexp-ehdm)
|
|
955 (pvs-mode . fume-function-name-regexp-pvs)
|
|
956
|
|
957 ;; SGML
|
|
958 (sgml-mode . fume-function-name-regexp-sgml)
|
|
959
|
|
960 ;; Ada
|
|
961 (ada-mode . fume-function-name-regexp-ada)
|
|
962
|
|
963 ;; Makefiles
|
|
964 (makefile-mode . fume-function-name-regexp-make)
|
|
965
|
|
966 ;; Dired
|
|
967 (dired-mode . fume-function-name-regexp-dired)
|
|
968
|
|
969 ;; Pascal
|
|
970 (pascal-mode . fume-function-name-regexp-pascal)
|
|
971
|
|
972 ;; Fame
|
|
973 (fame-mode . fume-function-name-regexp-fame)
|
|
974
|
|
975 ;; Verilog
|
|
976 (verilog-mode . fume-function-name-regexp-verilog)
|
|
977
|
82
|
978 ;; Idl
|
|
979 (idl-mode . fume-function-name-regexp-idl)
|
|
980
|
0
|
981 ;; Assembly
|
|
982 (asm-mode . fume-function-name-regexp-asm)
|
|
983 )
|
|
984
|
|
985 "The connection between a mode and the regexp that matches function names.")
|
|
986
|
|
987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
988 ;;;;;;;;;;;;;;;;;;;;; Mode specific finding functions ;;;;;;;;;;;;;;;;;;;;
|
|
989 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
990
|
|
991 ;;; Default routine : Note, most modes will need a specialised routine
|
|
992 ;;;
|
|
993 (defun fume-find-next-function-name (buffer)
|
|
994 "Searches for the next function in BUFFER."
|
|
995 (set-buffer buffer)
|
|
996 ;; Search for the function
|
|
997 (if (re-search-forward fume-function-name-regexp nil t)
|
|
998 (let ((char (progn
|
82
|
999 (if (string-match
|
|
1000 "[({[]"
|
|
1001 (char-to-string (char-after (1- (point)))))
|
|
1002 (backward-char)
|
|
1003 (forward-word -1))
|
0
|
1004 (save-excursion
|
|
1005 (goto-char (scan-sexps (point) 1))
|
|
1006 (skip-chars-forward "[ \t\n]")
|
|
1007 (following-char)))))
|
|
1008 ;; Skip this function name if it is a prototype declaration.
|
|
1009 (if (and (eq char ?\;) (not (eq major-mode 'emacs-lisp-mode)))
|
|
1010 (fume-find-next-function-name buffer)
|
|
1011 ;; Get the function name and position
|
|
1012 (let (beg)
|
|
1013 (forward-sexp -1)
|
|
1014 (setq beg (point))
|
|
1015 (forward-sexp)
|
|
1016 (cons (buffer-substring beg (point)) beg))))))
|
|
1017
|
|
1018 ;;; General purpose sexp find function
|
|
1019 ;;;
|
|
1020 (defun fume-find-next-sexp (buffer)
|
|
1021 "Searches for the next sexp type function in BUFFER."
|
|
1022 (set-buffer buffer)
|
|
1023 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1024 (let ((beg (save-excursion (forward-sexp -1) (point))))
|
|
1025 (cons (buffer-substring beg (point)) beg))))
|
|
1026
|
|
1027 ;;; Specialised routine to get the next ehdm entity in the buffer.
|
|
1028 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
1029 ;;;
|
|
1030 (defun fume-find-next-ehdm-entity (buffer)
|
|
1031 (set-buffer buffer)
|
|
1032 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1033 (let ((beg (match-beginning 0))
|
|
1034 (end (match-end 0)))
|
|
1035 (cons (buffer-substring beg end) beg))))
|
|
1036
|
|
1037 ;;; Specialised routine to get the next PVS entity in the buffer.
|
|
1038 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
1039 ;;;
|
|
1040 (defun fume-find-next-pvs-entity (buffer)
|
|
1041 (set-buffer buffer)
|
|
1042 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1043 (let ((beg (match-beginning 0))
|
|
1044 (end (match-end 0)))
|
|
1045 (goto-char (1- end))
|
|
1046 (if (looking-at ":")
|
|
1047 (setq end (1- end)))
|
|
1048 (cons (buffer-substring beg end) beg))))
|
|
1049
|
|
1050 ;;; Specialised routine to get the next C function name in the buffer.
|
82
|
1051 ;;; Modified 16/12/96: Jerome Bertorelle <bertorel@telspace.alcatel.fr>
|
0
|
1052 ;;;
|
|
1053 (defun fume-find-next-c-function-name (buffer)
|
|
1054 "Searches for the next C function in BUFFER."
|
|
1055 (set-buffer buffer)
|
|
1056 ;; Search for the function
|
|
1057 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1058 (let ((char (progn
|
|
1059 (backward-up-list 1)
|
|
1060 (save-excursion
|
|
1061 (goto-char (scan-sexps (point) 1))
|
|
1062 (skip-chars-forward "[ \t\n]")
|
|
1063 (following-char)))))
|
|
1064 ;; Skip this function name if it is a prototype declaration.
|
|
1065 (if (eq char ?\;)
|
82
|
1066 (fume-find-next-c-function-name buffer)
|
0
|
1067 (let (beg
|
|
1068 name)
|
|
1069 ;; Get the function name and position
|
|
1070 (forward-sexp -1)
|
|
1071 (setq beg (point))
|
|
1072 (forward-sexp)
|
|
1073 (setq name (buffer-substring beg (point)))
|
|
1074 ;; ghastly crock for DEFUN declarations
|
|
1075 (cond ((string-match "^DEFUN\\s-*" name)
|
|
1076 (forward-word 1)
|
|
1077 (forward-word -1)
|
|
1078 (setq beg (point))
|
|
1079 (cond ((re-search-forward "\"," nil t)
|
|
1080 (re-search-backward "\"," nil t)
|
|
1081 (setq name
|
|
1082 (format "%s %s"
|
|
1083 name
|
|
1084 (buffer-substring beg (point))))))))
|
82
|
1085 ;; kludge to avoid 'void' etc in menu
|
|
1086 (if (string-match "^void$\\|^if$\\|^switch$\\|^while$" name)
|
|
1087 (fume-find-next-c-function-name buffer)
|
0
|
1088 (cons name beg)))))))
|
|
1089
|
82
|
1090 ;;; Peter Pezaris <pez@dwwc.com>
|
|
1091 ;;;
|
0
|
1092 (defun fume-cc-inside-comment ()
|
82
|
1093 (memq (buffer-syntactic-context) '(comment block-comment)))
|
0
|
1094
|
|
1095 ;;; <jrm@odi.com>
|
|
1096 ;;; <ajp@eng.cam.ac.uk>
|
|
1097 ;;; <schittko@fokus.gmd.de>
|
151
|
1098 ;;; <d.hughes@videonetworks.com> - speedup, David Hughes 24th November 1996
|
0
|
1099 ;;;
|
|
1100 (defun fume-match-find-next-function-name (buffer)
|
82
|
1101 ;; General next function name in BUFFER finder using match.
|
|
1102 ;; The regexp is assumed to be a two item list the car of which is the regexp
|
|
1103 ;; to use, and the cdr of which is the match position of the function name
|
0
|
1104 (set-buffer buffer)
|
82
|
1105 (let ((r (car fume-function-name-regexp))
|
|
1106 (p (cdr fume-function-name-regexp)))
|
|
1107 (catch 'found
|
|
1108 (while (re-search-forward r nil t)
|
|
1109 (catch 'skip
|
|
1110 (if (fume-cc-inside-comment) (throw 'skip t))
|
|
1111 (save-excursion
|
|
1112 (re-search-backward r nil t)
|
|
1113 (if (string= "typedef" (fume-what-looking-at)) (throw 'skip t))
|
|
1114 (re-search-forward r nil t))
|
|
1115 (backward-up-list 1)
|
|
1116 (save-excursion
|
|
1117 (goto-char (scan-sexps (point) 1))
|
|
1118 (if (eq ?\; (following-char)) (throw 'skip t))) ; skip prototypes
|
|
1119 (throw
|
|
1120 'found
|
|
1121 (cons (buffer-substring (setq p (match-beginning p)) (point)) p))))
|
|
1122 nil)))
|
0
|
1123
|
|
1124 ;;; Specialised routine to find the next Perl function
|
|
1125 ;;;
|
|
1126 (defun fume-find-next-perl-function-name (buffer)
|
|
1127 "Searches for the next Perl function in BUFFER."
|
|
1128 (fume-find-next-sexp buffer))
|
|
1129
|
|
1130 ;;; Specialised routine to find the next Java function
|
151
|
1131 ;;; Bob Weiner <weiner@altrasoft.com>
|
0
|
1132 ;;; Heddy Boubaker <boubaker@dgac.fr>
|
|
1133 ;;;
|
|
1134 (defun fume-find-next-java-function-name (buffer)
|
|
1135 "Searches for the next Java function in BUFFER."
|
|
1136 (set-buffer buffer)
|
|
1137 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1138 (let ((beg (match-beginning 1))
|
|
1139 (end (match-end 1)))
|
|
1140 (goto-char (match-beginning 2))
|
|
1141 (forward-sexp)
|
|
1142 (if (and (looking-at "[^;(]*{")
|
|
1143 (not (fume-cc-inside-comment)))
|
82
|
1144 ;; This is a method definition and we're not in a comment
|
0
|
1145 (let ((str (buffer-substring beg end)))
|
151
|
1146 ;; Bob Weiner <weiner@altrasoft.com> added exact match
|
82
|
1147 ;; delimiters so function names that happen to contain
|
|
1148 ;; any of these terms are not eliminated. The old version
|
|
1149 ;; would ignore "notify()" since it contained "if".
|
|
1150 (or (string-match "\\`\\(if\\|switch\\|catch\\|for\\|while\\)\\'"
|
|
1151 str)
|
|
1152 ;; These constructs look like method definitions but are not
|
0
|
1153 (cons str beg)))
|
|
1154 (fume-find-next-java-function-name buffer)))))
|
|
1155
|
|
1156 ;;; Specialised routine to find the next Python function
|
|
1157 ;;; Shuichi Koga <skoga@virginia.edu>
|
|
1158 ;;;
|
|
1159 (defun fume-find-next-python-function-name (buffer)
|
|
1160 "Searches for the next python function in BUFFER."
|
|
1161 (set-buffer buffer)
|
|
1162 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1163 (save-excursion
|
|
1164 (let* ((retpnt (match-beginning 2))
|
|
1165 (retname (buffer-substring retpnt (match-end 2))))
|
|
1166 (goto-char (match-beginning 0))
|
|
1167 (cond ((looking-at "\\s-+def")
|
|
1168 (re-search-backward
|
|
1169 "^class\\s-*\\([A-Za-z0-9_]+\\)\\s-*[(:]" nil t)
|
|
1170 (setq retname
|
|
1171 (concat
|
|
1172 (buffer-substring (match-beginning 1) (match-end 1))
|
|
1173 "."
|
|
1174 retname))))
|
|
1175 (cons retname retpnt)))))
|
|
1176
|
|
1177 ;;; Specialised routine to find the next Modula function or subroutine.
|
|
1178 ;;;
|
|
1179 (defun fume-find-next-modula-function-name (buffer)
|
|
1180 "Searches for the next modula function in BUFFER."
|
|
1181 (fume-find-next-sexp buffer))
|
|
1182
|
|
1183 ;;; Specialised routine to find the next directory.
|
|
1184 ;;; Norbert Kiesel <norbert@i3.informatik.rwth-aachen.de>
|
|
1185 ;;;
|
|
1186 (defun fume-find-next-directory-name (buffer)
|
|
1187 "Searches for the next directory in dired BUFFER."
|
|
1188 (set-buffer buffer)
|
|
1189 ;; Search for the function
|
|
1190 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1191 (let ((beg (match-beginning 2))
|
|
1192 (end (match-end 2)))
|
|
1193 (cons (buffer-substring beg end) beg))))
|
|
1194
|
|
1195 ;;; Specialised routine to find the next Fortran function or subroutine
|
|
1196 ;;;
|
|
1197 (defun fume-find-next-fortran-function-name (buffer)
|
|
1198 "Searches for the next Fortran function in BUFFER."
|
|
1199 (set-buffer buffer)
|
|
1200 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1201 (let ((pos (point))
|
|
1202 ;; name may have "_" but must start with a letter
|
|
1203 (name-regexp "\\s-+[a-zA-Z]+[_a-zA-Z0-9*]*")
|
|
1204 (eol (save-excursion (end-of-line 1) (point))))
|
|
1205 (skip-chars-backward " \t")
|
|
1206 (if (re-search-forward name-regexp eol t)
|
|
1207 ;; name is ok; so return it
|
|
1208 (cons (buffer-substring pos (point)) pos)
|
|
1209 ;; rubbish found; skip to next function
|
|
1210 (fume-find-next-fortran-function-name buffer)))))
|
|
1211
|
|
1212 ;;; Specialised routine to get the next postscript function name in the buffer
|
|
1213 ;;; Leigh L. Klotz <klotz@adoc.xerox.com>
|
|
1214 ;;;
|
|
1215 (defun fume-find-next-postscript-function-name (buffer)
|
|
1216 "Searches for the next postscript function in BUFFER."
|
|
1217 (set-buffer buffer)
|
|
1218 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1219 (let ((beg (progn (beginning-of-line 1) (point))))
|
|
1220 (forward-sexp)
|
|
1221 ;; keep including sexps as long as they
|
|
1222 ;; start with / or [.
|
|
1223 (if (looking-at "\\s-+\\(/\\|\\[\\)")
|
|
1224 (forward-sexp))
|
|
1225 (cons (buffer-substring beg (point)) beg))))
|
|
1226
|
|
1227 ;;; Specialised routine to get the next prolog fact/clause name in the buffer
|
|
1228 ;;; Laszlo Teleki <laszlo@ipb.uni-bonn.de>
|
|
1229 ;;;
|
|
1230 (defun fume-find-next-prolog-function-name (buffer)
|
|
1231 "Searches for the next prolog fact or clause in BUFFER."
|
|
1232 (set-buffer buffer)
|
|
1233 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1234 (let ((beg (progn (beginning-of-line 1) (point))))
|
|
1235 (forward-sexp)
|
|
1236 (cons (buffer-substring beg (point)) beg))))
|
|
1237
|
|
1238 ;;; Specialised routine to get the next bacis2 procedure name in the buffer
|
|
1239 ;;;
|
|
1240 (defun fume-find-next-bacis-function-name (buffer)
|
|
1241 "Searches for the next Bacis2 function in BUFFER"
|
|
1242 (set-buffer buffer)
|
|
1243 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1244 (let ((pos (point))
|
|
1245 (name (condition-case ()
|
|
1246 (funcall
|
|
1247 (symbol-function (intern "focus-get-function-name")))
|
|
1248 (error nil))))
|
|
1249 (if (null name)
|
|
1250 (fume-find-next-bacis-function-name buffer)
|
|
1251 ;; jump past possible function dbgid
|
|
1252 (re-search-forward
|
|
1253 (format "<<dbgid +\\s-*%s%s" name "\\s-*>>") nil t)
|
|
1254 (cons name pos)))))
|
|
1255
|
|
1256 ;;; Specialized routine to get the next Maple function name in the buffer
|
|
1257 ;;; Luc Tancredi <Luc.Tancredi@sophia.inria.fr>
|
|
1258 ;;;
|
|
1259 (defun fume-find-next-maple-function-name (buffer)
|
|
1260 "Searches for the next maple function in BUFFER"
|
|
1261 (set-buffer buffer)
|
|
1262 ;; Search for the function
|
|
1263 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1264 (let ((beg (progn (backward-up-list 1) (forward-sexp -2) (point))))
|
|
1265 (forward-sexp)
|
|
1266 (cons (buffer-substring beg (point)) beg))))
|
|
1267
|
|
1268 ;;; Specialised routine to get the next latex section name in the buffer
|
|
1269 ;;; Philippe Queinnec <queinnec@cenatls.cena.dgac.fr>
|
|
1270 ;;; Paolo Frasconi <paolo@mcculloch.ing.unifi.it>
|
|
1271 ;;;
|
|
1272 (defun fume-find-next-latex-section-name (buffer)
|
|
1273 "Searches for the next latex section in BUFFER."
|
|
1274 (set-buffer buffer)
|
|
1275 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1276 (let* ((secname (buffer-substring (match-beginning 1) (match-end 1)))
|
|
1277 (beg (match-beginning 4))
|
|
1278 (name (buffer-substring beg (match-end 4))))
|
|
1279 (cond ((string= secname "chapter")
|
|
1280 (setq fume-tex-chapter (1+ fume-tex-chapter)
|
|
1281 fume-tex-section 0
|
|
1282 fume-tex-subsection 0
|
|
1283 fume-tex-subsubsection 0
|
|
1284 name (concat fume-tex-chapter " " (upcase name))))
|
|
1285 ((string= secname "section")
|
|
1286 (setq fume-tex-section (1+ fume-tex-section)
|
|
1287 name (concat
|
|
1288 (if (> fume-tex-chapter 0)
|
|
1289 (concat fume-tex-chapter ".") "")
|
|
1290 fume-tex-section " " name)
|
|
1291 fume-tex-subsection 0
|
|
1292 fume-tex-subsubsection 0))
|
|
1293 ((string= secname "subsection")
|
|
1294 (setq fume-tex-subsection (1+ fume-tex-subsection)
|
|
1295 name (concat
|
|
1296 (if (> fume-tex-chapter 0)
|
|
1297 (concat fume-tex-chapter ".") "")
|
|
1298 fume-tex-section "."
|
|
1299 fume-tex-subsection " " name)
|
|
1300 fume-tex-subsubsection 0))
|
|
1301 ((string= secname "subsubsection")
|
|
1302 (setq fume-tex-subsubsection (1+ fume-tex-subsubsection)
|
|
1303 name (concat
|
|
1304 (if (> fume-tex-chapter 0)
|
|
1305 (concat fume-tex-chapter ".") "")
|
|
1306 fume-tex-section "."
|
|
1307 fume-tex-subsection "."
|
|
1308 fume-tex-subsubsection " " name)))
|
|
1309 ((string= secname "subsubsection")
|
|
1310 (setq name (concat " " name))))
|
|
1311 (cons name beg))))
|
|
1312
|
|
1313 ;;; Specialised routine to get the next ksh function in the buffer
|
|
1314 ;;; Philippe Bondono <bondono@vnet.ibm.com>
|
|
1315 ;;;
|
|
1316 (defun fume-find-next-ksh-function-name (buffer)
|
|
1317 "Searches for the ksh type function in BUFFER."
|
|
1318 (set-buffer buffer)
|
|
1319 ;; Search for the function
|
|
1320 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1321 (let (name
|
|
1322 (beg (match-beginning 0)))
|
|
1323 (cond ((re-search-backward "\\(^\\|\\s-\\)function\\s-" beg t)
|
|
1324 (re-search-forward
|
|
1325 "\\(function\\s-+\\)\\([A-Za-z_][A-Za-z_0-9]*\\)" nil t)
|
|
1326 (setq beg (match-beginning 2)
|
|
1327 name (buffer-substring beg (match-end 2))))
|
|
1328 (t
|
|
1329 (re-search-backward
|
|
1330 "\\(^\\|\\s-\\)\\([A-Za-z_][A-Za-z_0-9]*\\)" beg t)
|
|
1331 (setq beg (match-beginning 2)
|
|
1332 name (buffer-substring beg (match-end 2)))))
|
|
1333 (if (null name)
|
|
1334 (fume-find-next-ksh-function-name buffer)
|
|
1335 (end-of-line)
|
|
1336 (cons name beg)))))
|
|
1337
|
|
1338 ;;; Specialised routine to get the next Scheme function in the buffer
|
|
1339 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
1340 ;;;
|
|
1341 (defun fume-find-next-scheme-function (buffer)
|
|
1342 "Searches for the next Scheme function in BUFFER."
|
|
1343 (set-buffer buffer)
|
|
1344 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1345 (let ((beg (progn (if (looking-at "(") (forward-char 1)) (point)))
|
|
1346 (end (save-excursion (forward-sexp) (point))))
|
|
1347 (cons (buffer-substring beg end) beg))))
|
|
1348
|
|
1349 ;;; Specialised routine to get the next BibTeX citation in the buffer
|
|
1350 ;;; C. Michael Holloway <c.m.holloway@larc.nasa.gov>
|
|
1351 ;;;
|
|
1352 (defun fume-find-next-bibtex-citation (buffer)
|
|
1353 "Searches for the next BibTeX citation in BUFFER."
|
|
1354 (set-buffer buffer)
|
|
1355 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1356 (let ((beg (match-beginning 1))
|
|
1357 (end (match-end 1)))
|
|
1358 (cons (buffer-substring beg end) beg))))
|
|
1359
|
|
1360 ;;; Specialised routine to get the next SGML declaration in the buffer
|
|
1361 ;;; Thomas Plass <thomas.plass@mid-heidelberg.de>
|
|
1362 ;;;
|
|
1363 (defun fume-find-next-sgml-element-name (buffer)
|
|
1364 "Searches for the next SGML declaration in BUFFER."
|
|
1365 (set-buffer buffer)
|
|
1366 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1367 (let ((type (buffer-substring (match-beginning 1) (match-end 1)))
|
|
1368 (beg (match-beginning 2))
|
|
1369 (name (buffer-substring (match-beginning 2) (match-end 2))))
|
|
1370 (if (string= (downcase type) "element")
|
|
1371 (setq name (format "%-17s%3s" name "EL"))
|
|
1372 (setq name (format "%-17s%3s" name "ENT")))
|
|
1373 (cons name beg))))
|
|
1374
|
|
1375 ;;; Specialised routine to get the next ada function in the buffer
|
|
1376 ;;; Michael Polo <mikep@polo.mn.org> <mikep@cfsmo.honeywell.com>
|
|
1377 ;;;
|
|
1378 (defun fume-find-next-ada-function-name (buffer)
|
|
1379 "Searches for the next ada function in BUFFER."
|
|
1380 (set-buffer buffer)
|
|
1381 (if (re-search-forward (car fume-function-name-regexp-ada) nil t)
|
|
1382 (let ((beg (match-beginning (cdr fume-function-name-regexp-ada)))
|
|
1383 (end (match-end (cdr fume-function-name-regexp-ada))))
|
|
1384
|
|
1385 (if (looking-at fume-function-name-regexp-ada-ignore)
|
|
1386 (fume-find-next-ada-function-name buffer)
|
|
1387 (cons (buffer-substring beg end) beg)))))
|
|
1388
|
|
1389 ;;; Makefiles
|
|
1390 ;;; Paul Filipski & Anthony Girardin <{filipski,girardin}@blackhawk.com>
|
|
1391 ;;;
|
|
1392 (defun fume-find-next-function-name-make (buffer)
|
|
1393 "Searches for the next make item in BUFFER."
|
|
1394 (set-buffer buffer)
|
|
1395 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1396 (let ((beg (match-beginning 1))
|
|
1397 (end (match-end 1)))
|
|
1398 (cons (buffer-substring beg end) beg))))
|
|
1399
|
|
1400 ;;; Find next pascal function in the buffer
|
|
1401 ;;; Espen Skoglund <espensk@stud.cs.uit.no>
|
|
1402 ;;;
|
|
1403 (defun fume-find-next-pascal-function-name (buffer)
|
|
1404 "Searches for the next pascal procedure in BUFFER."
|
|
1405 (set-buffer buffer)
|
|
1406 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1407 (let ((beg (match-beginning 2))
|
|
1408 (end (match-end 2)))
|
|
1409 (cons (buffer-substring beg end) beg))))
|
|
1410
|
|
1411 ;;; Verilog support
|
|
1412 ;;; Matt Sale <mdsale@icdc.delcoelect.com>
|
|
1413 ;;;
|
|
1414 (defun fume-find-next-verilog-function-name (buffer)
|
|
1415 "Searches for the next verilog module in BUFFER."
|
|
1416 (set-buffer buffer)
|
|
1417 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1418 (let ((beg (match-beginning 2))
|
|
1419 (end (match-end 2)))
|
|
1420 (cons (buffer-substring beg end) beg))))
|
|
1421
|
82
|
1422 ;;; Specialised routine to get the next idl function in the buffer
|
|
1423 ;;;
|
|
1424 ;;; Lubos Pochman <lubos@rsinc.com>
|
|
1425 (defun fume-find-next-idl-function-name (buffer)
|
|
1426 "Searches for the next idl function in BUFFER."
|
|
1427 (set-buffer buffer)
|
|
1428 (if (re-search-forward (car fume-function-name-regexp-idl) nil t)
|
|
1429 (let ((beg (match-beginning (cdr fume-function-name-regexp-idl)))
|
|
1430 (end (match-end (cdr fume-function-name-regexp-idl))))
|
|
1431 (cons (buffer-substring beg end) beg))))
|
|
1432
|
|
1433
|
0
|
1434 ;;; Assembly
|
151
|
1435 ;;; Bob Weiner <weiner@altrasoft.com>
|
0
|
1436 ;;;
|
|
1437 (defun fume-find-next-asm-function-name (buffer)
|
|
1438 "Searches for the next assembler function in BUFFER."
|
|
1439 (set-buffer buffer)
|
|
1440 ;; Search for the function
|
|
1441 (if (re-search-forward fume-function-name-regexp nil t)
|
|
1442 (cons (buffer-substring (match-beginning 1) (match-end 1))
|
|
1443 (match-beginning 1))))
|
|
1444
|
|
1445 ;;; This is where you can hook in other languages which may need a different
|
|
1446 ;;; method to scan for function names. Otherwise, the default defun used is
|
|
1447 ;;; fume-find-next-function-name which is suitable for sexp-based languages
|
|
1448 ;;; such as C, C++ and elisp.
|
|
1449 ;;;
|
|
1450 (defconst fume-find-function-name-method-alist
|
|
1451 '((ada-mode . fume-find-next-ada-function-name)
|
|
1452 (alice-mode . fume-find-next-python-function-name)
|
|
1453 (asm-mode . fume-find-next-asm-function-name)
|
|
1454 (bacis-mode . fume-find-next-bacis-function-name)
|
|
1455 (bibtex-mode . fume-find-next-bibtex-citation)
|
|
1456 (c++-mode . fume-match-find-next-function-name)
|
|
1457 (c-mode . fume-find-next-c-function-name)
|
|
1458 (dired-mode . fume-find-next-directory-name)
|
|
1459 (ehdm-mode . fume-find-next-ehdm-entity)
|
|
1460 (fame-mode . fume-find-next-pascal-function-name)
|
|
1461 (fortran-mode . fume-find-next-fortran-function-name)
|
|
1462 (f90-mode . fume-find-next-fortran-function-name)
|
|
1463 (ksh-mode . fume-find-next-ksh-function-name)
|
|
1464 (latex-mode . fume-find-next-latex-section-name)
|
|
1465 (LaTeX-mode . fume-find-next-latex-section-name)
|
|
1466 (makefile-mode . fume-find-next-function-name-make)
|
|
1467 (maple-mode . fume-find-next-maple-function-name)
|
|
1468 (modula-2-mode . fume-find-next-modula-function-name)
|
|
1469 (modula-3-mode . fume-find-next-modula-function-name)
|
|
1470 (pascal-mode . fume-find-next-pascal-function-name)
|
|
1471 (perl-mode . fume-find-next-perl-function-name)
|
|
1472 (java-mode . fume-find-next-java-function-name)
|
|
1473 (postscript-mode . fume-find-next-postscript-function-name)
|
|
1474 (prolog-mode . fume-find-next-prolog-function-name)
|
|
1475 (pvs-mode . fume-find-next-pvs-entity)
|
|
1476 (python-mode . fume-find-next-python-function-name)
|
|
1477 (scheme-mode . fume-find-next-scheme-function)
|
|
1478 (sgml-mode . fume-find-next-sgml-element-name)
|
|
1479 (tcl-mode . fume-match-find-next-function-name)
|
|
1480 (verilog-mode . fume-find-next-verilog-function-name)
|
82
|
1481 (idl-mode . fume-find-next-idl-function-name)
|
0
|
1482 )
|
|
1483
|
|
1484 "The connection between a mode and the defun that finds function names.
|
|
1485 If no connection is in this alist for a given mode, a default method is used")
|
|
1486
|
|
1487 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1488 ;;;;;;;;;;;;;;;;;;;;;;;; General utility functions ;;;;;;;;;;;;;;;;;;;;;;;
|
|
1489 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1490
|
82
|
1491 ;;; modeline refresh routine
|
0
|
1492 ;;;
|
82
|
1493 (or (fboundp 'redraw-modeline)
|
|
1494 (defun redraw-modeline () (set-buffer-modified-p (buffer-modified-p))))
|
0
|
1495
|
|
1496 ;;; Smart mouse positioning
|
|
1497 ;;;
|
|
1498 (if (fboundp 'window-edges) ; old method
|
|
1499 (defun fume-set-mouse-position ()
|
|
1500 (set-mouse-position
|
|
1501 (selected-frame)
|
|
1502 (nth 0 (window-edges)) (nth 1 (window-edges))))
|
|
1503 (defun fume-set-mouse-position () ; new method
|
|
1504 (set-mouse-position
|
|
1505 (selected-window)
|
|
1506 (nth 0 (window-pixel-edges))
|
|
1507 (nth 1 (window-pixel-edges)))))
|
|
1508
|
|
1509 ;;; Sets 'fume-function-name-regexp' to something appropriate for the current
|
|
1510 ;;; mode for this buffer.
|
|
1511 ;;;
|
|
1512 (defun fume-set-defaults ()
|
|
1513 "Returns nil if unsuccessful in setting up buffer-local defaults.
|
|
1514 Otherwise returns fume-function-name-regexp"
|
|
1515 (setq fume-function-name-regexp
|
|
1516 (symbol-value
|
|
1517 (cdr-safe (assoc major-mode fume-function-name-regexp-alist))))
|
|
1518 (if fume-function-name-regexp
|
|
1519 (setq fume-find-next-function-name-method
|
|
1520 (or (cdr-safe (assoc major-mode
|
|
1521 fume-find-function-name-method-alist))
|
|
1522 'fume-find-next-function-name)))
|
|
1523 fume-function-name-regexp)
|
|
1524
|
|
1525 ;;; Routines to add/remove/update function menu from menubar
|
|
1526 ;;;
|
82
|
1527 (defun fume-add-menubar-entry ()
|
0
|
1528 (interactive)
|
|
1529 (save-window-excursion (function-menu t)))
|
|
1530
|
82
|
1531 (defun fume-remove-menubar-entry ()
|
0
|
1532 (interactive)
|
|
1533 (cond ((and fume-running-xemacs current-menubar)
|
|
1534 (delete-menu-item (list fume-menubar-menu-name))
|
|
1535 ;; force update of the menubar
|
82
|
1536 (redraw-modeline))))
|
0
|
1537
|
82
|
1538 (defun fume-update-menubar-entry ()
|
0
|
1539 "Returns t if menubar was updated. Nil otherwise"
|
|
1540 (and fume-running-xemacs
|
|
1541 fume-not-tty
|
|
1542 (assoc fume-menubar-menu-name current-menubar)
|
|
1543 (fume-add-menubar-entry)
|
|
1544 t))
|
|
1545
|
82
|
1546 (defun fume-trim-string (string)
|
0
|
1547 "Returns STRING with leading and trailing whitespace removed."
|
|
1548 (if (string-match "^[ \t]*" (setq string (format "%s" string)))
|
|
1549 (setq string (substring string (match-end 0))))
|
|
1550 (if (string-match "[ \t]*$" string)
|
|
1551 (setq string (substring string 0 (match-beginning 0))))
|
|
1552 string)
|
|
1553
|
|
1554 (defvar fume-syntax-table nil)
|
|
1555
|
82
|
1556 (defun fume-what-looking-at (&optional check-primary-selection-p)
|
|
1557 (or (and check-primary-selection-p
|
|
1558 primary-selection-extent
|
|
1559 (condition-case ()
|
|
1560 (prog1 (buffer-substring (region-beginning) (region-end))
|
|
1561 (and zmacs-regions (zmacs-deactivate-region) (sit-for 0)))
|
|
1562 (error nil)))
|
|
1563 (let (name
|
|
1564 (orig-syntax-table (copy-syntax-table (syntax-table))))
|
|
1565 (if fume-syntax-table
|
|
1566 ()
|
|
1567 (setq fume-syntax-table (copy-syntax-table))
|
|
1568 (modify-syntax-entry ?: "w" fume-syntax-table))
|
|
1569 (unwind-protect
|
|
1570 (progn
|
|
1571 (set-syntax-table fume-syntax-table)
|
|
1572 (save-excursion
|
|
1573 (while (looking-at "\\sw\\|\\s_") (forward-char 1))
|
|
1574 (if (re-search-backward "\\sw\\|\\s_" nil t)
|
|
1575 (let ((beg (progn (forward-char 1) (point))))
|
|
1576 (forward-sexp -1)
|
|
1577 (while (looking-at "\\s'") (forward-char 1))
|
|
1578 (setq name (buffer-substring beg (point)))))))
|
|
1579 (set-syntax-table orig-syntax-table)
|
|
1580 name))))
|
0
|
1581
|
82
|
1582 ;;; Find function name that point is in
|
|
1583 ;;; (trick is to start from the end)
|
0
|
1584 ;;;
|
82
|
1585 (defun fume-function-before-point ()
|
0
|
1586 (if (or fume-modeline-funclist (fume-rescan-buffer) fume-modeline-funclist)
|
82
|
1587 (let ((p (point)))
|
0
|
1588 (save-excursion
|
|
1589 (catch 'found
|
|
1590 (mapcar (function
|
82
|
1591 (lambda (x)
|
|
1592 (goto-char (cdr x))
|
0
|
1593 (beginning-of-line 1)
|
82
|
1594 (if (>= p (point)) (throw 'found (car x)))))
|
|
1595 fume-modeline-funclist) nil)))))
|
0
|
1596
|
|
1597 ;;; Routines to add a buffer local post command hook
|
|
1598 ;;;
|
82
|
1599 (defun fume-post-command-hook-p (hook)
|
0
|
1600 (memq hook (if fume-use-local-post-command-hook
|
|
1601 local-post-command-hook
|
|
1602 post-command-hook)))
|
|
1603
|
82
|
1604 (defun fume-add-post-command-hook (hook &optional append)
|
0
|
1605 (or (fume-post-command-hook-p hook)
|
|
1606 (cond (fume-use-local-post-command-hook
|
|
1607 (add-hook 'local-post-command-hook hook append))
|
|
1608 ((fboundp 'make-local-hook)
|
|
1609 (make-local-hook 'post-command-hook)
|
|
1610 (add-hook 'post-command-hook hook append t))
|
|
1611 (t
|
|
1612 ;; NOT make-variable-buffer-local
|
|
1613 (make-local-variable 'post-command-hook)
|
|
1614 (add-hook 'post-command-hook hook append)))))
|
|
1615
|
82
|
1616 (defun fume-remove-post-command-hook (hook)
|
0
|
1617 (and (fume-post-command-hook-p hook)
|
|
1618 (cond (fume-use-local-post-command-hook
|
|
1619 (remove-hook 'local-post-command-hook hook))
|
|
1620 ((fboundp 'make-local-hook)
|
|
1621 (remove-hook 'post-command-hook hook t))
|
|
1622 (t
|
|
1623 (remove-hook 'post-command-hook hook)))))
|
|
1624
|
|
1625 ;;; Routine to install the modeline feature
|
|
1626 ;;;
|
82
|
1627 (defun fume-maybe-install-modeline-feature ()
|
0
|
1628 (cond ((and fume-display-in-modeline-p (fume-set-defaults))
|
|
1629 (or fume-modeline-funclist
|
|
1630 (fume-post-command-hook-p 'fume-tickle-modeline)
|
|
1631 (fume-rescan-buffer))
|
|
1632 (fume-add-post-command-hook 'fume-tickle-modeline)
|
|
1633 (fume-remove-post-command-hook 'fume-maybe-install-modeline-feature)
|
|
1634 (fume-tickle-modeline-1)
|
|
1635 (fume-tickle-modeline)
|
|
1636 t ; return success flag
|
|
1637 )))
|
|
1638
|
|
1639 (defun fume-toggle-modeline-display ()
|
|
1640 "Toggles whether func-menu displays function names in the modeline"
|
|
1641 (interactive)
|
|
1642 (setq fume-display-in-modeline-p (not fume-display-in-modeline-p))
|
|
1643 (if (interactive-p) (fume-tickle-modeline)))
|
|
1644
|
|
1645 ;;; Routine to display function before point in the modeline
|
|
1646 ;;;
|
|
1647 (defun fume-tickle-modeline ()
|
|
1648 (let ((fname (and fume-display-in-modeline-p (fume-function-before-point))))
|
|
1649 (set fume-modeline-buffer-identification
|
|
1650 (cond ((and fume-display-in-modeline-p (not (null fname)))
|
|
1651 (setq fname (format "`%s'" (fume-trim-string fname)))
|
|
1652 (if (eq fume-display-in-modeline-p t)
|
|
1653 (list fume-modeline-buffer-identification-1 " " fname)
|
|
1654 fname))
|
|
1655 (t
|
|
1656 fume-modeline-buffer-identification-0))))
|
|
1657 (cond ((not fume-display-in-modeline-p)
|
|
1658 (fume-remove-post-command-hook 'fume-tickle-modeline)
|
|
1659 (fume-add-post-command-hook 'fume-maybe-install-modeline-feature)))
|
82
|
1660 ;; force update of the modeline
|
|
1661 (redraw-modeline))
|
0
|
1662
|
|
1663 (fume-defvar-local fume-modeline-buffer-identification-0 nil
|
|
1664 "Storage for original modeline-buffer-identification")
|
|
1665
|
|
1666 (fume-defvar-local fume-modeline-buffer-identification-1 nil
|
|
1667 "Storage for munged modeline-buffer-identification")
|
|
1668
|
|
1669 (defun fume-tickle-f-to-b (str)
|
|
1670 ;; Change modeline format of "XEmacs: %f" to "XEmacs: %b" in order to make
|
|
1671 ;; extra room for the function name which is going to be appended to the
|
|
1672 ;; modeline-buffer-identification component of the modeline-format.
|
|
1673 (cond ((consp str)
|
|
1674 (if (extentp (car str))
|
|
1675 (cons (car str)
|
|
1676 (fume-tickle-f-to-b (cdr str)))
|
|
1677 (mapcar (function fume-tickle-f-to-b) str)))
|
|
1678 ((not (stringp str))
|
|
1679 str)
|
|
1680 ((string-match "%[0-9]*f" str)
|
|
1681 (let ((newstr (copy-sequence str)))
|
|
1682 (aset newstr (1- (match-end 0)) (string-to-char "b"))
|
|
1683 newstr))
|
|
1684 (t str)))
|
|
1685
|
|
1686 (defun fume-tickle-modeline-1 ()
|
|
1687 (or fume-modeline-buffer-identification-0
|
|
1688 (setq fume-modeline-buffer-identification-0
|
|
1689 (symbol-value fume-modeline-buffer-identification)))
|
|
1690 (setq fume-modeline-buffer-identification-1
|
|
1691 (fume-tickle-f-to-b fume-modeline-buffer-identification-0)))
|
|
1692
|
|
1693 ;;; Routine to toggle auto recanning of the buffer
|
|
1694 (defun fume-toggle-auto-rescanning ()
|
|
1695 (interactive)
|
|
1696 (message "Func-Menu buffer auto-rescanning turned %s"
|
|
1697 (if (setq fume-auto-rescan-buffer-p (not fume-auto-rescan-buffer-p))
|
|
1698 "ON" "OFF"))
|
|
1699 (sit-for 0))
|
|
1700
|
|
1701 ;;; Routine to create a shallow separate copy of a list
|
|
1702 ;;;
|
|
1703 (if (fboundp 'copy-tree) ; not built-in in all emacsen
|
|
1704 (defalias 'fume-shallow-copy-list 'copy-tree)
|
|
1705 (defun fume-shallow-copy-list (list)
|
|
1706 (mapcar (function (lambda (i) (cons (car i) (cdr i)))) list)))
|
|
1707
|
|
1708 ;;; Sort function to sort items depending on their function-name
|
|
1709 ;;; An item looks like (NAME . POSITION).
|
|
1710 ;;;
|
82
|
1711 (defun fume-sort-by-name (item1 item2)
|
0
|
1712 (or (string-lessp (car item1) (car item2))
|
|
1713 (string-equal (car item1) (car item2))))
|
|
1714
|
|
1715 ;;; Sort function to sort items depending on their position
|
|
1716 ;;;
|
82
|
1717 (defun fume-sort-by-position (item1 item2)
|
0
|
1718 (<= (cdr item1) (cdr item2)))
|
|
1719
|
|
1720 ;;; Support function to calculate relative position in buffer
|
|
1721 ;;;
|
82
|
1722 (defun fume-relative-position ()
|
0
|
1723 (let ((pos (point))
|
|
1724 (total (buffer-size)))
|
|
1725 (if (> total 50000)
|
|
1726 ;; Avoid overflow from multiplying by 100!
|
|
1727 (/ (1- pos) (max (/ total 100) 1))
|
|
1728 (/ (* 100 (1- pos))
|
|
1729 (max total 1)))))
|
|
1730
|
|
1731 ;;; Split LIST into sublists of max length N
|
|
1732 ;;; Example (fume-split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8))
|
|
1733 ;;;
|
82
|
1734 (defun fume-split (list n)
|
0
|
1735 (let ((i 0)
|
|
1736 result
|
|
1737 sublist
|
|
1738 (remain list))
|
|
1739 (while remain
|
|
1740 (if (= n (setq sublist (cons (car remain) sublist)
|
|
1741 remain (cdr remain)
|
|
1742 i (1+ i)))
|
|
1743 ;; We have finished a sublist
|
|
1744 (setq result (cons (nreverse sublist) result)
|
|
1745 sublist nil
|
|
1746 i 0)))
|
|
1747 ;; There might be a sublist (if the length of LIST mod n is != 0)
|
|
1748 ;; that has to be added to the result list.
|
|
1749 (if sublist
|
|
1750 (setq result (cons (nreverse sublist) result)))
|
|
1751 (nreverse result)))
|
|
1752
|
|
1753 ;;; Routines to create indexes for submenus
|
|
1754 ;;;
|
|
1755
|
|
1756 ;;; Method 0
|
|
1757 ;;;
|
|
1758 (defun fume-index-sublist-method-0 (sublist count)
|
|
1759 (concat "Function sublist #" count))
|
|
1760
|
|
1761 ;;; Method 1
|
|
1762 ;;; Thomas Plass <thomas.plass@mid-heidelberg.de>
|
|
1763 ;;;
|
|
1764 (defun fume-index-sublist-method-1 (sublist &rest count)
|
|
1765 (interactive)
|
|
1766 (let ((s (substring (car (car sublist)) 0 1))
|
|
1767 (e (substring (car (nth (1- (length sublist)) sublist)) 0 1)))
|
|
1768 (format "Function sublist (%s%s)"
|
|
1769 s (if (string-equal s e) "<>" (format "<>-%s<>" e)))))
|
|
1770
|
|
1771 ;;; Method 2
|
|
1772 ;;; Paul Filipski & Anthony Girardin <{filipski,girardin}@blackhawk.com>
|
|
1773 ;;;
|
|
1774 (defun fume-index-sublist-method-2 (sublist &rest count)
|
|
1775 (let ((s (substring (car (car sublist))
|
|
1776 0
|
|
1777 (min (length (car (car sublist))) 12)))
|
|
1778 (e (substring (car (nth (1- (length sublist)) sublist))
|
|
1779 0
|
|
1780 (min (length (car (nth (1- (length sublist)) sublist)))
|
|
1781 12))))
|
|
1782 (format "%s%s" s (if (string-equal s e) "<>" (format "<> ... %s<>" e)))))
|
|
1783
|
|
1784 ;;; Method 3
|
|
1785 ;;;
|
|
1786 (defun fume-index-sublist-method-3-1 (sublist ix limit)
|
|
1787 (let ((s1 (substring (car (car sublist)) 0 (min limit ix)))
|
|
1788 (s2 (substring
|
|
1789 (car (nth (1- (length sublist)) sublist))
|
|
1790 0 (min (length (car (nth (1- (length sublist)) sublist))) ix))))
|
|
1791 (cons s1 s2)))
|
|
1792
|
|
1793 (defun fume-index-sublist-method-3 (sublist &rest count)
|
|
1794 (let* ((cmplength 12)
|
|
1795 (limit (length (car (car sublist))))
|
|
1796 (result (fume-index-sublist-method-3-1 sublist cmplength limit))
|
|
1797 (str1 (car result))
|
|
1798 (str2 (cdr result)))
|
|
1799 (while (and (string-equal str1 str2) (< cmplength limit))
|
|
1800 (setq cmplength (1+ cmplength)
|
|
1801 result (fume-index-sublist-method-3-1 sublist cmplength limit)
|
|
1802 str1 (car result)
|
|
1803 str2 (cdr result)))
|
|
1804 (cond ((not (string-equal str1 str2))
|
|
1805 (format "%s<> ... %s<>" str1 str2))
|
|
1806 ((< cmplength limit)
|
|
1807 (format "%s<>" str1))
|
|
1808 (t
|
|
1809 (format "%s ..." str1)))))
|
|
1810
|
|
1811 ;;; Buffer rescanning
|
|
1812 ;;;
|
|
1813 (defun fume-rescan-buffer-trigger ()
|
|
1814 "Automatically spots when a buffer rescan becomes necessary"
|
|
1815 (if fume-auto-rescan-buffer-p
|
|
1816 (if (> fume-rescan-trigger-counter 0)
|
|
1817 (setq fume-rescan-trigger-counter (1- fume-rescan-trigger-counter))
|
|
1818 (setq fume-rescan-trigger-counter
|
100
|
1819 (max fume-rescan-trigger-counter-min
|
|
1820 (/ (buffer-size) fume-rescan-trigger-counter-buffer-size)))
|
0
|
1821 (if (or fume-funclist-dirty-p
|
|
1822 (save-excursion
|
|
1823 (let (find fnam)
|
|
1824 (condition-case ()
|
|
1825 (and fume-function-name-regexp
|
|
1826 (setq fnam (fume-function-before-point))
|
|
1827 (setq find (symbol-value
|
|
1828 'fume-find-next-function-name-method))
|
|
1829 (progn (end-of-line 1)
|
|
1830 (re-search-backward
|
|
1831 fume-function-name-regexp nil t))
|
|
1832 (if (eq find 'fume-find-next-latex-section-name)
|
|
1833 (let ((lnam
|
|
1834 (car (fume-find-next-latex-section-name
|
|
1835 (current-buffer)))))
|
|
1836 (fume-tex-rescan-buffer-hook)
|
|
1837 (not (string-equal
|
|
1838 (substring fnam
|
|
1839 (string-match " " fnam))
|
|
1840 (substring lnam
|
|
1841 (string-match " " lnam)))))
|
|
1842 (not (string-equal
|
|
1843 fnam
|
|
1844 (car (funcall find (current-buffer)))))))
|
|
1845 (error nil)))))
|
|
1846 (let ((fume-scanning-message nil))
|
|
1847 (fume-rescan-buffer))))))
|
|
1848
|
82
|
1849 (defun fume-install-rescan-buffer-trigger ()
|
0
|
1850 (cond ((not (fume-post-command-hook-p 'fume-rescan-buffer-trigger))
|
|
1851 (fume-add-post-command-hook 'fume-rescan-buffer-trigger 'append)
|
|
1852 ;; Make narrow-to-region tickle func-menu
|
|
1853 (or (fboundp 'fume-narrow-to-region)
|
|
1854 (fset 'fume-narrow-to-region
|
|
1855 (symbol-function 'narrow-to-region)))
|
|
1856 (defun narrow-to-region (b e)
|
|
1857 "Restrict editing in this buffer to the current region.
|
|
1858 The rest of the text becomes temporarily invisible and untouchable
|
|
1859 but is not deleted; if you save the buffer in a file, the invisible
|
|
1860 text is included in the file. C-x n w makes all visible again.
|
|
1861 See also `save-restriction'.
|
|
1862
|
|
1863 When calling from a program, pass two arguments; positions (integers
|
|
1864 or markers) bounding the text that should remain visible"
|
|
1865 (interactive "r")
|
|
1866 (fume-narrow-to-region b e)
|
|
1867 (if fume-funclist (setq fume-funclist-dirty-p t)))
|
|
1868 ;; Make widen tickle func-menu
|
|
1869 (or (fboundp 'fume-widen)
|
|
1870 (fset 'fume-widen (symbol-function 'widen)))
|
|
1871 (defun widen ()
|
|
1872 "Remove restrictions (narrowing) from current buffer.
|
|
1873 This allows the buffer's full text to be seen and edited."
|
|
1874 (interactive)
|
|
1875 (fume-widen)
|
|
1876 (if fume-funclist (setq fume-funclist-dirty-p t))))))
|
|
1877
|
|
1878 (defun fume-rescan-buffer (&optional popmenu)
|
|
1879 "Rescans the buffer for function names.
|
|
1880 If optional arg POPMENU is non-nil, brings up the function-menu."
|
|
1881 (interactive)
|
|
1882 (let ((find (symbol-value 'fume-find-next-function-name-method))
|
|
1883 (fnam)
|
|
1884 (flst '())
|
|
1885 (buffer-to-scan (current-buffer)))
|
|
1886 (save-excursion
|
|
1887 (goto-char (point-min))
|
|
1888 (cond (fume-scanning-message
|
|
1889 (message fume-scanning-message 0))
|
|
1890 (fume-rescanning-message
|
|
1891 (message fume-rescanning-message)))
|
|
1892 (while (setq fnam
|
|
1893 (condition-case ()
|
|
1894 (funcall find buffer-to-scan)
|
|
1895 (error
|
|
1896 ;; test for more possible fns after this error trap
|
|
1897 (if (consp fume-function-name-regexp)
|
|
1898 (save-excursion
|
|
1899 (re-search-forward
|
|
1900 (car fume-function-name-regexp) nil t))
|
|
1901 (and fume-function-name-regexp
|
|
1902 (save-excursion
|
|
1903 (re-search-forward
|
|
1904 fume-function-name-regexp nil t)))))))
|
|
1905 (cond ((listp fnam)
|
|
1906 (setq flst (cons fnam flst))
|
|
1907 (if fume-found-function-hook
|
|
1908 (save-excursion (run-hooks 'fume-found-function-hook)))))
|
|
1909 (if fume-scanning-message
|
|
1910 (message fume-scanning-message (fume-relative-position))))
|
|
1911 (cond (fume-scanning-message
|
|
1912 (message "%s done" (format fume-scanning-message 100)))
|
|
1913 (fume-rescanning-message
|
|
1914 (message "%s done" fume-rescanning-message)))
|
|
1915 ;; make a copy of flst sorted by position in buffer
|
|
1916 (setq fume-modeline-funclist
|
|
1917 (nreverse
|
|
1918 (sort (fume-shallow-copy-list flst) 'fume-sort-by-position)))
|
|
1919 (if fume-sort-function
|
|
1920 (setq fume-funclist (sort flst fume-sort-function))
|
|
1921 (setq fume-funclist (nreverse flst)))
|
|
1922 (if fume-rescan-buffer-hook
|
|
1923 (run-hooks 'fume-rescan-buffer-hook))))
|
|
1924 (if popmenu
|
|
1925 (function-menu)
|
|
1926 (let ((fume-rescan-inhibit-p t))
|
|
1927 (fume-update-menubar-entry)))
|
|
1928 ;; Reset dirty flag
|
|
1929 (setq fume-funclist-dirty-p nil))
|
|
1930
|
82
|
1931 (defun fume-scan-buffer ()
|
|
1932 (or fume-funclist (progn (fume-set-defaults) (fume-rescan-buffer))))
|
|
1933
|
0
|
1934 ;;; Routine to position cursor
|
|
1935 ;;;
|
|
1936 (defun fume-goto-function (fn pos)
|
|
1937 "Position cursor at function FN at location POS"
|
|
1938 (let ((orig-pos (point))
|
|
1939 (case-fold-search nil)
|
|
1940 (match-fn (cond ((string-match "DEFUN " fn) ; Emacs DEFUN declaration
|
|
1941 (substring fn (match-end 0)))
|
|
1942 ((string-match "^[ \t]*" fn) ; strip leading spaces
|
|
1943 (substring fn (match-end 0)))
|
|
1944 (t
|
|
1945 fn))))
|
|
1946
|
|
1947 (save-excursion
|
|
1948 (goto-char pos)
|
|
1949 (or (looking-at match-fn)
|
|
1950 (let ((fume-scanning-message nil))
|
|
1951 (fume-rescan-buffer)
|
|
1952 (setq pos (cdr-safe (assoc fn fume-funclist))))))
|
|
1953
|
|
1954 (if pos
|
|
1955 (progn
|
|
1956 (goto-char pos)
|
|
1957 ;; possibly set mark
|
|
1958 (or (= orig-pos (point))
|
|
1959 (push-mark orig-pos (null fume-scanning-message)))
|
|
1960 (if (numberp fume-fn-window-position)
|
|
1961 (set-window-start
|
|
1962 (selected-window)
|
|
1963 (save-excursion
|
|
1964 (beginning-of-line
|
|
1965 (- 1 (min (- (window-height) 2) fume-fn-window-position)))
|
|
1966 (point)))
|
|
1967 (recenter)))
|
|
1968 (ding)
|
|
1969 (message "%s not found" fn)
|
|
1970 (function-menu))))
|
|
1971
|
|
1972 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1973 ;;;;;;;;;;;;;;;;;; The main entry points for this package ;;;;;;;;;;;;;;;;
|
|
1974 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1975
|
|
1976 ;;; Interface to function-menu for mouse bindings only
|
|
1977 ;;;
|
|
1978 (defun mouse-function-menu (event)
|
|
1979 "Wrapper for mouse button bindings for function-menu"
|
|
1980 (interactive "e")
|
|
1981 (let ((currwin (selected-window)))
|
|
1982 (condition-case ()
|
|
1983 (progn
|
|
1984 (select-window (fume-event-window event))
|
|
1985 (let ((fume-auto-position-popup nil))
|
|
1986 (call-interactively 'function-menu)))
|
|
1987 (error (select-window currwin)))))
|
|
1988
|
|
1989 ;;; Interface for Key bindings
|
|
1990 ;;;
|
82
|
1991 (defun function-menu (&optional use-menubar return-only)
|
0
|
1992 "Pop up a menu of functions for selection with the mouse.
|
82
|
1993 Jumps to the selected function. A mark is set at the old position,
|
|
1994 so you can easily go back with C-u \\[set-mark-command].
|
0
|
1995
|
|
1996 With a prefix arg adds the menu to the current menubar.
|
82
|
1997 Optional second argument, RETURN-ONLY if non-nil simply returns
|
|
1998 the basic menu of functions."
|
0
|
1999 (interactive "P")
|
|
2000
|
|
2001 (setq use-menubar
|
|
2002 (and use-menubar fume-running-xemacs fume-not-tty current-menubar))
|
|
2003
|
|
2004 (catch 'no-functions
|
|
2005 (or (fume-set-defaults)
|
|
2006 (if (not (interactive-p))
|
|
2007 (throw 'no-functions t)
|
|
2008 (error "func-menu does not support the mode \"%s\"" mode-name)))
|
|
2009
|
|
2010 ;; Create a list for this buffer only if there isn't any.
|
|
2011 (or fume-funclist
|
|
2012 (if fume-rescan-inhibit-p
|
|
2013 (fume-remove-menubar-entry)
|
|
2014 (fume-rescan-buffer)))
|
|
2015 (or fume-funclist
|
|
2016 (if (not (interactive-p))
|
|
2017 (throw 'no-functions t)
|
|
2018 (error "No functions found in this buffer.")))
|
|
2019
|
|
2020 ;; Rescan buffer trigger
|
|
2021 (fume-install-rescan-buffer-trigger)
|
|
2022
|
|
2023 ;; Function name in modeline
|
|
2024 (fume-maybe-install-modeline-feature)
|
|
2025
|
|
2026 ;; The rest of this routine works only for (Lucid) XEmacs
|
|
2027 (cond (fume-running-xemacs
|
|
2028 ;; Create the menu
|
|
2029 (let* ((count 0)
|
|
2030 (index-method
|
|
2031 (intern (format "fume-index-sublist-method-%d"
|
|
2032 fume-index-method)))
|
|
2033 function-menu
|
|
2034 (function-menu-items
|
|
2035 (mapcar
|
|
2036 (function
|
|
2037 (lambda (sublist)
|
|
2038 (setq count (1+ count))
|
|
2039 (cons (format "%s"
|
|
2040 (funcall index-method sublist count))
|
|
2041 (mapcar
|
|
2042 (function
|
|
2043 (lambda (menu)
|
|
2044 (vector (format "%s" (car menu))
|
|
2045 (list 'fume-goto-function
|
|
2046 (car menu) (cdr menu))
|
|
2047 t)))
|
|
2048 sublist))))
|
|
2049 (fume-split fume-funclist fume-max-items))))
|
|
2050
|
|
2051 (or (> count 1)
|
|
2052 (setq function-menu-items (cdr (car function-menu-items))))
|
|
2053
|
82
|
2054 (if return-only
|
|
2055 nil
|
|
2056 (setq function-menu
|
|
2057 (` ((,@ function-menu-items)
|
|
2058 "----"
|
|
2059 ["Display full list of functions"
|
|
2060 fume-list-functions t]
|
|
2061 [(, (concat "Rescan buffer : " (buffer-name)))
|
|
2062 (fume-rescan-buffer (, (null use-menubar))) t]
|
|
2063 "----"
|
|
2064 ["Toggle modeline display"
|
|
2065 fume-toggle-modeline-display t]
|
|
2066 ["Toggle buffer auto rescanning"
|
|
2067 fume-toggle-auto-rescanning t]
|
|
2068 ["About Func-Menu" fume-about t])))
|
0
|
2069
|
82
|
2070 (cond (use-menubar
|
|
2071 (fume-remove-menubar-entry)
|
|
2072 (set-buffer-menubar (copy-sequence current-menubar))
|
|
2073 (fume-add-submenu
|
|
2074 fume-menubar-menu-name
|
|
2075 (` ((,@ function-menu)
|
|
2076 "----"
|
|
2077 ["Remove Function Menu from menubar"
|
|
2078 fume-remove-menubar-entry t]))
|
|
2079 fume-menubar-menu-location))
|
0
|
2080
|
82
|
2081 ((and fume-not-tty ; trap tty segmentation faults...
|
|
2082 (not (popup-menu-up-p)))
|
|
2083 (or (fume-update-menubar-entry)
|
|
2084 (setq function-menu
|
|
2085 (cons
|
|
2086 ["Put Function Menu into menubar"
|
|
2087 (function-menu t) t]
|
|
2088 (cons "----" function-menu))))
|
0
|
2089
|
82
|
2090 (if fume-auto-position-popup
|
|
2091 (fume-set-mouse-position))
|
0
|
2092
|
82
|
2093 (popup-menu
|
|
2094 (cons fume-menubar-menu-name function-menu)))))
|
|
2095
|
|
2096 ;; Return basic function menu for display by another function
|
|
2097 function-menu-items)))))
|
0
|
2098
|
|
2099 (defun fume-mouse-function-goto (event)
|
|
2100 "Goto function clicked on or prompt in minibuffer (with completion)."
|
|
2101 (interactive "@e")
|
82
|
2102 (let ((orig-pos (point)))
|
|
2103 (goto-char (event-point event))
|
|
2104 (let ((fume-no-prompt-on-valid-default t))
|
|
2105 (fume-prompt-function-goto))
|
|
2106 (or (= orig-pos (point))
|
|
2107 (push-mark orig-pos (null fume-scanning-message)))))
|
0
|
2108
|
|
2109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2110 ;;;;;;;;;;;;;;;; Keyboard access to func-menu for tty users ;;;;;;;;;;;;;;
|
|
2111 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2112
|
|
2113 ;;; Internal variables only
|
|
2114 ;;;
|
|
2115 (defvar fume-list-srcbuffer nil)
|
|
2116 (defvar fume-list-reused-win-p nil)
|
|
2117 (defvar fume-list-trampled-buffer nil)
|
|
2118
|
|
2119 ;;; Espen Skoglund <espensk@stud.cs.uit.no>
|
151
|
2120 ;;; David Hughes <d.hughes@videonetworks.com>
|
0
|
2121 ;;;
|
|
2122 (defun fume-prompt-function-goto (&optional other-window-p)
|
|
2123 "Goto function prompted for in minibuffer (with completion).
|
|
2124 With prefix arg, jumps to function in a different window."
|
|
2125 (interactive "P")
|
82
|
2126 (let* ((default-name (fume-what-looking-at t))
|
0
|
2127 (OrigBuffer (current-buffer))
|
82
|
2128 (flistMode (eq major-mode 'fume-list-mode))
|
|
2129 (no-prompt (or flistMode fume-no-prompt-on-valid-default))
|
|
2130 (TargetBuffer (if flistMode fume-list-srcbuffer OrigBuffer)))
|
0
|
2131 (switch-to-buffer TargetBuffer)
|
82
|
2132 (fume-scan-buffer) ;; Create funclist and set defaults if required
|
0
|
2133 (let* (;; verify default-name is a valid function name
|
|
2134 (default-exists-p (assoc default-name fume-funclist))
|
|
2135 ;; Prompt for function name in minibuffer, unless there is a valid
|
|
2136 ;; function name at point & fume-no-prompt-on-valid-default set to t
|
|
2137 (function-name
|
82
|
2138 (if (and default-exists-p no-prompt)
|
0
|
2139 ""
|
82
|
2140 (let ((this-command last-command)) ; preserve last-command
|
|
2141 (completing-read
|
|
2142 (format "Goto function%s%s: "
|
|
2143 (if other-window-p " other window" "")
|
|
2144 (if default-exists-p
|
|
2145 (concat " (" default-name ")")
|
|
2146 ""))
|
|
2147 fume-funclist nil t))))
|
0
|
2148 ;; Use default function name if just RET was pressed
|
|
2149 (function-name (if (and default-exists-p (string= "" function-name))
|
|
2150 default-name
|
|
2151 function-name)))
|
|
2152 (switch-to-buffer OrigBuffer)
|
|
2153 ;; Goto function or just return if function name is empty string
|
|
2154 (cond ((not (string= "" function-name))
|
|
2155 (if other-window-p
|
|
2156 (cond ((prog1 (one-window-p)
|
82
|
2157 (if (not (windowp other-window-p))
|
|
2158 (switch-to-buffer-other-window TargetBuffer)
|
|
2159 (select-window other-window-p)
|
|
2160 (switch-to-buffer TargetBuffer)))
|
0
|
2161 (other-window 1)
|
|
2162 (shrink-window-if-larger-than-buffer)
|
|
2163 (other-window 1)))
|
|
2164 (switch-to-buffer TargetBuffer))
|
|
2165 (fume-goto-function
|
|
2166 function-name (cdr (assoc function-name fume-funclist))))))))
|
|
2167
|
|
2168 (defun fume-prompt-function-goto-one-window ()
|
|
2169 (interactive)
|
|
2170 (delete-other-windows)
|
|
2171 (fume-prompt-function-goto))
|
|
2172
|
|
2173 (defun fume-prompt-function-goto-other-window ()
|
|
2174 (interactive)
|
82
|
2175 (fume-prompt-function-goto t))
|
0
|
2176
|
82
|
2177 (defun fume-list-functions-show-fn-other-window (&optional window)
|
0
|
2178 (interactive)
|
|
2179 (beginning-of-line)
|
|
2180 (select-window
|
82
|
2181 (prog1 (selected-window) (fume-prompt-function-goto (or window t)))))
|
0
|
2182
|
82
|
2183 (defun fume-list-functions-show-prev-fn-other-window (&optional window)
|
0
|
2184 (interactive)
|
|
2185 (forward-line -1)
|
82
|
2186 (fume-list-functions-show-fn-other-window window))
|
0
|
2187
|
82
|
2188 (defun fume-list-functions-show-next-fn-other-window (&optional window)
|
0
|
2189 (interactive)
|
|
2190 (forward-line 1)
|
|
2191 (beginning-of-line)
|
82
|
2192 (fume-list-functions-show-fn-other-window window))
|
0
|
2193
|
|
2194 (defun fume-list-functions-help ()
|
|
2195 (interactive)
|
|
2196 (fume-about)
|
|
2197 (sit-for 1)
|
|
2198 (message "SPC=%s, p=%s, n=%s, o=%s, G=%s, RET=%s, q=%s"
|
|
2199 "this"
|
|
2200 "previous"
|
|
2201 "next"
|
|
2202 "other win"
|
|
2203 "one win"
|
|
2204 "this win"
|
|
2205 "quit"))
|
|
2206
|
|
2207 (defun fume-list-functions-quit ()
|
|
2208 (interactive)
|
|
2209 (if (eq major-mode 'fume-list-mode)
|
|
2210 (kill-buffer (current-buffer)))
|
|
2211 (if fume-list-reused-win-p
|
|
2212 (condition-case ()
|
|
2213 (switch-to-buffer fume-list-trampled-buffer)
|
|
2214 (error nil))
|
|
2215 (or (one-window-p)
|
|
2216 (delete-window (selected-window))))
|
|
2217 (if (not (eq (current-buffer) fume-list-srcbuffer))
|
|
2218 (condition-case ()
|
|
2219 (select-window (get-buffer-window fume-list-srcbuffer))
|
|
2220 (error
|
|
2221 (condition-case ()
|
|
2222 (switch-to-buffer fume-list-srcbuffer)
|
|
2223 (error nil))))))
|
|
2224
|
|
2225 (defun fume-list-mouse-select (event)
|
|
2226 (interactive "e")
|
|
2227 (let (ws cb cp (wc (current-window-configuration)))
|
|
2228 (mouse-set-point event)
|
|
2229 (fume-prompt-function-goto-other-window)
|
|
2230 (setq ws (save-excursion
|
|
2231 (beginning-of-line (- 1 fume-fn-window-position)) (point))
|
|
2232 cb (current-buffer)
|
|
2233 cp (point))
|
|
2234 (set-window-configuration wc)
|
|
2235 (switch-to-buffer cb)
|
|
2236 (set-window-start (selected-window) ws)
|
|
2237 (goto-char cp)))
|
|
2238
|
|
2239 (defvar fume-list-mode-map nil)
|
|
2240 (or fume-list-mode-map
|
|
2241 (let ((map (make-sparse-keymap)))
|
|
2242 (define-key map "q" 'fume-list-functions-quit)
|
|
2243 (define-key map "h" 'fume-list-functions-help)
|
|
2244 (define-key map "?" 'fume-list-functions-help)
|
|
2245 (define-key map "g" 'fume-prompt-function-goto)
|
|
2246 (define-key map "\C-m" 'fume-prompt-function-goto)
|
|
2247 (define-key map "G" 'fume-prompt-function-goto-one-window)
|
|
2248 (define-key map "o" 'fume-prompt-function-goto-other-window)
|
|
2249 (define-key map " " 'fume-list-functions-show-fn-other-window)
|
|
2250 (define-key map "p" 'fume-list-functions-show-prev-fn-other-window)
|
|
2251 (define-key map "n" 'fume-list-functions-show-next-fn-other-window)
|
|
2252 (if fume-not-tty
|
|
2253 (define-key map [(button2)] 'fume-list-mouse-select))
|
|
2254 (setq fume-list-mode-map map)))
|
|
2255
|
|
2256 (defvar fume-list-mode-hook nil "*Hook to run after fume-list-mode entered")
|
|
2257
|
|
2258 (defun fume-list-functions (&optional this-window)
|
|
2259 "Creates a temporary buffer listing functions found in the current buffer"
|
|
2260 (interactive "P")
|
82
|
2261 (fume-scan-buffer) ;; Create funclist and set defaults if required
|
0
|
2262 (let ((func-near-point (format "^%s$" (fume-function-before-point))))
|
|
2263 (cond ((or fume-function-name-regexp (fume-maybe-install-modeline-feature))
|
|
2264 (save-excursion
|
|
2265 (let ((srcbuffer (current-buffer)))
|
|
2266 (set-buffer (get-buffer-create fume-buffer-name))
|
|
2267 (let (buffer-read-only) (erase-buffer))
|
|
2268 (use-local-map fume-list-mode-map)
|
|
2269 (setq buffer-read-only t
|
|
2270 mode-name "Func-Menu"
|
|
2271 major-mode 'fume-list-mode
|
|
2272 fume-list-srcbuffer srcbuffer
|
|
2273 fume-list-reused-win-p (not (one-window-p)))
|
|
2274 (if fume-not-tty
|
|
2275 (setq mode-motion-hook 'mode-motion-highlight-symbol))
|
|
2276 (run-hooks 'fume-list-mode-hook)))
|
|
2277 (or fume-funclist (fume-rescan-buffer))
|
|
2278 (if fume-funclist
|
|
2279 (mapcar (function
|
|
2280 (lambda (p)
|
|
2281 (save-excursion
|
|
2282 (set-buffer fume-buffer-name)
|
|
2283 (let (buffer-read-only)
|
|
2284 (goto-char (point-max))
|
|
2285 (if (= (point-min) (point))
|
|
2286 (insert (car p))
|
|
2287 (insert (concat "\n" (car p))))
|
|
2288 (set-buffer-modified-p nil)
|
|
2289 (goto-char (point-min))))))
|
|
2290 fume-funclist))
|
|
2291 (cond ((interactive-p)
|
|
2292 (if current-prefix-arg
|
|
2293 (switch-to-buffer fume-buffer-name)
|
|
2294 (switch-to-buffer-other-window fume-buffer-name)
|
|
2295 (setq fume-list-trampled-buffer (other-buffer))
|
|
2296 (or fume-list-reused-win-p
|
|
2297 (shrink-window-if-larger-than-buffer)))
|
|
2298 (cond (func-near-point
|
|
2299 (re-search-forward func-near-point nil t)
|
|
2300 (beginning-of-line)))
|
|
2301 (fume-list-functions-help))))
|
|
2302 (t
|
|
2303 (error "Func-Menu is not operative in this buffer")))))
|
|
2304
|
|
2305 (provide 'func-menu)
|
82
|
2306
|
|
2307 ;;; end of file
|