From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hrvoje Niksic Newsgroups: gmane.emacs.bugs Subject: Setting cursor-type does not trigger redisplay of cursor Date: Mon, 31 Oct 2005 16:49:48 +0100 Message-ID: <87mzkpbs9v.fsf@xemacs.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1130774233 24120 80.91.229.2 (31 Oct 2005 15:57:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 31 Oct 2005 15:57:13 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 31 16:57:05 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EWbz1-0007d0-Kk for geb-bug-gnu-emacs@m.gmane.org; Mon, 31 Oct 2005 16:54:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWbz0-0005jg-VE for geb-bug-gnu-emacs@m.gmane.org; Mon, 31 Oct 2005 10:54:02 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EWbxY-00052y-55 for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2005 10:52:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EWbv1-0003rB-5E for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2005 10:49:58 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWbux-0003pN-5h for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2005 10:49:53 -0500 Original-Received: from [195.29.150.97] (helo=ls405.htnet.hr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EWbuw-000119-W2 for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2005 10:49:51 -0500 Original-Received: from ls401.t-com.hr (ls401.t-com.hr [195.29.150.236]) by ls405.htnet.hr (0.0.0/8.12.10) with ESMTP id j9VFnnWj014612 for ; Mon, 31 Oct 2005 16:49:49 +0100 Original-Received: from ls401.t-com.hr (localhost.localdomain [127.0.0.1]) by ls401.t-com.hr (Qmlai) with ESMTP id A233470003 for ; Mon, 31 Oct 2005 16:49:49 +0100 (CET) X-Envelope-Sender: hniksic@xemacs.org Original-Received: from localhost.localdomain (83-131-64-105.adsl.net.t-com.hr [83.131.64.105]) by ls401.t-com.hr (Qmlai) with ESMTP id B4067A801B for ; Mon, 31 Oct 2005 16:49:48 +0100 (CET) Original-Received: by localhost.localdomain (Postfix, from userid 1000) id 29440380028; Mon, 31 Oct 2005 16:49:48 +0100 (CET) Original-To: bug-gnu-emacs@gnu.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:13798 Archived-At: 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.