emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Advice needed on modeline customization hack...


From: Perry E. Metzger
Subject: Advice needed on modeline customization hack...
Date: Sat, 15 Apr 2017 21:28:00 -0400

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                address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]