Actually, after thinking about it, I got to the conclusion that as long
as you don't try to handle the multiple-window case correctly, you're
probably better off with post-command-hook.
More or less. Try M-x nhexl-mode RET and the C-x 5 2 and then move
around the buffer and compare the two window's highlighting of the
"current line". You'll see that only one of the two is correct.
> From quick trial, I saw the line numbers change in the whole buffer even
> when I moved the cursor horizontally.
You need to always call it with point at BOL.
> In the below updated patch, I attempt to do this (code commented out
> in the patch), but failed. I tried removing the text properties on
> the current and last lines, but it is not working. I'll give more
> time to understand tomorrow. But if you can point out the issue with
> those remove-text-properties, that will be great.
Sorry, the problem didn't jump at me. They look pretty good.
Clearly the above change should come with the corresponding change in
nlinum-current-line-face (i.e. it shouldn't inherit from `linum' face
any more). But either way is OK.
Oh, and nowadays the convention is to use "-face" only for
names of variables whose value is a face, but not for the face names
themselves. The font-lock-foo-face faces are the main exceptions
because they're already so omnipresent.
> I have also made one cosmetic change .. Instead of `t' as argument values,
> I have replaced them with `:local' or `:contextual' as appropriate.
Fine. I often use 'local (rather than :local) for that same purpose,
but I don't really care about the color of this shed.
> +(defvar-local nlinum--last-line 0
> + "Store line number where the point was before it moved to the current
> line.")
No reason to keep this as a global var (but I'd rename
nlinum--current-line to nlinum--last-line).
> +(defun nlinum--current-line-update ()
> + "Update current line number, flush text properties for last and current
> line."
Actually, it shouldn't (and doesn't) flush text-properties. It should
only update the current-line highlighting or cause it to be
updated later.
Kaushal Modi