aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1998-04-21 18:56:02 +0000
committerDave Love1998-04-21 18:56:02 +0000
commit0211dda3a714610a1b193fdbd5edd47794ac87a7 (patch)
tree96448b432c87ecd795b6b378993278ad1d48a7e0
parentd46490e312e95fcd2172d1cefe94706246423350 (diff)
downloademacs-0211dda3a714610a1b193fdbd5edd47794ac87a7.tar.gz
emacs-0211dda3a714610a1b193fdbd5edd47794ac87a7.zip
Fix header comments.
(which-func-mode): Add autoload cookie. (which-func-mode-global): Customize.
-rw-r--r--lisp/which-func.el103
1 files changed, 58 insertions, 45 deletions
diff --git a/lisp/which-func.el b/lisp/which-func.el
index 56cbbbab8cd..9ff0b57334c 100644
--- a/lisp/which-func.el
+++ b/lisp/which-func.el
@@ -1,9 +1,9 @@
1;;; which-func.el --- Print current function in mode line 1;;; which-func.el --- Print current function in mode line
2 2
3;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1997, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Alex Rezinsky <alexr@msil.sps.mot.com> 5;; Author: Alex Rezinsky <alexr@msil.sps.mot.com>
6;; Keywords: mode-line imenu 6;; Keywords: mode-line, imenu, tools
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
9 9
@@ -22,43 +22,47 @@
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA. 23;; Boston, MA 02111-1307, USA.
24 24
25;;; COMMENTARY 25;;; Commentary:
26;;; ---------- 26
27;;; This package prints name of function where your current point is 27;; This package prints name of function where your current point is
28;;; located in mode line. It assumes that you work with imenu package 28;; located in mode line. It assumes that you work with imenu package
29;;; and imenu--index-alist is up to date. 29;; and imenu--index-alist is up to date.
30 30
31;;; KNOWN BUGS 31;; KNOWN BUGS
32;;; ---------- 32;; ----------
33;;; Really this package shows not "function where the current point 33;; Really this package shows not "function where the current point is
34;;; is located now", but "nearest function which defined above the 34;; located now", but "nearest function which defined above the current
35;;; current point". So if your current point is located after end of 35;; point". So if your current point is located after end of function
36;;; function FOO but before begin of function BAR, FOO will be 36;; FOO but before begin of function BAR, FOO will be displayed in mode
37;;; displayed in mode line. 37;; line.
38 38
39;;; TODO LIST 39;; TODO LIST
40;;; --------- 40;; ---------
41;;; 1. Dependence on imenu package should be removed. Separate 41;; 1. Dependence on imenu package should be removed. Separate
42;;; function determination mechanism should be used to determine the end 42;; function determination mechanism should be used to determine the end
43;;; of a function as well as the beginning of a function. 43;; of a function as well as the beginning of a function.
44;;; 2. This package should be realized with the help of overlay 44;; 2. This package should be realized with the help of overlay
45;;; properties instead of imenu--index-alist variable. 45;; properties instead of imenu--index-alist variable.
46 46
47;;; THANKS TO 47;;; History:
48;;; --------- 48
49;;; Per Abrahamsen <abraham@iesd.auc.dk> 49;; THANKS TO
50;;; Some ideas (inserting in mode-line, using of post-command hook 50;; ---------
51;;; and toggling this mode) have been borrowed from his package 51;; Per Abrahamsen <abraham@iesd.auc.dk>
52;;; column.el 52;; Some ideas (inserting in mode-line, using of post-command hook
53;;; Peter Eisenhauer <pipe@fzi.de> 53;; and toggling this mode) have been borrowed from his package
54;;; Bug fixing in case nested indexes. 54;; column.el
55;;; Terry Tateyama <ttt@ursa0.cs.utah.edu> 55;; Peter Eisenhauer <pipe@fzi.de>
56;;; Suggestion to use find-file-hooks for first imenu 56;; Bug fixing in case nested indexes.
57;;; index building. 57;; Terry Tateyama <ttt@ursa0.cs.utah.edu>
58 58;; Suggestion to use find-file-hooks for first imenu
59;;; Variables for customization 59;; index building.
60;;; --------------------------- 60
61;;; 61;;; Code:
62
63;; Variables for customization
64;; ---------------------------
65;;
62(defvar which-func-unknown "???" 66(defvar which-func-unknown "???"
63 "String to display in the mode line when current function is unknown.") 67 "String to display in the mode line when current function is unknown.")
64 68
@@ -96,6 +100,17 @@ Zero means compute the Imenu menu regardless of size."
96 :group 'which-func 100 :group 'which-func
97 :type 'sexp) 101 :type 'sexp)
98 102
103;;;###autoload
104(defcustom which-func-mode-global nil
105 "*Toggle `which-func-mode'.
106You must modify via \\[customize] for this variable to have an effect."
107 :set #'(lambda (symbol value)
108 (which-func-mode (or value 0)))
109 :initialize 'custom-initialize-default
110 :type 'boolean
111 :group 'which-func
112 :require 'which-func)
113
99;;; Code, nothing to customize below here 114;;; Code, nothing to customize below here
100;;; ------------------------------------- 115;;; -------------------------------------
101;;; 116;;;
@@ -106,12 +121,9 @@ Zero means compute the Imenu menu regardless of size."
106(make-variable-buffer-local 'which-func-current) 121(make-variable-buffer-local 'which-func-current)
107(make-variable-buffer-local 'which-func-previous) 122(make-variable-buffer-local 'which-func-previous)
108 123
109(defvar which-func-mode-global nil
110 "Non-nil means display current function name in mode line.")
111
112(defvar which-func-mode nil 124(defvar which-func-mode nil
113 "Non-nil means display current function name in mode line. 125 "Non-nil means display current function name in mode line.
114This makes a difference only if which-func-mode-global is non-nil") 126This makes a difference only if `which-func-mode-global' is non-nil")
115(make-variable-buffer-local 'which-func-mode) 127(make-variable-buffer-local 'which-func-mode)
116(put 'which-func-mode 'permanent-local t) 128(put 'which-func-mode 'permanent-local t)
117 129
@@ -147,6 +159,7 @@ It creates the Imenu index for the buffer, if necessary."
147 (which-func-mode -1) ; Function mode off 159 (which-func-mode -1) ; Function mode off
148 (message "Error in which-func-update: %s" info)))) 160 (message "Error in which-func-update: %s" info))))
149 161
162;;;###autoload
150(defun which-func-mode (&optional arg) 163(defun which-func-mode (&optional arg)
151 "Toggle Which Function mode, globally. 164 "Toggle Which Function mode, globally.
152When Which Function mode is enabled, the current function name is 165When Which Function mode is enabled, the current function name is
@@ -174,8 +187,8 @@ and off otherwise."
174 (member major-mode which-func-modes)))))) 187 (member major-mode which-func-modes))))))
175 188
176(defun which-function () 189(defun which-function ()
177 "Returns current function name based on point. 190 "Return current function name based on point.
178If imenu--index-alist does not exist, or is empty or if point 191If `imenu--index-alist' does not exist, or is empty or if point
179is located before first function, returns nil." 192is located before first function, returns nil."
180 (and 193 (and
181 (boundp 'imenu--index-alist) 194 (boundp 'imenu--index-alist)