help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Box cursor at EoL


From: Marcus Harnisch
Subject: Re: Box cursor at EoL
Date: Wed, 5 Oct 2022 17:34:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

Hi Rainer

On 05/10/2022 17.16, Dr Rainer Woitok wrote:
being in the process of "converting" from XEmacs to Emacs I currently am
missing XEmacs' habbit  of using a  different cursor shape  for a cursor
sitting on an invisible EoL character  as opposed to a cursor sitting on
an as invisible trailing blank.   I always loved  this feature of XEmacs
because I've always hated unnoticed trailing blanks :-)

Been there, done that. Here's a snippet from my ‘init.el’:

;; Turns out I really missed this from XEmacs
(defvar cursor-type-at-eol '(bar . 5)
  "Cursor shape to use when point moves to end of line.

XEmacs nostalgia, which gives a nice visual cue about trailing
whitespace.

See also `change-cursor-at-end-of-line'.")

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

;; 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)

Kind regards,
Marcus








reply via email to

[Prev in Thread] Current Thread [Next in Thread]