all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Box cursor at EoL
Date: Thu, 06 Oct 2022 15:34:17 -0400	[thread overview]
Message-ID: <jwv4jwgu50w.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: thk85c$oqq$1@ciao.gmane.io

> (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




  parent reply	other threads:[~2022-10-06 19:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 15:16 Box cursor at EoL Dr Rainer Woitok
2022-10-05 15:34 ` Marcus Harnisch
2022-10-06 15:53   ` Dr Rainer Woitok
2022-10-06 17:00     ` Marcus Harnisch
2022-10-06 19:34   ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2022-10-06 20:09     ` Marcus Harnisch
2022-10-07  8:28     ` Dr Rainer Woitok
2022-10-07 11:11       ` Eli Zaretskii
2022-10-07 13:49         ` Robert Pluim
2022-10-07 14:56         ` Dr Rainer Woitok
2022-10-07 15:37           ` Eli Zaretskii
2022-10-08  9:03             ` Dr Rainer Woitok
2022-10-08  9:12               ` Eli Zaretskii
2022-10-08  9:37                 ` Dr Rainer Woitok
2022-10-08 10:13                   ` Eli Zaretskii
2022-10-08 13:18                   ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-10-09 15:31                     ` Dr Rainer Woitok
2022-10-05 16:53 ` Eli Zaretskii
2022-10-05 23:44   ` Emanuel Berg
2022-10-17  3:34     ` Kenneth Goldman
2022-10-17  4:06       ` Emanuel Berg
2022-10-18 17:06         ` Kenneth Goldman
2022-10-18 23:07           ` Emanuel Berg
2022-10-06 16:02   ` Dr Rainer Woitok
2022-10-05 23:44 ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2022-10-18  8:29 Anders Munch
2022-10-18 10:22 ` Colin Baxter
2022-10-18 23:28   ` Emanuel Berg
2022-10-18 23:02 ` Emanuel Berg
2022-10-18 10:54 Anders Munch
2022-10-18 11:21 ` Colin Baxter

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=jwv4jwgu50w.fsf-monnier+emacs@gnu.org \
    --to=help-gnu-emacs@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.