]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/which-func.el
Merge from emacs-24; up to 2012-12-13T09:45:54Z!lekktu@gmail.com
[gnu-emacs] / lisp / progmodes / which-func.el
index d5c8a1c6792d69d4a67ffa4295cb19675fe39a96..edfe368479ca315bc8c57a9a9b9a1d5efaa9c568 100644 (file)
@@ -1,6 +1,7 @@
 ;;; 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-2013 Free Software Foundation,
+;; Inc.
 
 ;; Author:   Alex Rezinsky <alexr@msil.sps.mot.com>
 ;;           (doesn't seem to be responsive any more)
@@ -80,7 +81,7 @@
 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
+  :version "24.3"                       ; explicit list -> t
   :type '(choice (const :tag "All modes" t)
                 (repeat (symbol :tag "Major mode"))))
 
@@ -144,12 +145,13 @@ Zero means compute the Imenu menu regardless of size."
     (:propertize which-func-current
                 local-map ,which-func-keymap
                 face which-func
-                ;;mouse-face highlight ; currently not evaluated :-(
+                mouse-face mode-line-highlight
                 help-echo "mouse-1: go to beginning\n\
 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; 24point2 is correct
   :group 'which-func
   :type 'sexp)
 ;;;###autoload (put 'which-func-format 'risky-local-variable t)
@@ -181,7 +183,8 @@ and you want to simplify them for the mode line
 (defconst which-func-current
   '(:eval (replace-regexp-in-string
           "%" "%%"
-          (gethash (selected-window) which-func-table which-func-unknown))))
+          (or (gethash (selected-window) which-func-table)
+               which-func-unknown))))
 ;;;###autoload (put 'which-func-current 'risky-local-variable t)
 
 (defvar which-func-mode nil
@@ -233,9 +236,7 @@ It creates the Imenu index for the buffer, if necessary."
         (error "Error in which-func-update: %S" info))))))
 
 ;;;###autoload
-(defun which-func-mode (&optional arg)
-  (which-function-mode arg))
-(make-obsolete 'which-func-mode 'which-function-mode "24.1")
+(define-obsolete-function-alias 'which-func-mode 'which-function-mode "24.1")
 
 (defvar which-func-update-timer nil)
 
@@ -289,7 +290,7 @@ If no function name is found, return nil."
     (when (and (null name)
               (boundp 'imenu--index-alist) (null imenu--index-alist)
               (null which-function-imenu-failed))
-      (imenu--make-index-alist t)
+      (ignore-errors (imenu--make-index-alist t))
       (unless imenu--index-alist
         (set (make-local-variable 'which-function-imenu-failed) t)))
     ;; If we have an index alist, use it.
@@ -318,7 +319,9 @@ If no function name is found, return nil."
                     namestack (cons (car pair) namestack)
                     alist     (cdr pair)))
 
-             ((number-or-marker-p (setq mark (cdr pair)))
+             ((or (number-or-marker-p (setq mark (cdr pair)))
+                 (and (overlayp mark)
+                      (setq mark (overlay-start mark))))
               (when (and (>= (setq offset (- (point) mark)) 0)
                          (< offset minoffset)) ; Find the closest item.
                 (setq minoffset offset