On Mon, Jul 18, 2016 at 9:40 AM Stefan Monnier <
address@hidden> wrote:
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.
Yes, post-command-hook works fine for my use case.
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.
I see what you mean. I tried that. If I wanted to do something like that, C-x 4 c (indirect buffer cloning) seems like a good solution.
> 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.
Got it. Below works
(setq nlinum--current-line (save-excursion ; works
(unless (bolp)
(forward-line 0))
(nlinum--line-number-at-pos)))
> 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.
Do you mean that the commented code to remove text properties from last/current lines should have worked?
Here is a longish gif video (1 min 20 secs) demonstrating the issue I see when removing text properties from the whole visible window vs just curr+last lines:
http://i.imgur.com/GN3zTlJ.gifv
Note that nlinum--current-line-update is called in post-command-hook.
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.
OK, I will then stick with linum inheritance in the defface itself so that people can change that in their themes if they wish.
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.
OK, I have made that change locally; will be seen in the final patch.
> 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.
Thanks for confirming.
> +(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).
Correct. nlinum--last-line does not need to be a defvar; I have now made it a let-bound var. I did not understand why nlinum--current-line should be renamed as nlinum--last-line; because that var is storing the current line number and we are using that to highlight the current line number.
> +(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.
I did not understand this too. I refer to the remove-text-properties action as "flushing". That function is updating the nlinum--current-line defvar and removing text properties from the whole visible window (or not working presently, current and last lines).