From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Clemens Fischer Newsgroups: gmane.emacs.help Subject: Re: highlight current window/modeline after switching to it (solved) Date: Sat, 22 Nov 2003 12:37:55 +0100 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <3FBA6C9A.8090203@yahoo.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1069503457 11817 80.91.224.253 (22 Nov 2003 12:17:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 22 Nov 2003 12:17:37 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 22 13:17:34 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ANWhi-0005TO-00 for ; Sat, 22 Nov 2003 13:17:34 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ANXeE-0004RN-3w for geh-help-gnu-emacs@m.gmane.org; Sat, 22 Nov 2003 08:18:02 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ANXbz-0004Cm-9L for help-gnu-emacs@gnu.org; Sat, 22 Nov 2003 08:15:43 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ANXbD-0003ll-R6 for help-gnu-emacs@gnu.org; Sat, 22 Nov 2003 08:15:27 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ANXZM-0003Jr-Bp for help-gnu-emacs@gnu.org; Sat, 22 Nov 2003 08:13:00 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ANWbr-00027S-00 for ; Sat, 22 Nov 2003 13:11:31 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ANWbq-00027K-00 for ; Sat, 22 Nov 2003 13:11:30 +0100 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ANWbq-0002w9-00 for ; Sat, 22 Nov 2003 13:11:30 +0100 Original-Lines: 109 Original-X-Complaints-To: usenet@sea.gmane.org User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (berkeley-unix) Cancel-Lock: sha1:tT8eit8Jal/g4Zqlbl6sM1ud01w= X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:14504 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:14504 * 2003-11-18 Kevin Rodgers: >> ;(defadvice other-window (around other-window-flash activate) >> ; (interactive "p") >> ; (setq display-time-string-forms >> ; '( day "/" month "/" (substring year -2) >> ; " " 24-hours ":" minutes >> ; (if time-zone " (") time-zone (if time-zone ")"))) >> ; ad-do-it >> ; (setq display-time-string-forms >> ; '( "* " day "/" month "/" (substring year -2) >> ; " " 24-hours ":" minutes >> ; (if time-zone " (") time-zone (if time-zone ")"))) >> ; (force-mode-line-update t) >> ;) >> this version leaves me with the little `*' i wanted to signify the >> active window, but in all and everyone of them: no help. > > Try making it buffer local, and simplify your code at the same time: > > (set (make-local-variable 'display-time-string-forms) > (default-value 'display-time-string-forms)) > ad-do-it > (set (make-local-variable 'display-time-string-forms) > (cons "* " (default-value 'display-time-string-forms))) your proposal(s) looked entirely logical, but i couldn't get them to work. so i returned to a version using hooks. this one isn't perfect, because at times, when eg. M-x gnus manages my buffers, i have to press the key 'other-window is bound to once to see the mark indicating the M-x selected-window. ;; -ino: 221103-1133 (setq cf-model-selected '( "-" mode-line-mule-info mode-line-modified mode-line-frame-identification mode-line-buffer-identification " * " global-mode-string " %[(" mode-name mode-line-process minor-mode-alist "%n" ")%]--" (which-func-mode ("" which-func-format "--")) (line-number-mode "L%L--") (column-number-mode "C%c--") (-3 . "%p") "-%-" )) (setq cf-model-egal '( "-" mode-line-mule-info mode-line-modified mode-line-frame-identification mode-line-buffer-identification " " global-mode-string " %[(" mode-name mode-line-process minor-mode-alist "%n" ")%]--" (which-func-mode ("" which-func-format "--")) (line-number-mode "L%L--") (column-number-mode "C%c--") (-3 . "%p") "-%-" )) (defun cf-before-other-win nil (if (or (eq this-command 'other-window) (eq this-command 'select-window)) (setq mode-line-format cf-model-egal))) (defun cf-after-other-win nil (if (or (eq this-command 'other-window) (eq this-command 'select-window)) (progn (setq mode-line-format cf-model-selected) (force-mode-line-update t)))) (add-hook 'pre-command-hook 'cf-before-other-win) (add-hook 'post-command-hook 'cf-after-other-win) > Crufty! Does setting deactivate-mark temporarily while a pre- or > post-command-hook function is being evaluated actually have an > effect? i didn't check this at all, it was part of some code pasted there. i don't use it. > And the local com variable is completely unnecessary: just test (eq > last-command 'other-window) thanks for this tip! the previous version had M-x string= instead, because it's doc-string indicated it would compare symbols using their print-string. question: can i be sure that elisp will always keep only one copy of any symbol, so that i can effectively compare the pointers to them, which is the cheapest form of comparison? > [making elisp re-read anything it prints and get the same structure] > It's just too ugly. too bad. so i have to remember that elisp gets text properties, but there are exceptions in certain other cases. clemens