2003-05-30 23:31:15 +00:00
|
|
|
|
;;; which-func.el --- print current function in mode line
|
|
|
|
|
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Copyright (C) 1994, 1997-1998, 2001-2013 Free Software Foundation,
|
|
|
|
|
;; Inc.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Alex Rezinsky <alexr@msil.sps.mot.com>
|
|
|
|
|
;; (doesn't seem to be responsive any more)
|
|
|
|
|
;; Keywords: mode-line, imenu, tools
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This package prints name of function where your current point is
|
|
|
|
|
;; located in mode line. It assumes that you work with imenu package
|
|
|
|
|
;; and imenu--index-alist is up to date.
|
|
|
|
|
|
|
|
|
|
;; KNOWN BUGS
|
|
|
|
|
;; ----------
|
|
|
|
|
;; Really this package shows not "function where the current point is
|
|
|
|
|
;; located now", but "nearest function which defined above the current
|
|
|
|
|
;; point". So if your current point is located after end of function
|
|
|
|
|
;; FOO but before begin of function BAR, FOO will be displayed in mode
|
|
|
|
|
;; line.
|
|
|
|
|
;; - if two windows display the same buffer, both windows
|
|
|
|
|
;; show the same `which-func' information.
|
|
|
|
|
|
|
|
|
|
;; TODO LIST
|
|
|
|
|
;; ---------
|
|
|
|
|
;; 1. Dependence on imenu package should be removed. Separate
|
|
|
|
|
;; function determination mechanism should be used to determine the end
|
|
|
|
|
;; of a function as well as the beginning of a function.
|
|
|
|
|
;; 2. This package should be realized with the help of overlay
|
|
|
|
|
;; properties instead of imenu--index-alist variable.
|
|
|
|
|
|
|
|
|
|
;;; History:
|
|
|
|
|
|
|
|
|
|
;; THANKS TO
|
|
|
|
|
;; ---------
|
|
|
|
|
;; Per Abrahamsen <abraham@iesd.auc.dk>
|
|
|
|
|
;; Some ideas (inserting in mode-line, using of post-command hook
|
|
|
|
|
;; and toggling this mode) have been borrowed from his package
|
|
|
|
|
;; column.el
|
|
|
|
|
;; Peter Eisenhauer <pipe@fzi.de>
|
|
|
|
|
;; Bug fixing in case nested indexes.
|
|
|
|
|
;; Terry Tateyama <ttt@ursa0.cs.utah.edu>
|
|
|
|
|
;; Suggestion to use find-file-hook for first imenu
|
|
|
|
|
;; index building.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;; Variables for customization
|
|
|
|
|
;; ---------------------------
|
|
|
|
|
;;
|
|
|
|
|
(defvar which-func-unknown "???"
|
|
|
|
|
"String to display in the mode line when current function is unknown.")
|
|
|
|
|
|
|
|
|
|
(defgroup which-func nil
|
2012-06-02 10:56:09 +00:00
|
|
|
|
"Display the current function name in the mode line."
|
2003-05-30 23:31:15 +00:00
|
|
|
|
:group 'tools
|
|
|
|
|
:version "20.3")
|
|
|
|
|
|
2012-04-14 02:31:50 +00:00
|
|
|
|
(defcustom which-func-modes t
|
|
|
|
|
;; '(emacs-lisp-mode c-mode c++-mode objc-mode perl-mode cperl-mode python-mode
|
|
|
|
|
;; makefile-mode sh-mode fortran-mode f90-mode ada-mode
|
|
|
|
|
;; diff-mode)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
"List of major modes for which Which Function mode should be used.
|
|
|
|
|
For other modes it is disabled. If this is equal to t,
|
|
|
|
|
then Which Function mode is enabled in any major mode that supports it."
|
|
|
|
|
:group 'which-func
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3" ; explicit list -> t
|
2003-05-30 23:31:15 +00:00
|
|
|
|
:type '(choice (const :tag "All modes" t)
|
|
|
|
|
(repeat (symbol :tag "Major mode"))))
|
|
|
|
|
|
|
|
|
|
(defcustom which-func-non-auto-modes nil
|
|
|
|
|
"List of major modes where Which Function mode is inactive till Imenu is used.
|
|
|
|
|
This means that Which Function mode won't really do anything
|
|
|
|
|
until you use Imenu, in these modes. Note that files
|
|
|
|
|
larger than `which-func-maxout' behave in this way too;
|
|
|
|
|
Which Function mode doesn't do anything until you use Imenu."
|
|
|
|
|
:group 'which-func
|
|
|
|
|
:type '(repeat (symbol :tag "Major mode")))
|
|
|
|
|
|
|
|
|
|
(defcustom which-func-maxout 500000
|
|
|
|
|
"Don't automatically compute the Imenu menu if buffer is this big or bigger.
|
|
|
|
|
Zero means compute the Imenu menu regardless of size."
|
|
|
|
|
:group 'which-func
|
|
|
|
|
:type 'integer)
|
|
|
|
|
|
2004-07-17 08:10:28 +00:00
|
|
|
|
(defvar which-func-keymap
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [mode-line mouse-1] 'beginning-of-defun)
|
|
|
|
|
(define-key map [mode-line mouse-2]
|
|
|
|
|
(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (eq (point-min) 1)
|
|
|
|
|
(narrow-to-defun)
|
|
|
|
|
(widen))))
|
|
|
|
|
(define-key map [mode-line mouse-3] 'end-of-defun)
|
|
|
|
|
map)
|
|
|
|
|
"Keymap to display on mode line which-func.")
|
|
|
|
|
|
2005-06-15 00:14:41 +00:00
|
|
|
|
(defface which-func
|
2005-06-15 04:35:23 +00:00
|
|
|
|
;; Whether `font-lock-function-name-face' is an appropriate face to
|
|
|
|
|
;; inherit depends on the mode-line face; define several variants based
|
|
|
|
|
;; on the default mode-line face.
|
|
|
|
|
'(;; The default mode-line face on a high-color display is a relatively
|
|
|
|
|
;; light color ("grey75"), and only the light-background variant of
|
|
|
|
|
;; `font-lock-function-name-face' is visible against it.
|
|
|
|
|
(((class color) (min-colors 88) (background light))
|
|
|
|
|
:inherit font-lock-function-name-face)
|
|
|
|
|
;; The default mode-line face on other display types is inverse-video;
|
|
|
|
|
;; it seems that only in the dark-background case is
|
|
|
|
|
;; `font-lock-function-name-face' visible against it.
|
|
|
|
|
(((class grayscale mono) (background dark))
|
|
|
|
|
:inherit font-lock-function-name-face)
|
|
|
|
|
(((class color) (background light))
|
|
|
|
|
:inherit font-lock-function-name-face)
|
|
|
|
|
;; If none of the above cases, use an explicit color chosen to contrast
|
|
|
|
|
;; well with the default mode-line face.
|
|
|
|
|
(((class color) (min-colors 88) (background dark))
|
|
|
|
|
:foreground "Blue1")
|
|
|
|
|
(((background dark))
|
|
|
|
|
:foreground "Blue1")
|
|
|
|
|
(t
|
|
|
|
|
:foreground "LightSkyBlue"))
|
|
|
|
|
"Face used to highlight mode line function names."
|
2004-07-17 08:10:28 +00:00
|
|
|
|
:group 'which-func)
|
|
|
|
|
|
|
|
|
|
(defcustom which-func-format
|
|
|
|
|
`("["
|
|
|
|
|
(:propertize which-func-current
|
|
|
|
|
local-map ,which-func-keymap
|
2005-06-15 00:14:41 +00:00
|
|
|
|
face which-func
|
2012-06-25 07:11:03 +00:00
|
|
|
|
mouse-face mode-line-highlight
|
2010-08-03 16:39:37 +00:00
|
|
|
|
help-echo "mouse-1: go to beginning\n\
|
|
|
|
|
mouse-2: toggle rest visibility\n\
|
|
|
|
|
mouse-3: go to end")
|
2004-07-17 08:10:28 +00:00
|
|
|
|
"]")
|
2003-05-30 23:31:15 +00:00
|
|
|
|
"Format for displaying the function in the mode line."
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.2" ; added mouse-face; 24point2 is correct
|
2003-05-30 23:31:15 +00:00
|
|
|
|
:group 'which-func
|
|
|
|
|
:type 'sexp)
|
|
|
|
|
;;;###autoload (put 'which-func-format 'risky-local-variable t)
|
|
|
|
|
|
2010-11-24 02:21:55 +00:00
|
|
|
|
(defvar which-func-imenu-joiner-function (lambda (x) (car (last x)))
|
2008-09-30 03:42:56 +00:00
|
|
|
|
"Function to join together multiple levels of imenu nomenclature.
|
|
|
|
|
Called with a single argument, a list of strings giving the names
|
|
|
|
|
of the menus we had to traverse to get to the item. Returns a
|
|
|
|
|
single string, the new name of the item.")
|
2008-09-30 03:41:35 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defvar which-func-cleanup-function nil
|
|
|
|
|
"Function to transform a string before displaying it in the mode line.
|
|
|
|
|
The function is called with one argument, the string to display.
|
2012-06-02 10:56:09 +00:00
|
|
|
|
Its return value is displayed in the mode line.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
If nil, no function is called. The default value is nil.
|
|
|
|
|
|
|
|
|
|
This feature can be useful if Imenu is set up to make more
|
|
|
|
|
detailed entries (e.g., containing the argument list of a function),
|
|
|
|
|
and you want to simplify them for the mode line
|
|
|
|
|
\(e.g., removing the parameter list to just have the function name.)")
|
|
|
|
|
|
|
|
|
|
;;; Code, nothing to customize below here
|
|
|
|
|
;;; -------------------------------------
|
|
|
|
|
;;;
|
|
|
|
|
(require 'imenu)
|
|
|
|
|
|
|
|
|
|
(defvar which-func-table (make-hash-table :test 'eq :weakness 'key))
|
|
|
|
|
|
|
|
|
|
(defconst which-func-current
|
2012-04-21 18:25:20 +00:00
|
|
|
|
'(:eval (replace-regexp-in-string
|
|
|
|
|
"%" "%%"
|
2012-10-22 13:29:28 +00:00
|
|
|
|
(or (gethash (selected-window) which-func-table)
|
|
|
|
|
which-func-unknown))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;;;###autoload (put 'which-func-current 'risky-local-variable t)
|
|
|
|
|
|
|
|
|
|
(defvar which-func-mode nil
|
|
|
|
|
"Non-nil means display current function name in mode line.
|
|
|
|
|
This makes a difference only if `which-function-mode' is non-nil.")
|
|
|
|
|
(make-variable-buffer-local 'which-func-mode)
|
|
|
|
|
;;(put 'which-func-mode 'permanent-local t)
|
|
|
|
|
|
|
|
|
|
(add-hook 'find-file-hook 'which-func-ff-hook t)
|
|
|
|
|
|
|
|
|
|
(defun which-func-ff-hook ()
|
|
|
|
|
"File find hook for Which Function mode.
|
|
|
|
|
It creates the Imenu index for the buffer, if necessary."
|
|
|
|
|
(setq which-func-mode
|
|
|
|
|
(and which-function-mode
|
|
|
|
|
(or (eq which-func-modes t)
|
|
|
|
|
(member major-mode which-func-modes))))
|
|
|
|
|
|
2010-12-04 00:49:49 +00:00
|
|
|
|
(condition-case err
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(if (and which-func-mode
|
|
|
|
|
(not (member major-mode which-func-non-auto-modes))
|
|
|
|
|
(or (null which-func-maxout)
|
|
|
|
|
(< buffer-saved-size which-func-maxout)
|
|
|
|
|
(= which-func-maxout 0)))
|
|
|
|
|
(setq imenu--index-alist
|
|
|
|
|
(save-excursion (funcall imenu-create-index-function))))
|
|
|
|
|
(error
|
2012-05-22 16:50:02 +00:00
|
|
|
|
(unless (equal err
|
|
|
|
|
'(user-error "This buffer cannot use `imenu-default-create-index-function'"))
|
2011-07-05 18:56:31 +00:00
|
|
|
|
(message "which-func-ff-hook error: %S" err))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(setq which-func-mode nil))))
|
|
|
|
|
|
|
|
|
|
(defun which-func-update ()
|
|
|
|
|
;; "Update the Which-Function mode display for all windows."
|
|
|
|
|
;; (walk-windows 'which-func-update-1 nil 'visible))
|
|
|
|
|
(which-func-update-1 (selected-window)))
|
|
|
|
|
|
|
|
|
|
(defun which-func-update-1 (window)
|
2004-08-16 22:46:26 +00:00
|
|
|
|
"Update the Which Function mode display for window WINDOW."
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(with-selected-window window
|
|
|
|
|
(when which-func-mode
|
|
|
|
|
(condition-case info
|
|
|
|
|
(let ((current (which-function)))
|
|
|
|
|
(unless (equal current (gethash window which-func-table))
|
|
|
|
|
(puthash window current which-func-table)
|
|
|
|
|
(force-mode-line-update)))
|
|
|
|
|
(error
|
2005-05-29 08:31:54 +00:00
|
|
|
|
(setq which-func-mode nil)
|
2010-12-04 00:49:49 +00:00
|
|
|
|
(error "Error in which-func-update: %S" info))))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
Use declare forms, where possible, to mark obsolete functions.
* lisp/allout.el (allout-passphrase-hint-string): Likewise.
(allout-init): Use a declare form to mark obsolete.
* lisp/calendar/calendar.el (calendar-version):
* lisp/calendar/icalendar.el (icalendar-extract-ical-from-buffer)
(icalendar-convert-diary-to-ical):
* lisp/cus-edit.el (custom-mode):
* lisp/ansi-color.el (ansi-color-unfontify-region):
* lisp/international/latin1-disp.el (latin1-char-displayable-p):
* lisp/progmodes/cwarn.el (turn-on-cwarn-mode):
* lisp/progmodes/which-func.el (which-func-update-1): Use
define-obsolete-function-alias.
* lisp/bookmark.el (bookmark-jump-noselect): Use a declare form to mark
this function obsolete.
* lisp/calendar/cal-x.el (calendar-two-frame-setup)
(calendar-only-one-frame-setup, calendar-one-frame-setup):
* lisp/calendar/calendar.el (american-calendar, european-calendar)
(calendar-for-loop):
* lisp/comint.el (comint-dynamic-simple-complete)
(comint-dynamic-complete-as-filename, comint-unquote-filename):
* lisp/desktop.el (desktop-load-default):
* lisp/dired-x.el (dired-omit-here-always)
(dired-hack-local-variables, dired-default-directory):
* lisp/emacs-lisp/derived.el (derived-mode-class):
* lisp/emacs-lisp/timer.el (timer-set-time-with-usecs):
* lisp/emacs-lock.el (toggle-emacs-lock):
* lisp/epa.el (epa-display-verify-result):
* lisp/epg.el (epg-sign-keys, epg-start-sign-keys)
(epg-passphrase-callback-function):
* lisp/eshell/esh-util.el (eshell-for):
* lisp/eshell/eshell.el (eshell-remove-from-window-buffer-names)
(eshell-add-to-window-buffer-names):
* lisp/files.el (locate-file-completion):
* lisp/imenu.el (imenu-example--create-c-index)
(imenu-example--create-lisp-index)
(imenu-example--lisp-extract-index-name)
(imenu-example--name-and-position):
* lisp/international/mule-cmds.el (princ-list):
* lisp/international/mule-diag.el (decode-codepage-char):
* lisp/international/mule-util.el (detect-coding-with-priority):
* lisp/iswitchb.el (iswitchb-read-buffer):
* lisp/mail/mailalias.el (mail-complete):
* lisp/mail/sendmail.el (mail-sent-via):
* lisp/mouse.el (mouse-popup-menubar-stuff, mouse-popup-menubar)
(mouse-major-mode-menu):
* lisp/password-cache.el (password-read-and-add):
* lisp/pcomplete.el (pcomplete-parse-comint-arguments):
* lisp/progmodes/sh-script.el (sh-maybe-here-document):
* lisp/replace.el (query-replace-regexp-eval):
* lisp/savehist.el (savehist-load):
* lisp/simple.el (choose-completion-delete-max-match):
* lisp/term.el (term-dynamic-simple-complete):
* lisp/vc/ediff-init.el (ediff-check-version):
* lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically):
* lisp/vc/vc.el (vc-diff-switches-list):
* lisp/view.el (view-return-to-alist-update): Likewise.
* lisp/iswitchb.el (iswitchb-read-buffer): Move code of
iswitchb-define-mode-map here, and delete that obsolete function.
* lisp/subr.el (eval-next-after-load, makehash, insert-string)
(assoc-ignore-representation, assoc-ignore-case): Use declare to
mark obsolete.
(mode-line-inverse-video): Variable deleted.
* lisp/emacs-lisp/byte-run.el (make-obsolete): Doc fix; emphasize that
this applies to functions.
* lisp/erc/erc.el (erc-send-command): Use define-obsolete-function-alias.
* lisp/international/mule-util.el (string-to-sequence): Remove.
* lisp/net/newst-backend.el (newsticker-cache-filename):
* lisp/net/newst-treeview.el (newsticker-groups-filename): Fix
incorrect obsolescence declaration.
* lisp/net/snmp-mode.el (snmp-font-lock-keywords-3): Don't use obsolete
font-lock-reference-face.
* lisp/url/url-parse.el (url-recreate-url-attributes):
* lisp/url/url-util.el (url-generate-unique-filename): Use declare to mark
obsolete.
* src/xdisp.c (mode_line_inverse_video): Delete obsolete variable.
2012-09-25 04:13:02 +00:00
|
|
|
|
(define-obsolete-function-alias 'which-func-mode 'which-function-mode "24.1")
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defvar which-func-update-timer nil)
|
|
|
|
|
|
|
|
|
|
;; This is the name people would normally expect.
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-minor-mode which-function-mode
|
2011-10-20 00:26:14 +00:00
|
|
|
|
"Toggle mode line display of current function (Which Function mode).
|
|
|
|
|
With a prefix argument ARG, enable Which Function mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
Which Function mode is a global minor mode. When enabled, the
|
|
|
|
|
current function name is continuously displayed in the mode line,
|
|
|
|
|
in certain major modes."
|
2003-05-30 23:31:15 +00:00
|
|
|
|
:global t :group 'which-func
|
2010-11-24 02:21:55 +00:00
|
|
|
|
(when (timerp which-func-update-timer)
|
|
|
|
|
(cancel-timer which-func-update-timer))
|
|
|
|
|
(setq which-func-update-timer nil)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(if which-function-mode
|
|
|
|
|
;;Turn it on
|
|
|
|
|
(progn
|
|
|
|
|
(setq which-func-update-timer
|
|
|
|
|
(run-with-idle-timer idle-update-delay t 'which-func-update))
|
|
|
|
|
(dolist (buf (buffer-list))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(setq which-func-mode
|
|
|
|
|
(or (eq which-func-modes t)
|
|
|
|
|
(member major-mode which-func-modes))))))
|
|
|
|
|
;; Turn it off
|
|
|
|
|
(dolist (buf (buffer-list))
|
|
|
|
|
(with-current-buffer buf (setq which-func-mode nil)))))
|
|
|
|
|
|
|
|
|
|
(defvar which-function-imenu-failed nil
|
|
|
|
|
"Locally t in a buffer if `imenu--make-index-alist' found nothing there.")
|
|
|
|
|
|
2003-09-30 12:53:26 +00:00
|
|
|
|
(defvar which-func-functions nil
|
|
|
|
|
"List of functions for `which-function' to call with no arguments.
|
|
|
|
|
It calls them sequentially, and if any returns non-nil,
|
|
|
|
|
`which-function' uses that name and stops looking for the name.")
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun which-function ()
|
|
|
|
|
"Return current function name based on point.
|
2006-07-27 12:18:03 +00:00
|
|
|
|
Uses `which-func-functions', `imenu--index-alist'
|
2011-05-08 18:29:35 +00:00
|
|
|
|
or `add-log-current-defun'.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
If no function name is found, return nil."
|
2004-12-05 16:58:13 +00:00
|
|
|
|
(let ((name
|
2006-07-27 12:18:03 +00:00
|
|
|
|
;; Try the `which-func-functions' functions first.
|
2004-12-05 16:58:13 +00:00
|
|
|
|
(run-hook-with-args-until-success 'which-func-functions)))
|
2003-09-30 12:53:26 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; If Imenu is loaded, try to make an index alist with it.
|
2003-09-30 12:53:26 +00:00
|
|
|
|
(when (and (null name)
|
|
|
|
|
(boundp 'imenu--index-alist) (null imenu--index-alist)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(null which-function-imenu-failed))
|
2013-01-15 04:20:13 +00:00
|
|
|
|
(ignore-errors (imenu--make-index-alist t))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(unless imenu--index-alist
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 20:00:25 +00:00
|
|
|
|
(set (make-local-variable 'which-function-imenu-failed) t)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; If we have an index alist, use it.
|
2003-09-30 12:53:26 +00:00
|
|
|
|
(when (and (null name)
|
|
|
|
|
(boundp 'imenu--index-alist) imenu--index-alist)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(let ((alist imenu--index-alist)
|
|
|
|
|
(minoffset (point-max))
|
2008-09-30 03:41:35 +00:00
|
|
|
|
offset pair mark imstack namestack)
|
|
|
|
|
;; Elements of alist are either ("name" . marker), or
|
|
|
|
|
;; ("submenu" ("name" . marker) ... ). The list can be
|
|
|
|
|
;; arbitrarily nested.
|
|
|
|
|
(while (or alist imstack)
|
2010-12-04 00:49:49 +00:00
|
|
|
|
(if (null alist)
|
|
|
|
|
(setq alist (car imstack)
|
|
|
|
|
namestack (cdr namestack)
|
|
|
|
|
imstack (cdr imstack))
|
|
|
|
|
|
|
|
|
|
(setq pair (car-safe alist)
|
|
|
|
|
alist (cdr-safe alist))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((atom pair)) ; Skip anything not a cons.
|
|
|
|
|
|
|
|
|
|
((imenu--subalist-p pair)
|
|
|
|
|
(setq imstack (cons alist imstack)
|
|
|
|
|
namestack (cons (car pair) namestack)
|
|
|
|
|
alist (cdr pair)))
|
|
|
|
|
|
2013-01-10 15:36:01 +00:00
|
|
|
|
((or (number-or-marker-p (setq mark (cdr pair)))
|
|
|
|
|
(and (overlayp mark)
|
|
|
|
|
(setq mark (overlay-start mark))))
|
2010-12-04 00:49:49 +00:00
|
|
|
|
(when (and (>= (setq offset (- (point) mark)) 0)
|
|
|
|
|
(< offset minoffset)) ; Find the closest item.
|
|
|
|
|
(setq minoffset offset
|
|
|
|
|
name (if (null which-func-imenu-joiner-function)
|
|
|
|
|
(car pair)
|
|
|
|
|
(funcall
|
|
|
|
|
which-func-imenu-joiner-function
|
|
|
|
|
(reverse (cons (car pair) namestack))))))))))))
|
2008-09-30 03:41:35 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; Try using add-log support.
|
2011-05-08 18:29:35 +00:00
|
|
|
|
(when (null name)
|
|
|
|
|
(setq name (add-log-current-defun)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; Filter the name if requested.
|
|
|
|
|
(when name
|
|
|
|
|
(if which-func-cleanup-function
|
|
|
|
|
(funcall which-func-cleanup-function name)
|
|
|
|
|
name))))
|
|
|
|
|
|
2012-06-03 11:10:44 +00:00
|
|
|
|
|
|
|
|
|
;;; Integration with other packages
|
|
|
|
|
|
2013-05-24 03:49:17 +00:00
|
|
|
|
(defvar ediff-window-A)
|
|
|
|
|
(defvar ediff-window-B)
|
|
|
|
|
(defvar ediff-window-C)
|
|
|
|
|
|
2012-06-03 11:10:44 +00:00
|
|
|
|
(defun which-func-update-ediff-windows ()
|
|
|
|
|
"Update Which-Function mode display for Ediff windows.
|
|
|
|
|
This function is meant to be called from `ediff-select-hook'."
|
|
|
|
|
(when (eq major-mode 'ediff-mode)
|
|
|
|
|
(when ediff-window-A
|
|
|
|
|
(which-func-update-1 ediff-window-A))
|
|
|
|
|
(when ediff-window-B
|
|
|
|
|
(which-func-update-1 ediff-window-B))
|
|
|
|
|
(when ediff-window-C
|
|
|
|
|
(which-func-update-1 ediff-window-C))))
|
|
|
|
|
|
|
|
|
|
(add-hook 'ediff-select-hook 'which-func-update-ediff-windows)
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(provide 'which-func)
|
|
|
|
|
|
|
|
|
|
;;; which-func.el ends here
|