emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Proposal to change cursor appearance to indicate region acti


From: David Kastrup
Subject: Re: [PATCH] Proposal to change cursor appearance to indicate region activation
Date: Wed, 28 Jan 2015 12:24:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Kelly Dean <address@hidden> writes:

> +(define-minor-mode dynamic-cursor-mode
> +  "Toggle Dynamic Cursor mode.
> +With a prefix argument ARG, enable Dynamic Cursor mode if ARG is
> +positive, and disable it otherwise.  If called from Lisp, enable
> +Dynamic Cursor mode if ARG is omitted or nil.
> +
> +Dynamic Cursor mode is a global minor mode.  When enabled,
> +`cursor-type' is set dynamically to reflect `mark-active'.
> +
> +Dynamic Cursor mode can be enabled or disabled buffer-locally
> +using (setq-local dynamic-cursor-mode t)
> +or (setq-local dynamic-cursor-mode nil).
> +This will override the global setting.
> +
> +Setting `cursor-type' globally or buffer-locally will automatically
> +disable Dynamic Cursor mode in the same environment."
> +  :global t
> +  :init-value t)
> +
> +(defvar cursor-type-varhook nil)
> +(add-hook 'cursor-type-varhook
> +       (lambda (_sym env)
> +         (if (eq env 'global)
> +             (setq-default dynamic-cursor-mode nil)
> +           (if (eq env 'buffer-local)
> +               (setq-local dynamic-cursor-mode nil)))))
> +(put 'cursor-type 'varhook 'cursor-type-varhook)

Ugh.  That's implementing and using a sledgehammer (and one which slows
down any variable access on a symbol with properties) on a comparatively
straightforward problem, resulting in pretty inscrutable code.  I don't
think that this approach is worth the complexity.

As to the varhook feature itself: apart from the performance impact, it
also has the problem that one cannot usefully manipulate such a varhook
using add-hook or remove-hook.  That makes it a feature that does not
scale to multiple applications (like variable profiling).

-- 
David Kastrup



reply via email to

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