[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: highlight current window/modeline after switching to it
From: |
Clemens Fischer |
Subject: |
Re: highlight current window/modeline after switching to it |
Date: |
Sun, 16 Nov 2003 20:36:37 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (berkeley-unix) |
* 2003-11-13 clemens fischer:
> with at least two windows open, i often have trouble to find the
> active one, ie. the one where the curser is ready to accept commands.
> so i want eg. the modeline swap fore- and background colors or parts
> of it. my older versions (this is a GNU Emacs 21.3.1
> (i386-unknown-freebsd4.8, X toolkit, Xaw3d scroll bars)) did this
> without any extra elisp.
>
> i couldn't find a ready-made function, so my question continues with
> "is there a hook called on each `other-window'"? i think i could take
> it from there with the elisp snippets already collected :)
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.
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 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)
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.
clemens