From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: highlight current window/modeline after switching to it Date: Tue, 18 Nov 2003 12:01:46 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3FBA6C9A.8090203@yahoo.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1069182960 31614 80.91.224.253 (18 Nov 2003 19:16:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Nov 2003 19:16:00 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 18 20:15:57 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 1AMBKO-0005t8-00 for ; Tue, 18 Nov 2003 20:15:57 +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 1AMCGm-0005jB-RL for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Nov 2003 15:16:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 91 Original-NNTP-Posting-Host: 170.207.51.80 Original-X-Trace: news.uni-berlin.de 1069182106 57194996 170.207.51.80 (16 [82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us Original-Xref: shelby.stanford.edu gnu.emacs.help:118418 Original-To: help-gnu-emacs@gnu.org 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:14359 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:14359 Clemens Fischer wrote: > using (defadvice) without the inner fillings didn't help me, and i > just cannot grasp all that rigmarole with the advice system. i just > came as far as: > > ;(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))) Of course, that won't work as desired if the same buffer is displayed in 2 windows. > so i went to go another way: we have 'pre-command-hook and > 'post-command-hook, and a buffer-local variable mode-line-format. > > ; mode-line-format's value is shown below: > ; > ;(setq cf-model-default (#("-" 0 1 > ; (help-echo "mouse-1: select window, mouse-2: delete others, mouse-3: delete ...")) > ; mode-line-mule-info mode-line-modified mode-line-frame-identification mode-line-buffer-identification > ; #(" " 0 3 > ; (help-echo "mouse-1: select window, mouse-2: delete others, mouse-3: delete ...")) > > now the collision is between elisps incompatible read and write > syntax. elisp will show me mode-line-format, but it can't read its > own output! I think the elipses are due to print-length and print-level. The #(...) notation is for strings with text properties, and can be read by Emacs Lisp. > i can try understanding defadvice or (i think easier) use hooks. my > first attempt was: > > (defun cf-before-other-win > (let ((com (prin1-to-string last-command)) > (deactivate-mark nil)) > (if (string= com "other-window") > (setq mode-line-format cf-model-egal)))) > > (defun cf-after-other-win > (let ((com (prin1-to-string last-command)) > (deactivate-mark nil)) > (if (string= com "other-window") > (setq mode-line-format cf-model-selected)))) > > ;(add-hook 'post-command-hook 'cf-before-other-win t) > ;(add-hook 'pre-command-hook 'cf-after-other-win t) Crufty! Does setting deactivate-mark temporarily while a pre- or post-command-hook function is being evaluated actually have an effect? And the local com variable is completely unnecessary: just test (eq last-command 'other-window) > this one might propably work, but then i should be able to give > mode-line-format sensible values. just yanking it over from the > doc-string and changing a bit is not enough, if the syntax displayed > can't be reread. It's just too ugly. -- Kevin Rodgers