help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highlight current window/modeline after switching to it


From: Kevin Rodgers
Subject: Re: highlight current window/modeline after switching to it
Date: Tue, 18 Nov 2003 12:01:46 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]