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