From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Proposal to change cursor appearance to indicate region activation Date: Wed, 28 Jan 2015 12:24:56 +0100 Message-ID: <874mrbcflj.fsf@fencepost.gnu.org> References: <0cKOQ95j7CUiQLCExsRqM9mvV5ADaC7ZcKGBLr3Ut5G@local> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422444322 11766 80.91.229.3 (28 Jan 2015 11:25:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 11:25:22 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 28 12:25:22 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YGQkK-0002c3-IA for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2015 12:25:20 +0100 Original-Received: from localhost ([::1]:52570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQkJ-0001hZ-OP for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2015 06:25:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQk3-0001g6-6J for emacs-devel@gnu.org; Wed, 28 Jan 2015 06:25:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGQjy-000563-4a for emacs-devel@gnu.org; Wed, 28 Jan 2015 06:25:03 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQjy-00055z-17 for emacs-devel@gnu.org; Wed, 28 Jan 2015 06:24:58 -0500 Original-Received: from localhost ([127.0.0.1]:58154 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQjx-0000qj-2D; Wed, 28 Jan 2015 06:24:57 -0500 Original-Received: by lola (Postfix, from userid 1000) id 7CF38E07AB; Wed, 28 Jan 2015 12:24:56 +0100 (CET) In-Reply-To: <0cKOQ95j7CUiQLCExsRqM9mvV5ADaC7ZcKGBLr3Ut5G@local> (Kelly Dean's message of "Wed, 28 Jan 2015 09:23:19 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181895 Archived-At: Kelly Dean 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