emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: blink-cursor improvement suggestion]


From: Kim F. Storm
Subject: Re: address@hidden: blink-cursor improvement suggestion]
Date: 25 Feb 2002 10:51:06 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

Richard Stallman <address@hidden> writes:

> Do people like change?
> 
> From: Ulrich Neumerkel <address@hidden>
> Subject: blink-cursor improvement suggestion
> To: address@hidden
> Date: Sun, 24 Feb 2002 18:21:37 +0100 (MET)
> 

Yes, I think it is an improvement that the cursor never disappears.
However, as implemented, it doesn't work, as it doesn't preserve the
current cursor color, but uses two fixed colors.

I have code which changes the color of the cursor depending on the
current state of the buffer (e.g. read-only, overwrite mode), and
the supplied code works very poorly with that.

I think the code should remember the `true' background color of the
cursor and restore that.  In addition, it should notice if the
cursor color has changed, so it can correctly restore it.

Something like this:

(defvar blink-cursor-defined-color nil)
(defvar blink-cursor-current-color nil)
(defvar blink-cursor-alt-color "gray50")
(defvar blink-cursor-logical-off   nil)

(defun blink-cursor-timer-function ()
  "Improved but flickering timer function of timer `blink-cursor-timer'."
  (let ((bg (face-background 'cursor)))
     (when (not blink-cursor-defined-color)
        (setq blink-cursor-defined-color bg)
        (setq blink-cursor-current-color bg)
        (setq blink-cursor-logical-off t))
     (when (not (equal bg blink-cursor-current-color))
        (setq blink-cursor-defined-color bg))
     (setq blink-cursor-logical-off (not blink-cursor-logical-off))
     (setq blink-cursor-current-color 
        (if blink-cursor-logical-off
             blink-cursor-alt-color
           blink-cursor-defined-color))
     (set-face-background 'cursor blink-cursor-current-color)))

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

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