unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: highlight current window/modeline after switching to it
Date: Tue, 18 Nov 2003 12:01:46 -0700	[thread overview]
Message-ID: <3FBA6C9A.8090203@yahoo.com> (raw)
In-Reply-To: mailman.213.1069158630.399.help-gnu-emacs@gnu.org

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

  parent reply	other threads:[~2003-11-18 19:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FBA6C9A.8090203@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).