# HG changeset patch # User Stefan Monnier # Date 1053209948 0 # Node ID 322e59c8a00caca5bb1dcefbf829f8189052e747 # Parent b39d8ed2d159d607c7df4d74b7743f70c3b6649e (which-func-format): Make it risky-local-variable. (which-func-table): New var. (which-func-current): Make it into a constant modeline spec. (which-func-previous): Remove. (which-func-update): Only update the selected window. (which-func-update-1): Use the new var to allow the current function to be different for a buffer shown in two windows. diff -r b39d8ed2d159 -r 322e59c8a00c lisp/which-func.el --- a/lisp/which-func.el Sat May 17 22:00:40 2003 +0000 +++ b/lisp/which-func.el Sat May 17 22:19:08 2003 +0000 @@ -1,6 +1,6 @@ ;;; which-func.el --- print current function in mode line -;; Copyright (C) 1994, 1997, 1998, 2001 Free Software Foundation, Inc. +;; Copyright (C) 1994, 1997, 1998, 2001, 2003 Free Software Foundation, Inc. ;; Author: Alex Rezinsky ;; (doesn't seem to be responsive any more) @@ -103,6 +103,7 @@ "Format for displaying the function in the mode line." :group 'which-func :type 'sexp) +(put 'which-func-format 'risky-local-variable t) (defvar which-func-cleanup-function nil "Function to transform a string before displaying it in the mode line. @@ -120,10 +121,11 @@ ;;; (require 'imenu) -(defvar which-func-current which-func-unknown) -(defvar which-func-previous which-func-unknown) -(make-variable-buffer-local 'which-func-current) -(make-variable-buffer-local 'which-func-previous) +(defvar which-func-table (make-hash-table :test 'eq :weakness 'key)) + +(defconst which-func-current + '(:eval (gethash (selected-window) which-func-table which-func-unknown))) +(put 'which-func-current 'risky-local-variable t) (defvar which-func-mode nil "Non-nil means display current function name in mode line. @@ -153,21 +155,19 @@ (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)) + ;; "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) "Update the Which-Function mode display for window WINDOW." - (save-selected-window - (select-window window) - ;; Update the string containing the current function. + (with-selected-window window (when which-func-mode (condition-case info - (progn - (setq which-func-current (or (which-function) which-func-unknown)) - (unless (string= which-func-current which-func-previous) - (force-mode-line-update) - (setq which-func-previous which-func-current))) + (let ((current (which-function))) + (unless (equal current (gethash window which-func-table)) + (puthash window current which-func-table) + (force-mode-line-update))) (error (which-func-mode -1) (error "Error in which-func-update: %s" info))))))