From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Joakim Hove Newsgroups: gmane.emacs.help Subject: Re: Displaying the window number in the mode line? Date: Thu, 22 May 2003 13:46:58 +0200 Organization: University of Bergen Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <4yel2rgq4t.fsf@skjellgran.ii.uib.no> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1053604333 22719 80.91.224.249 (22 May 2003 11:52:13 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 22 May 2003 11:52:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Thu May 22 13:52:10 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19IocE-0005u7-00 for ; Thu, 22 May 2003 13:52:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19Iob7-0004cF-Su for gnu-help-gnu-emacs@m.gmane.org; Thu, 22 May 2003 07:51:01 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.e.nsc.no!nsc.no!nextra.com!uio.no!nntp.uib.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 61 Original-NNTP-Posting-Host: skjellgran.ii.uib.no Original-X-Trace: toralf.uib.no 1053604019 73403 129.177.20.52 (22 May 2003 11:46:59 GMT) Original-X-Complaints-To: abuse@uib.no Original-NNTP-Posting-Date: 22 May 2003 11:46:59 GMT User-Agent: Gnus/5.090017 (Oort Gnus v0.17) Emacs/21.2 (gnu/linux) Cancel-Lock: sha1:0WTN6AQkRXi2r/+kwBViF6e5Ylg= Original-Xref: shelby.stanford.edu gnu.emacs.help:113521 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10016 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10016 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