unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36361: 'hl-line-range-function' as list of choice
@ 2019-06-24 16:30 Sebastian Urban
  2019-07-08 23:51 ` Lars Ingebrigtsen
  2021-10-26 18:48 ` Howard Melman
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Urban @ 2019-06-24 16:30 UTC (permalink / raw)
  To: 36361

Because 'hl-line-mode' highlight logical line instead of screen line
when 'visual-line-mode' is active, and for example 'C-a' and 'C-e'
change behaviour, some people want 'hl-line-mode' to change the
behaviour as well.  They usually use 'hl-line-range-function' to
define how it should highlight, but... cannot it be made simpler?
Like by making 'hl-line-range-function' a list of choice:
- nil for default behaviour,
- "Screen line" to change to screen line,
- "Function" for user to write what he wants.
I'm writing this from perspective of "Customize" menu.


S. U.


In GNU Emacs 26.2 (build 1, i686-w64-mingw32)
  of 2019-04-13 built on CIRROCUMULUS
Repository revision: fd1b34bfba8f3f6298df47c8e10b61530426f749
Windowing system distributor 'Microsoft Corp.', version 6.1.7601





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#36361: 'hl-line-range-function' as list of choice
  2019-06-24 16:30 bug#36361: 'hl-line-range-function' as list of choice Sebastian Urban
@ 2019-07-08 23:51 ` Lars Ingebrigtsen
  2021-10-26 18:48 ` Howard Melman
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-08 23:51 UTC (permalink / raw)
  To: Sebastian Urban; +Cc: 36361

Sebastian Urban <mrsebastianurban@gmail.com> writes:

> Because 'hl-line-mode' highlight logical line instead of screen line
> when 'visual-line-mode' is active, and for example 'C-a' and 'C-e'
> change behaviour, some people want 'hl-line-mode' to change the
> behaviour as well.  They usually use 'hl-line-range-function' to
> define how it should highlight, but... cannot it be made simpler?
> Like by making 'hl-line-range-function' a list of choice:
> - nil for default behaviour,
> - "Screen line" to change to screen line,
> - "Function" for user to write what he wants.

I think that makes sense, and I think `visual-line-mode' should adjust
`hl-line-range-function' automatically to do the visual line highlight.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#36361: 'hl-line-range-function' as list of choice
  2019-06-24 16:30 bug#36361: 'hl-line-range-function' as list of choice Sebastian Urban
  2019-07-08 23:51 ` Lars Ingebrigtsen
@ 2021-10-26 18:48 ` Howard Melman
  2021-10-26 19:11   ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Howard Melman @ 2021-10-26 18:48 UTC (permalink / raw)
  To: 36361

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.

Howard





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#36361: 'hl-line-range-function' as list of choice
  2021-10-26 18:48 ` Howard Melman
@ 2021-10-26 19:11   ` Eli Zaretskii
  2021-10-26 19:17     ` Howard Melman
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-10-26 19:11 UTC (permalink / raw)
  To: Howard Melman; +Cc: 36361

> From: Howard Melman <hmelman@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)))))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#36361: 'hl-line-range-function' as list of choice
  2021-10-26 19:11   ` Eli Zaretskii
@ 2021-10-26 19:17     ` Howard Melman
  0 siblings, 0 replies; 5+ messages in thread
From: Howard Melman @ 2021-10-26 19:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 36361


> On Oct 26, 2021, at 3:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> 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)))))

That does seem to work well.  Thanks.

I hope visual-line-mode and hl-line-mode can be made to work 
well together out of the box.

Howard





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-26 19:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 16:30 bug#36361: 'hl-line-range-function' as list of choice Sebastian Urban
2019-07-08 23:51 ` Lars Ingebrigtsen
2021-10-26 18:48 ` Howard Melman
2021-10-26 19:11   ` Eli Zaretskii
2021-10-26 19:17     ` Howard Melman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).