GNU bug report logs -
#36361
'hl-line-range-function' as list of choice
Previous Next
Full log
View this message in rfc822 format
> 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.