unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Perry E. Metzger" <perry@piermont.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Advice needed on modeline customization hack...
Date: Sun, 16 Apr 2017 10:46:33 -0400	[thread overview]
Message-ID: <20170416104633.1768bbb6@jabberwock.cb.piermont.com> (raw)
In-Reply-To: <jwvzifgzbta.fsf-monnier+gmane.emacs.devel@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On Sun, 16 Apr 2017 10:07:25 -0400 Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> > instead. The big question for me right now is what to name the
> > knob, believe it or not.  
> 
> Suggestion of the day: perry-metzger-s-anonymous-knob ?

I'm trying column-number-mode-starts-from-zero instead. :P

Opinions on the attached patches? If there is consensus that they
could go in, I'll update the appropriate docs as well. (And should
column-number-mode-starts-from-zero be in simple.el where I put it?)

Perry
-- 
Perry E. Metzger		perry@piermont.com

[-- Attachment #2: column.diff --]
[-- Type: application/octet-stream, Size: 3776 bytes --]

diff --git a/etc/refcards/gnus-logo.pdf b/etc/refcards/gnus-logo.pdf
deleted file mode 100644
index 3629a605e6..0000000000
Binary files a/etc/refcards/gnus-logo.pdf and /dev/null differ
diff --git a/lisp/bindings.el b/lisp/bindings.el
index f641865ba3..47d9596176 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -368,12 +368,19 @@ mode-line-position
 mouse-1: Display Line and Column Mode Menu")))
     (line-number-mode
      ((column-number-mode
-       (10 ,(propertize
-	     " (%l,%c)"
-	     'local-map mode-line-column-line-number-mode-map
-	     'mouse-face 'mode-line-highlight
-	     'help-echo "Line number and Column number\n\
+       (column-number-mode-starts-from-zero
+        (10 ,(propertize
+              " (%l,%c)"
+              'local-map mode-line-column-line-number-mode-map
+              'mouse-face 'mode-line-highlight
+              'help-echo "Line number and Column number\n\
 mouse-1: Display Line and Column Mode Menu"))
+        (10 ,(propertize
+              " (%l,%C)"
+              'local-map mode-line-column-line-number-mode-map
+              'mouse-face 'mode-line-highlight
+              'help-echo "Line number and Column number\n\
+mouse-1: Display Line and Column Mode Menu")))
        (6 ,(propertize
 	    " L%l"
 	    'local-map mode-line-column-line-number-mode-map
@@ -381,12 +388,19 @@ mode-line-position
 	    'help-echo "Line Number\n\
 mouse-1: Display Line and Column Mode Menu"))))
      ((column-number-mode
-       (5 ,(propertize
-	    " C%c"
-	    'local-map mode-line-column-line-number-mode-map
-	    'mouse-face 'mode-line-highlight
-	    'help-echo "Column number\n\
-mouse-1: Display Line and Column Mode Menu"))))))
+       (column-number-mode-starts-from-zero
+        (5 ,(propertize
+             " C%c"
+             'local-map mode-line-column-line-number-mode-map
+             'mouse-face 'mode-line-highlight
+             'help-echo "Column number\n\
+mouse-1: Display Line and Column Mode Menu"))
+        (5 ,(propertize
+             " C%C"
+             'local-map mode-line-column-line-number-mode-map
+             'mouse-face 'mode-line-highlight
+             'help-echo "Column number\n\
+mouse-1: Display Line and Column Mode Menu")))))))
   "Mode line construct for displaying the position in the buffer.
 Normally displays the buffer percentage and, optionally, the
 buffer size, the line number and the column number.")
diff --git a/lisp/simple.el b/lisp/simple.el
index 5f70adedc4..f7d83903fa 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -7198,6 +7198,10 @@ column-number-mode
 If called from Lisp, enable the mode if ARG is omitted or nil."
   :global t :group 'mode-line)
 
+(defvar column-number-mode-starts-from-zero t
+  "When set to true, Column Number mode displays columns starting from zero.
+Otherwise, column numbers start from one.")
+
 (define-minor-mode size-indication-mode
   "Toggle buffer size display in the mode line (Size Indication mode).
 With a prefix argument ARG, enable Size Indication mode if ARG is
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;

  reply	other threads:[~2017-04-16 14:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170416104633.1768bbb6@jabberwock.cb.piermont.com \
    --to=perry@piermont.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).