Juri Linkov <juri@xxxxxxxxx> 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
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.