GNU bug report logs - #36361
'hl-line-range-function' as list of choice

Previous Next

Package: emacs;

Reported by: Sebastian Urban <mrsebastianurban <at> gmail.com>

Date: Mon, 24 Jun 2019 16:31:01 UTC

Severity: wishlist

Full log


Message #14 received at 36361 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Howard Melman <hmelman <at> gmail.com>
Cc: 36361 <at> debbugs.gnu.org
Subject: Re: bug#36361: 'hl-line-range-function' as list of choice
Date: Tue, 26 Oct 2021 22:11:28 +0300
> From: Howard Melman <hmelman <at> gmail.com>
> Date: Tue, 26 Oct 2021 14:48:53 -0400
> 
> FWIW, I've been using the following in Emacs 27.2:
> 
> #+begin_src elisp
>   (defun visual-line-range-function ()
>     "Return a cons cell of positions of begining and end 
>   of the current line in `visual-line-mode`. Meant to be used
>   as the value of `hl-line-range-function`."
>     (save-excursion
>       (cons (progn (beginning-of-visual-line) (point))
>             (progn (beginning-of-visual-line 2) (point)))))
> 
>   (defun set-visual-line-range-function ()
>     (setq-local hl-line-range-function
>                 (if visual-line-mode 'visual-line-range-function nil)))
> 
>   (add-hook 'visual-line-mode-hook 'set-visual-line-range-function)
> #+end_src
> 
> but it seems to conflict with the temporary-goal-column in
> line-move-visual.  If I have a buffer:
> 
> - foo
> - bar
> - zot
> 
> With point just before foo and do C-n twice, the first one moves point
> to just before bar, but the second moves point to the beginning of the
> 3rd line.
> 
> Suggestions for an improved version are welcome.

Try this:

  (defun visual-line-range-function ()
    "Return a cons cell of positions of begining and end 
  of the current line in `visual-line-mode`. Meant to be used
  as the value of `hl-line-range-function`."
    (save-excursion
      (cons (progn (vertical-motion 0) (point))
            (progn (vertical-motion 1) (point)))))




This bug report was last modified 3 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.