[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Box cursor at EoL
From: |
Stefan Monnier |
Subject: |
Re: Box cursor at EoL |
Date: |
Thu, 06 Oct 2022 15:34:17 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> (defun change-cursor-at-end-of-line ()
> "Change shape of cursor to value of `cursor-type-at-eol' at end of line.
>
> When the cursor is moved away from end of line, its shape returns
> to its default value. This gives a cue about trailing whitespace
> that is even less in your face than `whitespace-newline-mode'.
>
> Add this to `post-command-hook' to enable the feature."
> (while-no-input
> (if (eolp)
> (setq cursor-type cursor-type-at-eol)
> (setq cursor-type (default-value 'cursor-type))
> )))
I suspect the `while-no-input` makes no difference here.
And the next three lines can be simplified to:
(setq cursor-type
(if (eolp) cursor-type-at-eol (default-value 'cursor-type)))
> ;; Oddly this doesn't seem to always work with Emacs 27.1. Never
> ;; noticed any problem with 26.3.
> (add-hook 'post-command-hook 'change-cursor-at-end-of-line)
Nowadays you could also use the `pre-redisplay-function` hook which
could have some advantages, but in any case the limit of the above
approach is that it can't correctly account for all the cases where the
buffer is displayed in several windows, with some windows' cursor at
EOL and others not :-(
Stefan
- Box cursor at EoL, Dr Rainer Woitok, 2022/10/05
- Re: Box cursor at EoL, Marcus Harnisch, 2022/10/05
- Re: Box cursor at EoL, Dr Rainer Woitok, 2022/10/06
- Re: Box cursor at EoL,
Stefan Monnier <=
- Re: Box cursor at EoL, Marcus Harnisch, 2022/10/06
- Re: Box cursor at EoL, Dr Rainer Woitok, 2022/10/07
- Re: Box cursor at EoL, Eli Zaretskii, 2022/10/07
- Re: Box cursor at EoL, Robert Pluim, 2022/10/07
- Re: Box cursor at EoL, Dr Rainer Woitok, 2022/10/07
- Re: Box cursor at EoL, Eli Zaretskii, 2022/10/07
- Re: Box cursor at EoL, Dr Rainer Woitok, 2022/10/08
- Re: Box cursor at EoL, Eli Zaretskii, 2022/10/08
- Re: Box cursor at EoL, Dr Rainer Woitok, 2022/10/08
- Re: Box cursor at EoL, Eli Zaretskii, 2022/10/08