all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How add one to column # on modeline (%c) so starts from _1_?
@ 2002-09-26  5:35 seberino
  2002-09-26  5:52 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: seberino @ 2002-09-26  5:35 UTC (permalink / raw)


%c on modeline gives column number but it
starts at 0 which is silly...

How add 1 to this so starts at 1???

(%c + 1) doesn't do it of course.

Chris
-- 
_______________________________________

Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Rd. Rm. A339
San Diego, CA 92152-6147
U.S.A.

Phone: (619) 553-7940
Fax:   (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________

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

* Re: How add one to column # on modeline (%c) so starts from _1_?
  2002-09-26  5:35 How add one to column # on modeline (%c) so starts from _1_? seberino
@ 2002-09-26  5:52 ` Eli Zaretskii
  2002-10-07 17:49   ` seberino
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2002-09-26  5:52 UTC (permalink / raw)
  Cc: help-gnu-emacs


On Wed, 25 Sep 2002 seberino@spawar.navy.mil wrote:

> %c on modeline gives column number but it
> starts at 0 which is silly...
> 
> How add 1 to this so starts at 1???
> 
> (%c + 1) doesn't do it of course.

Try the (:eval FORM) construct.

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

* Re: How add one to column # on modeline (%c) so starts from _1_?
  2002-09-26  5:52 ` Eli Zaretskii
@ 2002-10-07 17:49   ` seberino
  0 siblings, 0 replies; 6+ messages in thread
From: seberino @ 2002-10-07 17:49 UTC (permalink / raw)
  Cc: help-gnu-emacs

Eli

Thanks for this tip!
I read Emacs Lisp manual on this and followed the example.
After some tweaking I can get eval to print something without
an error by adding following to modeline list....

'(:eval "%c + 1")

The ' and the double quotes are necessary.


The above will print "0 + 1" on the modeline when in the first column.

*****How can I tell Emacs to evaluate the *addition* in quotes rather
     than just interpret it as a /string/????

Chris

On Thu, Sep 26, 2002 at 07:52:58AM +0200, Eli Zaretskii wrote:
> 
> On Wed, 25 Sep 2002 seberino@spawar.navy.mil wrote:
> 
> > %c on modeline gives column number but it
> > starts at 0 which is silly...
> > 
> > How add 1 to this so starts at 1???
> > 
> > (%c + 1) doesn't do it of course.
> 
> Try the (:eval FORM) construct.
> 
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

-- 
_______________________________________

Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Rd. Rm. A339
San Diego, CA 92152-6147
U.S.A.

Phone: (619) 553-7940
Fax:   (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________

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

* RE: How add one to column # on modeline (%c) so starts from _1_?
@ 2002-10-08  9:39 Victor Kirk
  2002-10-08 19:33 ` seberino
  0 siblings, 1 reply; 6+ messages in thread
From: Victor Kirk @ 2002-10-08  9:39 UTC (permalink / raw)




> '(:eval "%c + 1")

> The above will print "0 + 1" on the modeline when in the first column.

This is because it thre result is a string which contains those characters.
What you need to do is 

 o convert %c to an int  - (string-to-int "%c")
 o add one to this value - (+ (string-to-int "%c") 1)
 o Return the result as a string (format "%s" (+ (string-to-int "%c") 1))

> How can I tell Emacs to evaluate the *addition* in quotes rather
> than just interpret it as a /string/????

Thus try 

(:eval (format "%s" (+ (string-to-int "%c") 1)))

And don't forget to use column-number-mode!

Vic
--



This message, including attachments, is intended only for the use by the
person(s) to whom it is addressed. It may contain information which is
privileged and confidential. Copying or use by anybody else is not
authorised. If you are not the intended recipient, please contact the sender
as soon as possible. The views expressed in this communication may not
necessarily be the views held by Serco Integrated Transport.

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

* Re: How add one to column # on modeline (%c) so starts from _1_?
  2002-10-08  9:39 Victor Kirk
@ 2002-10-08 19:33 ` seberino
  2002-10-09 14:34   ` ken
  0 siblings, 1 reply; 6+ messages in thread
From: seberino @ 2002-10-08 19:33 UTC (permalink / raw)
  Cc: help-gnu-emacs

Thanks for the help!!!!! 

I implemented your suggestion in my mode line def....

 (setq default-mode-line-format (list ""
                                 'mode-line-buffer-identification
                                 "     "
                                 (system-name)
                                 "     "
                                 '(:eval (format "%s" (+ (string-to-int "%c") 1))) 
                                 "Line %l Col %c"))

Indeed the eval part delivers a "1".  The problem is that the "1" is
not updated as columnn number changes.... it just stays "1" for all
time....

What did you mean by "column-number-mode"??? Perhaps that would
solve problem of updating the eval line continuously????

Chris


On Tue, Oct 08, 2002 at 10:39:57AM +0100, Victor Kirk wrote:
> 
> 
> > '(:eval "%c + 1")
> 
> > The above will print "0 + 1" on the modeline when in the first column.
> 
> This is because it thre result is a string which contains those characters.
> What you need to do is 
> 
>  o convert %c to an int  - (string-to-int "%c")
>  o add one to this value - (+ (string-to-int "%c") 1)
>  o Return the result as a string (format "%s" (+ (string-to-int "%c") 1))
> 
> > How can I tell Emacs to evaluate the *addition* in quotes rather
> > than just interpret it as a /string/????
> 
> Thus try 
> 
> (:eval (format "%s" (+ (string-to-int "%c") 1)))
> 
> And don't forget to use column-number-mode!
> 
> Vic
> --
> 
> 
> 
> This message, including attachments, is intended only for the use by the
> person(s) to whom it is addressed. It may contain information which is
> privileged and confidential. Copying or use by anybody else is not
> authorised. If you are not the intended recipient, please contact the sender
> as soon as possible. The views expressed in this communication may not
> necessarily be the views held by Serco Integrated Transport.
> 
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

-- 
_______________________________________

Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Rd. Rm. A339
San Diego, CA 92152-6147
U.S.A.

Phone: (619) 553-7940
Fax:   (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________

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

* Re: How add one to column # on modeline (%c) so starts from _1_?
  2002-10-08 19:33 ` seberino
@ 2002-10-09 14:34   ` ken
  0 siblings, 0 replies; 6+ messages in thread
From: ken @ 2002-10-09 14:34 UTC (permalink / raw)
  Cc: Victor Kirk, help-gnu-emacs


It's generally a good idea to be clear about the "big picture" 
surrounding the issue at hand.  I'm not sure what it is in this case, 
but I'm guessing that you're wanting the modeline to show the column 
number of the cursor (in emacs-speak: the "point").  It might also be 
wagered that this is more for the sake of intellectual curiosity.

If the goal is the first, you could put this in your ~/.emacs:

; set line numbering on
(setq-default line-number-mode t)

If the goal is more the second, you might want to have a look at the 
elisp source now and again as you compose your code.


hth,
ken

-- 
AMD crashes?  See http://cleveland.lug.net/~ken/amd-problem/.

Spake seberino@spawar.navy.mil at 12:33 (UTC-0700) on Tue, 8 Oct 2002:

= Thanks for the help!!!!! 
= 
= I implemented your suggestion in my mode line def....
= 
=  (setq default-mode-line-format (list ""
=                                  'mode-line-buffer-identification
=                                  "     "
=                                  (system-name)
=                                  "     "
=                                  '(:eval (format "%s" (+ (string-to-int "%c") 1))) 
=                                  "Line %l Col %c"))
= 
= Indeed the eval part delivers a "1".  The problem is that the "1" is
= not updated as columnn number changes.... it just stays "1" for all
= time....
= 
= What did you mean by "column-number-mode"??? Perhaps that would
= solve problem of updating the eval line continuously????
= 
= Chris
= 
= 
= On Tue, Oct 08, 2002 at 10:39:57AM +0100, Victor Kirk wrote:
= > 
= > 
= > > '(:eval "%c + 1")
= > 
= > > The above will print "0 + 1" on the modeline when in the first column.
= > 
= > This is because it thre result is a string which contains those characters.
= > What you need to do is 
= > 
= >  o convert %c to an int  - (string-to-int "%c")
= >  o add one to this value - (+ (string-to-int "%c") 1)
= >  o Return the result as a string (format "%s" (+ (string-to-int "%c") 1))
= > 
= > > How can I tell Emacs to evaluate the *addition* in quotes rather
= > > than just interpret it as a /string/????
= > 
= > Thus try 
= > 
= > (:eval (format "%s" (+ (string-to-int "%c") 1)))
= > 
= > And don't forget to use column-number-mode!
= > 
= > Vic
= > --
= > 
= > 
= > 
= > This message, including attachments, is intended only for the use by the
= > person(s) to whom it is addressed. It may contain information which is
= > privileged and confidential. Copying or use by anybody else is not
= > authorised. If you are not the intended recipient, please contact the sender
= > as soon as possible. The views expressed in this communication may not
= > necessarily be the views held by Serco Integrated Transport.
= > 
= > 
= > _______________________________________________
= > Help-gnu-emacs mailing list
= > Help-gnu-emacs@gnu.org
= > http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
= 
= 

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

end of thread, other threads:[~2002-10-09 14:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-26  5:35 How add one to column # on modeline (%c) so starts from _1_? seberino
2002-09-26  5:52 ` Eli Zaretskii
2002-10-07 17:49   ` seberino
  -- strict thread matches above, loose matches on Subject: below --
2002-10-08  9:39 Victor Kirk
2002-10-08 19:33 ` seberino
2002-10-09 14:34   ` ken

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.