unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Displaying the window number in the mode line?
@ 2003-05-22  1:14 myrkraverk
  0 siblings, 0 replies; 4+ messages in thread
From: myrkraverk @ 2003-05-22  1:14 UTC (permalink / raw)


Hi,

I've made a crude hack to jump to a window with specific number, the
functions are available at

  http://www.emacswiki.org/cgi-bin/wiki.pl?SwitchingWindows

and have been revised a little by better elisp hackers than me :)

This has resulted in my desire to display the window[1] number in the
mode line.  So far I've the following function to evalute the number
of the selected window:

(defun my-window-number ()
  (number-to-string
   (1- (length (memq (selected-window) (nreverse
					(window-list)))))))

Then I create this list with items I want to show in the modeline:

(setq window-number-string
      (list "W"
 	'(:eval (my-window-number)) " "))

And add it to the global-mode-string:

(add-to-list 'global-mode-string '("" window-number-string))

But I only get an "W " in the modeline, the number doesn't show up!
Can anyone tell my why this is and how to do it?

And so people won't get confused, I'm using GNU Emacs version 21.[23].


Thanks in advange,

Johann

1 Emacs terminology, this has nothing to do with an os or even a
  window system. 

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

* Re: Displaying the window number in the mode line?
       [not found] <mailman.6560.1053566934.21513.help-gnu-emacs@gnu.org>
@ 2003-05-22 11:46 ` Joakim Hove
  2003-05-22 13:21   ` myrkraverk
  2003-05-23  9:25 ` Oliver Scholz
  1 sibling, 1 reply; 4+ messages in thread
From: Joakim Hove @ 2003-05-22 11:46 UTC (permalink / raw)



myrkraverk@users.sourceforge.net writes:

> Hi,
>
> I've made a crude hack to jump to a window with specific number, the
> functions are available at
>
>   http://www.emacswiki.org/cgi-bin/wiki.pl?SwitchingWindows
>
> and have been revised a little by better elisp hackers than me :)

Looks interesting!

> This has resulted in my desire to display the window[1] number in the
> mode line.  So far I've the following function to evalute the number
> of the selected window:
>
> (defun my-window-number ()
>   (number-to-string
>    (1- (length (memq (selected-window) (nreverse
> 					(window-list)))))))
>
> Then I create this list with items I want to show in the modeline:
>
> (setq window-number-string
>       (list "W"
>  	'(:eval (my-window-number)) " "))
>

I can not really help you - but some comments:

1. The *global*-mode-string is just that - i.e. it is gloablly shared
   among all windows (and even frames) - hence any code which simply
   sets global-mode-string to some value will result in the same value
   displayed in all windows. So (as far as I can see)
   global-mode-string is not the variable to use - others can maybe
   suggeste another variable to use for this?

> And add it to the global-mode-string:
>
> (add-to-list 'global-mode-string '("" window-number-string))

2. global-mode-string is a string - not a list. The following
   implements (my understanding of) what you want to achieve, but with
   the caveat mentioned above:

     (setq global-mode-string (format "Window: %s" (my-window-number)))
   
   The natural solution (if you can solve problem 1) above, would be
   to wrap this in a function, and then add this function as a hook
   called when splitting windows (I don't know if there is any such
   hook).

Good Luck


Joakim

-- 
Joakim Hove  / hove@bccs.no  /  (55 5) 84076

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

* Re: Displaying the window number in the mode line?
  2003-05-22 11:46 ` Joakim Hove
@ 2003-05-22 13:21   ` myrkraverk
  0 siblings, 0 replies; 4+ messages in thread
From: myrkraverk @ 2003-05-22 13:21 UTC (permalink / raw)
  Cc: help-gnu-emacs

Hi,

Joakim Hove writes:
 > 
 > myrkraverk@users.sourceforge.net writes:
 > 
 > > I've made a crude hack to jump to a window with specific number, the
 > > functions are available at
 > >
 > >   http://www.emacswiki.org/cgi-bin/wiki.pl?SwitchingWindows
 > >
 > 
 > Looks interesting!
 > 
 > > This has resulted in my desire to display the window[1] number in the
 > > mode line.  So far I've the following function to evalute the number
 > > of the selected window:

 > 1. The *global*-mode-string is just that - i.e. it is gloablly shared
 >    among all windows (and even frames) - hence any code which simply
 >    sets global-mode-string to some value will result in the same value
 >    displayed in all windows. So (as far as I can see)

The (:eval ..) construct is though unique to each modeline.

 > 2. global-mode-string is a string - not a list. The following

Actually, global-mode-string is a list, and now there are two methods
that show the window number in the modeline at the above url.  The
latter is a fixed version of what I was trying to do.


Thanx though,

Johann

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

* Re: Displaying the window number in the mode line?
       [not found] <mailman.6560.1053566934.21513.help-gnu-emacs@gnu.org>
  2003-05-22 11:46 ` Joakim Hove
@ 2003-05-23  9:25 ` Oliver Scholz
  1 sibling, 0 replies; 4+ messages in thread
From: Oliver Scholz @ 2003-05-23  9:25 UTC (permalink / raw)


myrkraverk@users.sourceforge.net writes:
[...]
> This has resulted in my desire to display the window[1] number in the
> mode line.  So far I've the following function to evalute the number
> of the selected window:
>
> (defun my-window-number ()
>   (number-to-string
>    (1- (length (memq (selected-window) (nreverse
> 					(window-list)))))))
>
> Then I create this list with items I want to show in the modeline:
>
> (setq window-number-string
>       (list "W"
>  	'(:eval (my-window-number)) " "))
>
> And add it to the global-mode-string:
>
> (add-to-list 'global-mode-string '("" window-number-string))
[...]

(add-to-list 'global-mode-string window-number-string)

    Oliver
-- 
4 Prairial an 211 de la Révolution
Liberté, Egalité, Fraternité!

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

end of thread, other threads:[~2003-05-23  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-22  1:14 Displaying the window number in the mode line? myrkraverk
     [not found] <mailman.6560.1053566934.21513.help-gnu-emacs@gnu.org>
2003-05-22 11:46 ` Joakim Hove
2003-05-22 13:21   ` myrkraverk
2003-05-23  9:25 ` Oliver Scholz

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