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