all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Christoph Scholtes <cschol2112@googlemail.com>
Cc: 11496@debbugs.gnu.org
Subject: bug#11496: 24.1.50; Line numbers are not redrawn correctly in linum-mode
Date: Thu, 17 May 2012 09:59:55 -0400	[thread overview]
Message-ID: <jwvr4uilxym.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <4FB46A30.8070703@gmail.com>

> Would it be hard to add the "relative line number" feature with your code?

Depends on how badly you want it and how reliable you want it.
`jit-lock' is not triggered by mere cursor movement, so you need to use
another hook to detect when we move to another line, after which you'll
have to flush all the nlinum overlays and recompute them, and since we
want jit-lock to recompute them (so that all (but only) visible parts of
the buffer get recomputed), that means telling jit-lock to redo the
buffer, which will make it re-font-lock as well.
So it'll be a bit costly.

IOW, you need to hook into nlinum.el's display so it puts relative
numbers (easy), and then add something like

  (add-hook 'post-command-hook
    (lambda () (if (current-line-number-changed-p)
                   (remove-text-properties (point-min) (point-max)
                   '(fontified nil)))))

And of course, post-command-hook will not always be sufficient.


        Stefan


PS: And of course, there's the problem (also present in the linum.el hack)
that the cursor position is a window-property so when the buffer is
shown in various windows the relative line numbers may not make that
much sense in other buffers.  So maybe you'd really want this relative
numbering to be different for every window.





  reply	other threads:[~2012-05-17 13:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-17  1:45 bug#11496: 24.1.50; Line numbers are not redrawn correctly in linum-mode Christoph Scholtes
2012-05-17  2:40 ` Stefan Monnier
2012-05-17  3:02   ` Christoph Scholtes
2012-05-17 13:59     ` Stefan Monnier [this message]
2012-05-17  3:50   ` Juanma Barranquero
2012-05-17 13:49     ` Stefan Monnier
2012-05-17 13:08   ` Johan Bockgård
2012-05-17  9:09 ` martin rudalics
2012-05-17 10:12   ` martin rudalics
2012-05-17 16:15     ` Eli Zaretskii
2012-05-18 17:59       ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=jwvr4uilxym.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=11496@debbugs.gnu.org \
    --cc=cschol2112@googlemail.com \
    /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 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.