[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: highlight current window/modeline after switching to it (solved)
From: |
Clemens Fischer |
Subject: |
Re: highlight current window/modeline after switching to it (solved) |
Date: |
Sat, 22 Nov 2003 12:37:55 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (berkeley-unix) |
* 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