all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: code.falling@gmail.com, Emacs developers <emacs-devel@gnu.org>
Subject: Re: Patch to highlight current line number [nlinum.el]
Date: Mon, 18 Jul 2016 15:28:04 +0000	[thread overview]
Message-ID: <CAFyQvY1=+70eNbCmZtKVLmaat-JN23xBB32FsOnaaFg20o1T-w@mail.gmail.com> (raw)
In-Reply-To: <jwv1t2rhz7f.fsf-monnier+emacs@gnu.org>

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

Thanks Stefan,

My comments are below.

On Mon, Jul 18, 2016 at 9:40 AM Stefan Monnier <monnier@iro.umontreal.ca>
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).
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 6083 bytes --]

  reply	other threads:[~2016-07-18 15:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15 17:10 Patch to highlight current line number [nlinum.el] Kaushal Modi
2016-07-16  2:15 ` Stefan Monnier
2016-07-18  4:31   ` Kaushal Modi
2016-07-18 13:40     ` Stefan Monnier
2016-07-18 15:28       ` Kaushal Modi [this message]
2016-07-18 17:09         ` Stefan Monnier
2016-07-18 22:05           ` Kaushal Modi
2016-07-18 22:55             ` Kaushal Modi
2016-07-19  0:32             ` Stefan Monnier
2016-07-19  5:00               ` Kaushal Modi
2016-07-19 12:28                 ` Stefan Monnier
2016-07-19 12:40                   ` Kaushal Modi
2016-07-20 19:30                     ` Stefan Monnier
2016-07-20 19:38                       ` Kaushal Modi
2016-07-20 20:28                         ` Stefan Monnier
2016-07-20 20:31                           ` Kaushal Modi

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='CAFyQvY1=+70eNbCmZtKVLmaat-JN23xBB32FsOnaaFg20o1T-w@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=code.falling@gmail.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 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.