unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* highlight current window/modeline after switching to it
@ 2003-11-13 20:27 clemens fischer
  2003-11-16 19:36 ` Clemens Fischer
       [not found] ` <mailman.213.1069158630.399.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: clemens fischer @ 2003-11-13 20:27 UTC (permalink / raw)


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 :)

regards,

  clemens

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
       [not found] <mailman.64.1068806323.399.help-gnu-emacs@gnu.org>
@ 2003-11-14 16:37 ` Kevin Rodgers
  0 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2003-11-14 16:37 UTC (permalink / raw)


clemens fischer wrote:

> 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 :)

(defadvice other-window (after my-hook activate)
   ...)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-13 20:27 highlight current window/modeline after switching to it clemens fischer
@ 2003-11-16 19:36 ` Clemens Fischer
       [not found] ` <mailman.213.1069158630.399.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Clemens Fischer @ 2003-11-16 19:36 UTC (permalink / raw)


* 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
       [not found] ` <mailman.213.1069158630.399.help-gnu-emacs@gnu.org>
@ 2003-11-18 19:01   ` Kevin Rodgers
  2003-11-18 21:12     ` Chris McMahan
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Kevin Rodgers @ 2003-11-18 19:01 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-18 19:01   ` Kevin Rodgers
@ 2003-11-18 21:12     ` Chris McMahan
  2003-11-19 12:43       ` François Fleuret
  2003-11-22  9:32       ` Clemens Fischer
  2003-11-22 11:37     ` highlight current window/modeline after switching to it (solved) Clemens Fischer
       [not found]     ` <mailman.439.1069506956.399.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 11+ messages in thread
From: Chris McMahan @ 2003-11-18 21:12 UTC (permalink / raw)


I've got the following code that flashes the newly-selected
window. The latest version of emacs has faces for mode-line and
mode-line-inactive that will allow you to change their appearance.

e-other-window can be found at:
http://relativity.yi.org/el/e-other-window.el

