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: [PATCH] Re: Proposal to change cursor appearance to indicate region activation Date: Thu, 22 Jan 2015 05:38:34 +0000 Message-ID: References: <1366426478.1624.YahooMailClassic@web141106.mail.bf1.yahoo.com> <78667428-5c03-402b-8d42-5342079d9bfd@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1421905205 21278 80.91.229.3 (22 Jan 2015 05:40:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Jan 2015 05:40:05 +0000 (UTC) Cc: Drew Adams , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 22 06:40:01 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 1YEAUq-0000om-GQ for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 06:40:00 +0100 Original-Received: from localhost ([::1]:51289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEAUp-0006Jt-Qy for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 00:39:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEAUc-0006Jn-Tm for emacs-devel@gnu.org; Thu, 22 Jan 2015 00:39:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEAUZ-0005tQ-Kf for emacs-devel@gnu.org; Thu, 22 Jan 2015 00:39:46 -0500 Original-Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:51009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEAUZ-0005tE-FN for emacs-devel@gnu.org; Thu, 22 Jan 2015 00:39:43 -0500 Original-Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id E5C03172070; Thu, 22 Jan 2015 06:39:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "Cc" Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id VATLlWzfH-eK; Thu, 22 Jan 2015 06:39:37 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 21F6D172077; Thu, 22 Jan 2015 06:39: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::196 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:181552 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier wrote on 23 Nov 2013: >> (add-hook 'deactivate-mark-hook (lambda () (setq cursor-type t))) >> (add-hook 'activate-mark-hook (lambda () (setq cursor-type 'bar))) > > I like the idea, but this collides with other uses of cursor-type. > Could someone cook up a patch which only does the above if cursor-type > has not been modified (and which lets users opt-out if they prefer). > Also, the patch should directly modify deactivate-mark and activate-mark > rather than using the hooks. Ok. Patch attached below. With dynamic-cursor-mode turned off, it won't interfere with other uses of cursor-type. And if you enable/disable dynamic-cursor-mode buffer-locally, it won't interfere with other uses of cursor-type in other buffers. In fact I have a couple of minor modes in my own packages that rely on this separation. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dynamic-cursor-mode.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,12 @@ (declare-function x-selection-exists-p "xselect.c" (&optional selection terminal)) +(defcustom dynamic-cursor-mode 't + "If non-nil, `cursor-type' is set dynamically to reflect `mark-active'." + :type 'boolean + :version "25.1" + :group 'editing-basics) + (defun deactivate-mark (&optional force) "Deactivate the mark. If Transient Mark mode is disabled, this function normally does @@ -4430,6 +4436,7 @@ ((eq transient-mark-mode 'lambda) (setq transient-mark-mode nil))) (setq mark-active nil) + (if dynamic-cursor-mode (setq cursor-type 't)) (run-hooks 'deactivate-mark-hook) (redisplay--update-region-highlight (selected-window)))) @@ -4445,3 +4452,4 @@ + (if dynamic-cursor-mode (setq cursor-type 'bar)) (run-hooks 'activate-mark-hook)))) (defun set-mark (pos) --=-=-=--