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: Re: Setting cursor-type does not trigger redisplay of cursor Date: Tue, 01 Nov 2005 14:51:01 +0100 Message-ID: <87ll08a33u.fsf@xemacs.org> References: <87mzkpbs9v.fsf@xemacs.org> <874q6wn313.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1130856347 21429 80.91.229.2 (1 Nov 2005 14:45:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2005 14:45:47 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 01 15:45:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EWxNP-0003rh-8P for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Nov 2005 15:44:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWxNO-00039Y-Ex for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Nov 2005 09:44:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EWwXb-0007z7-6y for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2005 08:51:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EWwXZ-0007yi-WB for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2005 08:51:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWwXZ-0007yd-NS for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2005 08:51:05 -0500 Original-Received: from [195.29.150.97] (helo=ls405.htnet.hr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EWwXZ-0008VE-Q5 for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2005 08:51:06 -0500 Original-Received: from ls422.t-com.hr (ls422.t-com.hr [195.29.150.237]) by ls405.htnet.hr (0.0.0/8.12.10) with ESMTP id jA1Dp3Wl008353; Tue, 1 Nov 2005 14:51:03 +0100 Original-Received: from ls422.t-com.hr (localhost.localdomain [127.0.0.1]) by ls422.t-com.hr (Qmlai) with ESMTP id C365C988043; Tue, 1 Nov 2005 14:51:03 +0100 (CET) X-Envelope-Sender: hniksic@xemacs.org X-Envelope-Sender: hniksic@xemacs.org Original-Received: from ls422.t-com.hr (localhost.localdomain [127.0.0.1]) by ls422.t-com.hr (Qmlai) with ESMTP id C04CF988042; Tue, 1 Nov 2005 14:51:03 +0100 (CET) Original-Received: from localhost.localdomain (83-131-1-237.adsl.net.t-com.hr [83.131.1.237]) by ls422.t-com.hr (Qmlai) with ESMTP id 01B678B8060; Tue, 1 Nov 2005 14:51:02 +0100 (CET) Original-Received: by localhost.localdomain (Postfix, from userid 1000) id 2A968380028; Tue, 1 Nov 2005 14:51:01 +0100 (CET) Original-To: Juri Linkov In-Reply-To: <874q6wn313.fsf@jurta.org> (Juri Linkov's message of "Tue, 01 Nov 2005 11:18:16 +0200") 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:13825 Archived-At: Juri Linkov writes: >> (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. > > As I see, this works correctly in the CVS version. Are you sure? It sometimes requires a bit more testing for the bug to appear. Also, if you modify frame parameters off post-command-hook with your code, that might trigger redisplay in its own right. > There is no function `set-cursor-type' in CVS. I use the patch > below. Note that it changes frame parameters instead of the > buffer-local variable `cursor-type'. I think this causes less > trouble. Why? If anything, cursor type should be *window*-local. Then, if you change the cursor based on buffer contents (as my hook does), it is wrong to modify it for the entire frame. After all, frames can and do have more than one window. > + (defun set-cursor-type (cursor-type) > + "Set the text cursor type of the selected frame to CURSOR-TYPE. > + When called interactively, prompt for the name of the type to use. > + To get the frame's current cursor type, use `frame-parameters'." > + (interactive (list (intern (completing-read > + "Cursor type: " > + '("box" "hollow" "bar" "hbar" nil))))) > + (modify-frame-parameters (selected-frame) > + (list (cons 'cursor-type cursor-type)))) > + Setting the cursor type interactively does not appear useful. This command would IMHO needlessly clutter the command namespace.