From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Proposal to change cursor appearance to indicate region activation Date: Wed, 28 Jan 2015 09:23:19 +0000 Message-ID: <0cKOQ95j7CUiQLCExsRqM9mvV5ADaC7ZcKGBLr3Ut5G@local> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1422437091 18141 80.91.229.3 (28 Jan 2015 09:24:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 09:24:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 28 10:24:51 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 1YGOrg-000723-GZ for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2015 10:24:48 +0100 Original-Received: from localhost ([::1]:52090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGOrf-0002D4-GE for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2015 04:24:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGOra-00028I-FP for emacs-devel@gnu.org; Wed, 28 Jan 2015 04:24:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGOrX-0005re-89 for emacs-devel@gnu.org; Wed, 28 Jan 2015 04:24:42 -0500 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:42630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGOrX-0005rY-2L for emacs-devel@gnu.org; Wed, 28 Jan 2015 04:24:39 -0500 Original-Received: from mfilter39-d.gandi.net (mfilter39-d.gandi.net [217.70.178.170]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 6064A41C072; Wed, 28 Jan 2015 10:24:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter39-d.gandi.net Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter39-d.gandi.net (mfilter39-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id ft01IpZmEh7l; Wed, 28 Jan 2015 10:24:36 +0100 (CET) X-Originating-IP: 66.220.3.179 Original-Received: from localhost (gm179.geneticmail.com [66.220.3.179]) (Authenticated sender: kelly@prtime.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 0FD2441C075; Wed, 28 Jan 2015 10:24:34 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::197 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:181891 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier wrote: > Of course. But to me the whole point of this exercise is to change > the default. Ok. The attached patch relies on the varhook feature, which I implemented so that it's possible to enable dynamic-cursor-mode by default without causing any conflict with other uses of cursor-type. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dynamic-cursor-mode-2.patch Third hunk adjusted to avoid conflict with current Emacs trunk. --- emacs-24.4/lisp/simple.el +++ emacs-24.4/lisp/simple.el @@ -4391,6 +4391,34 @@ (declare-function x-selection-exists-p "xselect.c" (&optional selection terminal)) +(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) + (defun deactivate-mark (&optional force) "Deactivate the mark. If Transient Mark mode is disabled, this function normally does @@ -4430,6 +4458,8 @@ ((eq transient-mark-mode 'lambda) (setq transient-mark-mode nil))) (setq mark-active nil) + (let ((cursor-type-varhook nil)) + (if dynamic-cursor-mode (setq cursor-type t))) (run-hooks 'deactivate-mark-hook) (redisplay--update-region-highlight (selected-window)))) @@ -4445,3 +4475,5 @@ + (let ((cursor-type-varhook nil)) + (if dynamic-cursor-mode (setq cursor-type 'bar))) (run-hooks 'activate-mark-hook)))) (defun set-mark (pos) --=-=-=--