From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Perry E. Metzger" Newsgroups: gmane.emacs.devel Subject: Advice needed on modeline customization hack... Date: Sat, 15 Apr 2017 21:28:00 -0400 Message-ID: <20170415212800.5be89037@jabberwock.cb.piermont.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1492306129 28033 195.159.176.226 (16 Apr 2017 01:28:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Apr 2017 01:28:49 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 16 03:28:44 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1czYzb-00075m-6D for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 03:28:43 +0200 Original-Received: from localhost ([::1]:58563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czYzd-0003ND-KG for ged-emacs-devel@m.gmane.org; Sat, 15 Apr 2017 21:28:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czYz2-0003Mw-OX for emacs-devel@gnu.org; Sat, 15 Apr 2017 21:28:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czYz1-0003CV-GV for emacs-devel@gnu.org; Sat, 15 Apr 2017 21:28:08 -0400 Original-Received: from hacklheber.piermont.com ([2001:470:30:84:e276:63ff:fe62:3400]:49894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1czYz1-00039N-CA for emacs-devel@gnu.org; Sat, 15 Apr 2017 21:28:07 -0400 Original-Received: from snark.cb.piermont.com (localhost [127.0.0.1]) by hacklheber.piermont.com (Postfix) with ESMTP id F217D213 for ; Sat, 15 Apr 2017 21:28:00 -0400 (EDT) Original-Received: from jabberwock.cb.piermont.com (jabberwock.cb.piermont.com [10.160.2.107]) by snark.cb.piermont.com (Postfix) with ESMTP id D6B462DE040 for ; Sat, 15 Apr 2017 21:28:00 -0400 (EDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:470:30:84:e276:63ff:fe62:3400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213983 Archived-At: 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