]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/which-func.el
* progmodes/python.el: Enhancements to navigation commands.
[gnu-emacs] / lisp / progmodes / which-func.el
index 7a810fb1e8f480ef3a82b559ecd1dad3fd9d0f07..02948b35fe0e84ca4d21bfbffdd9fc44c7cae8e7 100644 (file)
@@ -1,6 +1,6 @@
 ;;; which-func.el --- print current function in mode line
 
-;; Copyright (C) 1994, 1997-1998, 2001-2012  Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1997-1998, 2001-2012 Free Software Foundation, Inc.
 
 ;; Author:   Alex Rezinsky <alexr@msil.sps.mot.com>
 ;;           (doesn't seem to be responsive any more)
   "String to display in the mode line when current function is unknown.")
 
 (defgroup which-func nil
-  "Mode to display the current function name in the modeline."
+  "Display the current function name in the mode line."
   :group 'tools
   :version "20.3")
 
-(defcustom which-func-modes
-  '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode python-mode
-                   makefile-mode sh-mode fortran-mode f90-mode ada-mode
-                   diff-mode)
+(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)
   "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
+  :version "24.2"                       ; explicit list -> t
   :type '(choice (const :tag "All modes" t)
                 (repeat (symbol :tag "Major mode"))))
 
@@ -149,6 +150,7 @@ mouse-2: toggle rest visibility\n\
 mouse-3: go to end")
     "]")
   "Format for displaying the function in the mode line."
+  :version "24.2"                       ; added mouse-face
   :group 'which-func
   :type 'sexp)
 ;;;###autoload (put 'which-func-format 'risky-local-variable t)
@@ -162,7 +164,7 @@ single string, the new name of the item.")
 (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.
-Its return value is displayed in the modeline.
+Its return value is displayed in the mode line.
 If nil, no function is called.  The default value is nil.
 
 This feature can be useful if Imenu is set up to make more
@@ -208,7 +210,8 @@ It creates the Imenu index for the buffer, if necessary."
          (setq imenu--index-alist
                (save-excursion (funcall imenu-create-index-function))))
     (error
-     (unless (equal err '(error "This buffer cannot use `imenu-default-create-index-function'"))
+     (unless (equal err
+                    '(user-error "This buffer cannot use `imenu-default-create-index-function'"))
        (message "which-func-ff-hook error: %S" err))
      (setq which-func-mode nil))))
 
@@ -335,6 +338,22 @@ If no function name is found, return nil."
          (funcall which-func-cleanup-function name)
        name))))
 
+\f
+;;; Integration with other packages
+
+(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)
+
 (provide 'which-func)
 
 ;;; which-func.el ends here