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

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

Setting cursor-type does not trigger redisplay of cursor


From: Hrvoje Niksic
Subject: Setting cursor-type does not trigger redisplay of cursor
Date: Mon, 31 Oct 2005 16:49:48 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.4.1 (i386-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2005-03-17 on trouble, modified by Debian
configured using `configure '--build=i386-linux' '--host=i386-linux' 
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' 
'--localstatedir=/var/lib' '--infodir=/usr/share/info' 
'--mandir=/usr/share/man' '--with-pop=yes' '--with-x=yes' 
'--with-x-toolkit=athena' 'CFLAGS=-DDEBIAN -g -O2' 'build_alias=i386-linux' 
'host_alias=i386-linux''
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

I wanted to set cursor-type off post-command-hook with the intention
of changing the cursor appearance depending on whether the point is at
the end of line/buffer or not.  (This emulates an XEmacs feature of
showing a thin cursor at the end of line.)  Something like:

(defun set-cursor-adaptive ()
  (setq cursor-type (if (eq (char-after (point)) ?\n) '(bar . 5) t)))
(add-hook 'post-command-hook 'set-cursor-adaptive)

However, it turns out that this doesn't work as well as it should --
apparently changing `cursor-type' does not affect the shape of the
cursor until after it is redrawn, either by changing the position of
point, or by redrawing the frame.  I can work around that by calling
(sit-for 0), but it seems wasteful to invoke redisplay after every
single command.  I ended up checking whether the cursor would actually
change, and calling (sit-for 0) then, like this:

(defun set-cursor-adaptive ()
  (let ((type (let ((c (char-after (point))))
                (if (or (eq c ?\n) (null c))
                    '(bar . 5)
                  t))))
    (if (not (equal cursor-type type))
        (progn
          (setq cursor-type type)
          (sit-for 0)))))
(add-hook 'post-command-hook 'set-cursor-adaptive)

To summarize, changing the cursor type should IMO automatically
refresh the cursor when the event loop is reentered, without the user
having to do anything special.  This would be consistent with the rest
of Emacs, which doesn't require Lisp code to explicitly trigger
redisplay -- it simply happens when necessary.




reply via email to

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