;;;============================================================
;;; e-other-window flashes the window when traversing windows within a
;;; fram to help locat the cursor
;;;============================================================
(require 'e-other-window)
(setq e-other-window-interval .05)
(set-face-background 'e-other-window-overlay-face "LightSteelBlue")

;;; map it to the standard keybinding to swith windows
(defun cm-other-window ()
  (interactive)
  (other-window 1)
  (e-other-window-blink)
  )
(global-set-key "\C-xo" 'cm-other-window)

- Chris McMahan

Kevin Rodgers <ihs_4664@yahoo.com> writes:


-- 
     (.   .)
  =ooO=(_)=Ooo========================
  Chris McMahan | cmcmahan-at-one.net
  ====================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-18 21:12     ` Chris McMahan
@ 2003-11-19 12:43       ` François Fleuret
  2003-11-19 14:48         ` Chris McMahan
  2003-11-22  9:32       ` Clemens Fischer
  1 sibling, 1 reply; 11+ messages in thread
From: François Fleuret @ 2003-11-19 12:43 UTC (permalink / raw)


Hi people,

Chris McMahan wrote on 18 Nov 2003 22:12:35 MET:

> e-other-window can be found at:
> http://relativity.yi.org/el/e-other-window.el

> ;;; map it to the standard keybinding to swith windows
> (defun cm-other-window ()
>   (interactive)
>   (other-window 1)
>   (e-other-window-blink)
>   )
> (global-set-key "\C-xo" 'cm-other-window)

Isn't it precisely what e-other-window does ?

Btw, I had this problem several times already: what is the standard
way to change one window background color ? In e-other-window, they
use an overlay to change the color of the face. The problem with that
solution is that it changes the color of non-empty lines only ...
(which lead to ugliness such as *modifying* empty buffer by inserting
a '\n', cf. e-other-window-blink).

Regards,

-- 
François Fleuret

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-19 12:43       ` François Fleuret
@ 2003-11-19 14:48         ` Chris McMahan
  2003-11-19 17:01           ` Kevin Rodgers
  0 siblings, 1 reply; 11+ messages in thread
From: Chris McMahan @ 2003-11-19 14:48 UTC (permalink / raw)



I tried loading e-other-window without the cm-other-window function
defined or mapped, and it had no effect by itself. 

cm-other-window is the only way I know to get it working... I'd
welcome any suggestions :)

- Chris

François Fleuret <francois.fleuret@inria.fr> writes:

> Hi people,
> 
> Chris McMahan wrote on 18 Nov 2003 22:12:35 MET:
> 
> > e-other-window can be found at:
> > http://relativity.yi.org/el/e-other-window.el
> 
> > ;;; map it to the standard keybinding to swith windows
> > (defun cm-other-window ()
> >   (interactive)
> >   (other-window 1)
> >   (e-other-window-blink)
> >   )
> > (global-set-key "\C-xo" 'cm-other-window)
> 
> Isn't it precisely what e-other-window does ?
> 
> Btw, I had this problem several times already: what is the standard
> way to change one window background color ? In e-other-window, they
> use an overlay to change the color of the face. The problem with that
> solution is that it changes the color of non-empty lines only ...
> (which lead to ugliness such as *modifying* empty buffer by inserting
> a '\n', cf. e-other-window-blink).
> 
> Regards,
> 
> -- 
> François Fleuret

-- 
     (.   .)
  =ooO=(_)=Ooo========================
  Chris McMahan | cmcmahan-at-one.net
  ====================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-19 14:48         ` Chris McMahan
@ 2003-11-19 17:01           ` Kevin Rodgers
  0 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2003-11-19 17:01 UTC (permalink / raw)


Chris McMahan wrote:

> I tried loading e-other-window without the cm-other-window function
> defined or mapped, and it had no effect by itself. 


That's apparently because all the defadvice forms are commented out.


> cm-other-window is the only way I know to get it working... I'd
> welcome any suggestions :)

(defadvice other-window (after e-other-window-blink activate)
   "Blink the currently selected window so that it is obvious what is going on."
   (e-other-window-blink))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it
  2003-11-18 21:12     ` Chris McMahan
  2003-11-19 12:43       ` François Fleuret
@ 2003-11-22  9:32       ` Clemens Fischer
  1 sibling, 0 replies; 11+ messages in thread
From: Clemens Fischer @ 2003-11-22  9:32 UTC (permalink / raw)


* 2003-11-18 Chris McMahan:

> I've got the following code that flashes the newly-selected
> window. The latest version of emacs has faces for mode-line and
> mode-line-inactive that will allow you to change their appearance.
>
> e-other-window can be found at:
> http://relativity.yi.org/el/e-other-window.el

thanks for this pointer, but my problem is slightly different.  i
would like to have in indicator on the (selected-window) for the
entire duration the cursor is in it.  a star `*' maybe in the
mode-line.  just flushing it would improve the situation, but i'd soon
forget which window "beeped" last.

thanks for your help,

  clemens

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it (solved)
  2003-11-18 19:01   ` Kevin Rodgers
  2003-11-18 21:12     ` Chris McMahan
@ 2003-11-22 11:37     ` Clemens Fischer
       [not found]     ` <mailman.439.1069506956.399.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 11+ messages in thread
From: Clemens Fischer @ 2003-11-22 11:37 UTC (permalink / raw)


* 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: highlight current window/modeline after switching to it (solved)
       [not found]     ` <mailman.439.1069506956.399.help-gnu-emacs@gnu.org>
@ 2003-11-24 18:33       ` Kevin Rodgers
  0 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2003-11-24 18:33 UTC (permalink / raw)


Clemens Fischer wrote:

> 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?


Yes.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-11-24 18:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-13 20:27 highlight current window/modeline after switching to it clemens fischer
2003-11-16 19:36 ` Clemens Fischer
     [not found] ` <mailman.213.1069158630.399.help-gnu-emacs@gnu.org>
2003-11-18 19:01   ` Kevin Rodgers
2003-11-18 21:12     ` Chris McMahan
2003-11-19 12:43       ` François Fleuret
2003-11-19 14:48         ` Chris McMahan
2003-11-19 17:01           ` Kevin Rodgers
2003-11-22  9:32       ` Clemens Fischer
2003-11-22 11:37     ` highlight current window/modeline after switching to it (solved) Clemens Fischer
     [not found]     ` <mailman.439.1069506956.399.help-gnu-emacs@gnu.org>
2003-11-24 18:33       ` Kevin Rodgers
     [not found] <mailman.64.1068806323.399.help-gnu-emacs@gnu.org>
2003-11-14 16:37 ` highlight current window/modeline after switching to it Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).