unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Advice needed on modeline customization hack...
@ 2017-04-16  1:28 Perry E. Metzger
  2017-04-16  1:55 ` Perry E. Metzger
  2017-04-16  3:11 ` Stefan Monnier
  0 siblings, 2 replies; 31+ messages in thread
From: Perry E. Metzger @ 2017-04-16  1:28 UTC (permalink / raw)
  To: emacs-devel

So I have been irritated for a while by the fact that when you turn
on column-number-mode, that the displayed column starts at zero. GNU
coding standards say that compilers and the like are to spit out error
messages with column numbers starting at one, so what your modeline
tells you and what your error message tells you are off by one.

Of course, this being Emacs, I figure the right thing to do is to add
a customization opportunity so people can get this displayed starting
at one or at zero, as their tastes dictate, and presumably we leave
the default as it is, and then everyone is happy.

The two line patch at the end of this adds a %C modeline construct
that acts just like %c only it displays the modeline with characters
starting at 1 instead of zero. Doing it that way gives you essentially
no extra performance hit. That part turns out to be the easy bit.

Harder is this: short of redefining the entirety of the really, really
long mode-line-position variable from bindings.el, which isn't
something one wants to tell people to casually do in their .emacs
(it's long and complicated as heck), I'm not quite sure how to do a
practical customization here. Then again, I only half understand how
the modeline format stuff works at all, and it seems semantically
rich enough that some reasonable way to do this should exist.

Advice on how to do the elisp half of this so there can be an easy
setting to let you pick one based or zero based?

Perry

diff --git a/src/xdisp.c b/src/xdisp.c
index c6f8566523..f23dbcb585 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23520,6 +23520,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
       break;
 
     case 'c':
+    case 'C':
       /* %c and %l are ignored in `frame-title-format'.
          (In redisplay_internal, the frame title is drawn _before_ the
          windows are updated, so the stuff which depends on actual
@@ -23530,6 +23531,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
       else
 	{
 	  ptrdiff_t col = current_column ();
+	  if (c == 'C') col++;
 	  w->column_number_displayed = col;
 	  pint2str (decode_mode_spec_buf, width, col);
 	  return decode_mode_spec_buf;


-- 
Perry E. Metzger		perry@piermont.com



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

end of thread, other threads:[~2017-05-10 17:59 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-16  1:28 Advice needed on modeline customization hack Perry E. Metzger
2017-04-16  1:55 ` Perry E. Metzger
2017-04-16  3:11 ` Stefan Monnier
2017-04-16 13:49   ` Perry E. Metzger
2017-04-16 14:07     ` Stefan Monnier
2017-04-16 14:46       ` Perry E. Metzger
2017-04-16 15:02         ` Clément Pit-Claudel
2017-04-16 16:09           ` Perry E. Metzger
2017-04-16 20:59             ` Clément Pit-Claudel
2017-04-16 22:06               ` Perry E. Metzger
2017-04-16 22:16                 ` Perry E. Metzger
2017-04-16 22:57                   ` Perry E. Metzger
2017-04-16 23:48                     ` Drew Adams
2017-04-17  0:13                       ` Perry E. Metzger
2017-04-17  6:00                     ` Eli Zaretskii
2017-04-17 12:53                       ` Perry E. Metzger
2017-04-17 14:17                         ` Eli Zaretskii
2017-04-17 15:24                           ` Perry E. Metzger
2017-04-17 15:34                             ` Eli Zaretskii
2017-04-17 18:07                               ` Perry E. Metzger
2017-04-17 18:23                                 ` Eli Zaretskii
2017-04-17 18:55                                   ` Perry E. Metzger
2017-04-17 19:07                                     ` Noam Postavsky
2017-04-17 19:18                                       ` Perry E. Metzger
2017-05-10 17:59                                   ` Eli Zaretskii
2017-04-17 15:21                         ` Perry E. Metzger
2017-04-17 15:31                           ` Eli Zaretskii
2017-04-17 15:55                             ` Perry E. Metzger
2017-04-17 16:13                               ` Eli Zaretskii
2017-04-17  6:02                 ` Eli Zaretskii
2017-04-17 12:32                   ` Perry E. Metzger

Code repositories for project(s) associated with this public inbox

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

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