diff options
| author | Stefan Monnier | 2001-03-06 23:47:40 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-03-06 23:47:40 +0000 |
| commit | d530d358fd4af842a07d4d4755d3f4f4c72b1ca5 (patch) | |
| tree | 00224745518050f34c02f4d8a7a541c4e1910394 | |
| parent | 41b1cae76e9ba447f4d77f6db22f572ebed88887 (diff) | |
| download | emacs-d530d358fd4af842a07d4d4755d3f4f4c72b1ca5.tar.gz emacs-d530d358fd4af842a07d4d4755d3f4f4c72b1ca5.zip | |
(which-func-modes): Add cperl-mode.
(which-func-mode-global): Use define-minor-mode.
| -rw-r--r-- | lisp/which-func.el | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/lisp/which-func.el b/lisp/which-func.el index 5a70d5478c7..28f8d5f1067 100644 --- a/lisp/which-func.el +++ b/lisp/which-func.el | |||
| @@ -36,6 +36,8 @@ | |||
| 36 | ;; point". So if your current point is located after end of function | 36 | ;; point". So if your current point is located after end of function |
| 37 | ;; FOO but before begin of function BAR, FOO will be displayed in mode | 37 | ;; FOO but before begin of function BAR, FOO will be displayed in mode |
| 38 | ;; line. | 38 | ;; line. |
| 39 | ;; - if two windows display the same buffer, both windows | ||
| 40 | ;; show the same `which-func' information. | ||
| 39 | 41 | ||
| 40 | ;; TODO LIST | 42 | ;; TODO LIST |
| 41 | ;; --------- | 43 | ;; --------- |
| @@ -73,8 +75,8 @@ | |||
| 73 | :version "20.3") | 75 | :version "20.3") |
| 74 | 76 | ||
| 75 | (defcustom which-func-modes | 77 | (defcustom which-func-modes |
| 76 | '(emacs-lisp-mode c-mode c++-mode perl-mode makefile-mode sh-mode | 78 | '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode makefile-mode |
| 77 | fortran-mode) | 79 | sh-mode fortran-mode) |
| 78 | "List of major modes for which Which Function mode should be used. | 80 | "List of major modes for which Which Function mode should be used. |
| 79 | For other modes it is disabled. If this is equal to t, | 81 | For other modes it is disabled. If this is equal to t, |
| 80 | then Which Function mode is enabled in any major mode that supports it." | 82 | then Which Function mode is enabled in any major mode that supports it." |
| @@ -102,18 +104,6 @@ Zero means compute the Imenu menu regardless of size." | |||
| 102 | :group 'which-func | 104 | :group 'which-func |
| 103 | :type 'sexp) | 105 | :type 'sexp) |
| 104 | 106 | ||
| 105 | ;;;###autoload | ||
| 106 | (defcustom which-func-mode-global nil | ||
| 107 | "*Toggle `which-func-mode' globally. | ||
| 108 | Setting this variable directly does not take effect; | ||
| 109 | use either \\[customize] or the function `which-func-mode'." | ||
| 110 | :set #'(lambda (symbol value) | ||
| 111 | (which-func-mode (if value 1 0))) | ||
| 112 | :initialize 'custom-initialize-default | ||
| 113 | :type 'boolean | ||
| 114 | :group 'which-func | ||
| 115 | :require 'which-func) | ||
| 116 | |||
| 117 | (defvar which-func-cleanup-function nil | 107 | (defvar which-func-cleanup-function nil |
| 118 | "Function to transform a string before displaying it in the mode line. | 108 | "Function to transform a string before displaying it in the mode line. |
| 119 | The function is called with one argument, the string to display. | 109 | The function is called with one argument, the string to display. |
| @@ -176,20 +166,18 @@ It creates the Imenu index for the buffer, if necessary." | |||
| 176 | 166 | ||
| 177 | ;; This is the name people would normally expect. | 167 | ;; This is the name people would normally expect. |
| 178 | ;;;###autoload | 168 | ;;;###autoload |
| 179 | (defalias 'which-function-mode 'which-func-mode) | 169 | (defalias 'which-function-mode 'which-func-mode-global) |
| 180 | 170 | ;;;###autoload | |
| 171 | (defalias 'which-func-mode 'which-func-mode-global) | ||
| 181 | ;;;###autoload | 172 | ;;;###autoload |
| 182 | (defun which-func-mode (&optional arg) | 173 | (define-minor-mode which-func-mode-global |
| 183 | "Toggle Which Function mode, globally. | 174 | "Toggle Which Function mode, globally. |
| 184 | When Which Function mode is enabled, the current function name is | 175 | When Which Function mode is enabled, the current function name is |
| 185 | continuously displayed in the mode line, in certain major modes. | 176 | continuously displayed in the mode line, in certain major modes. |
| 186 | 177 | ||
| 187 | With prefix ARG, turn Which Function mode on iff arg is positive, | 178 | With prefix ARG, turn Which Function mode on iff arg is positive, |
| 188 | and off otherwise." | 179 | and off otherwise." |
| 189 | (interactive "P") | 180 | :global t :group 'which-func |
| 190 | (setq which-func-mode-global | ||
| 191 | (and (or arg (not which-func-mode-global)) | ||
| 192 | (> (prefix-numeric-value arg) 0))) | ||
| 193 | (if which-func-mode-global | 181 | (if which-func-mode-global |
| 194 | ;;Turn it on | 182 | ;;Turn it on |
| 195 | (progn | 183 | (progn |
| @@ -206,8 +194,8 @@ and off otherwise." | |||
| 206 | 194 | ||
| 207 | (defun which-function () | 195 | (defun which-function () |
| 208 | "Return current function name based on point. | 196 | "Return current function name based on point. |
| 209 | If `imenu--index-alist' does not exist, or is empty or if point | 197 | Uses `imenu--index-alist' or `add-log-current-defun-function'. |
| 210 | is located before first function, returns nil." | 198 | If no function name is found, return nil." |
| 211 | (let (name) | 199 | (let (name) |
| 212 | ;; First try using imenu support. | 200 | ;; First try using imenu support. |
| 213 | (when (and (boundp 'imenu--index-alist) imenu--index-alist) | 201 | (when (and (boundp 'imenu--index-alist) imenu--index-alist) |