unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Setting cursor-type does not trigger redisplay of cursor
@ 2005-10-31 15:49 Hrvoje Niksic
  2005-11-01  9:18 ` Juri Linkov
  0 siblings, 1 reply; 13+ messages in thread
From: Hrvoje Niksic @ 2005-10-31 15:49 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-11-03 21:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-31 15:49 Setting cursor-type does not trigger redisplay of cursor Hrvoje Niksic
2005-11-01  9:18 ` Juri Linkov
2005-11-01 13:51   ` Hrvoje Niksic
2005-11-01 20:03     ` Juri Linkov
2005-11-01 21:07       ` Hrvoje Niksic
2005-11-01 22:08         ` Juri Linkov
2005-11-02 10:27   ` Richard M. Stallman
2005-11-02 14:18     ` Hrvoje Niksic
2005-11-03  7:54       ` Juri Linkov
2005-11-03 13:50       ` Richard M. Stallman
2005-11-03 18:04         ` Hrvoje Niksic
2005-11-03  7:54     ` Juri Linkov
2005-11-03 21:41       ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).