From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: storm@cua.dk (Kim F. Storm) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Oct 2014 16:56:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 18886@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.141460175826937 (code B ref -1); Wed, 29 Oct 2014 16:56:03 +0000 Received: (at submit) by debbugs.gnu.org; 29 Oct 2014 16:55:58 +0000 Received: from localhost ([127.0.0.1]:39155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjWXI-000709-70 for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57366) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjWWd-0006yS-Hr for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjWWR-0007v7-Ig for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWR-0007v1-F1 for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:54:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWL-0004Xz-CX for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjWWC-0007pu-63 for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:53 -0400 Date: Wed, 29 Oct 2014 12:54:53 -0400 Received: from mail1-hoer.fullrate.dk ([90.185.2.131]:43600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWB-0007p8-Uk for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:44 -0400 Received: from kfs-lx2 (1405ds6-amb.0.fullrate.dk [90.184.76.141]) by mail1-hoer.fullrate.dk (Postfix) with SMTP id 5A77DBFAE9 for ; Wed, 29 Oct 2014 17:54:38 +0100 (CET) From: storm@cua.dk (Kim F. Storm) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] Message-ID: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) I have just upgraded from 23.? to 24.4, and found that two (for me) essintial features of cua-mode no longer works: - Deleted text is not saved automatically in register 0 when overwriting highlighted region. - M-v no longer performs the "repeat last replacement" functionality. Both functions are documented in cua-base.el: ;; Typing text replaces the region ;; ------------------------------- ;; When the region is active, i.e. highlighted, the text in region is ;; replaced by the text you type. ;; The replaced text is saved in register 0 which can be inserted using ;; the key sequence M-0 C-v (see the section on register support below). ;; If you have just replaced a highlighted region with typed text, ;; you can repeat the replace with M-v. This will search forward ;; for a stretch of text identical to the previous contents of the ;; region (i.e. the contents of register 0) and replace it with the ;; text you typed to replace the original region. Repeating M-v will ;; replace the next matching region and so on. ;; ;; Example: Suppose you have a line like this ;; The redo operation will redo the last redoable command ;; which you want to change into ;; The repeat operation will repeat the last repeatable command ;; This is done by highlighting the first occurrence of "redo" ;; and type "repeat" M-v M-v. Since the basic functionality has now been split from cua-mode, I think that those functions belongs in delsel (if anywhere). Of course, the M-v binding should still only be active in cua-mode (since cua-mode takes over C-v it can also use M-v). I guess the functionality could be restored by suitable tweaking of the region-extract-function -- I will look into that possibility. -- Kim F. Storm http://www.cua.dk From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Oct 2014 00:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: storm@cua.dk (Kim F. Storm) Cc: 18886@debbugs.gnu.org Received: via spool by 18886-submit@debbugs.gnu.org id=B18886.141463004622265 (code B ref 18886); Thu, 30 Oct 2014 00:48:01 +0000 Received: (at 18886) by debbugs.gnu.org; 30 Oct 2014 00:47:26 +0000 Received: from localhost ([127.0.0.1]:39557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xjdte-0005n3-5F for submit@debbugs.gnu.org; Wed, 29 Oct 2014 20:47:26 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:60182) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xjdtc-0005mo-F4 for 18886@debbugs.gnu.org; Wed, 29 Oct 2014 20:47:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au0MAOatTlRFpY87/2dsb2JhbABcgw6DYoZ+y1MEAgKBHBcBAXyEAwEBAwFWIwULCzQSFBgNiG8Jy3IBAQEBBgEBAQEekEZCB4RLBY9pojeBb4QUIYE3gUMBAQE X-IPAS-Result: Au0MAOatTlRFpY87/2dsb2JhbABcgw6DYoZ+y1MEAgKBHBcBAXyEAwEBAwFWIwULCzQSFBgNiG8Jy3IBAQEBBgEBAQEekEZCB4RLBY9pojeBb4QUIYE3gUMBAQE X-IronPort-AV: E=Sophos;i="5.04,797,1406606400"; d="scan'208";a="95551732" Received: from 69-165-143-59.dsl.teksavvy.com (HELO pastel.home) ([69.165.143.59]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Oct 2014 20:47:18 -0400 Received: by pastel.home (Postfix, from userid 20848) id 729547CFF; Wed, 29 Oct 2014 20:47:18 -0400 (EDT) From: Stefan Monnier Message-ID: References: Date: Wed, 29 Oct 2014 20:47:18 -0400 In-Reply-To: (Kim F. Storm's message of "Wed, 29 Oct 2014 12:54:53 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) Hi Kim, Nice to hear from you again. > I have just upgraded from 23.? to 24.4, and found that two (for me) > essential features of cua-mode no longer works: Hmm.. indeed these have been lost in the move to delsel.el. > Since the basic functionality has now been split from cua-mode, > I think that those functions belongs in delsel (if anywhere). That's right. > Of course, the M-v binding should still only be active in cua-mode > (since cua-mode takes over C-v it can also use M-v). delsel.el can provide the command, and then cua-mode can bind it to M-v. > I guess the functionality could be restored by suitable tweaking of > the region-extract-function -- I will look into that possibility. I think extending delsel.el directly will be easier. Stefan From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: Kim Storm Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Oct 2014 16:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 18886@debbugs.gnu.org Received: via spool by 18886-submit@debbugs.gnu.org id=B18886.141468765829800 (code B ref 18886); Thu, 30 Oct 2014 16:48:02 +0000 Received: (at 18886) by debbugs.gnu.org; 30 Oct 2014 16:47:38 +0000 Received: from localhost ([127.0.0.1]:40714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xjssq-0007kZ-W5 for submit@debbugs.gnu.org; Thu, 30 Oct 2014 12:47:37 -0400 Received: from ispc3.dotserv.com ([178.20.216.13]:39795) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xjssm-0007kF-9s for 18886@debbugs.gnu.org; Thu, 30 Oct 2014 12:47:33 -0400 Received: from localhost (localhost [127.0.0.1]) by ispc3.dotserv.com (Postfix) with ESMTP id D8BF980347849; Thu, 30 Oct 2014 17:47:25 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ispc3.dotserv.com Received: from ispc3.dotserv.com ([127.0.0.1]) by localhost (ispc3.dotserv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3yEbASih+WXF; Thu, 30 Oct 2014 17:47:17 +0100 (CET) Received: from [10.1.82.9] (1405ds6-amb.0.fullrate.dk [90.184.76.141]) (Authenticated sender: storm@cua.dk) by ispc3.dotserv.com (Postfix) with ESMTPSA id 560B680130A9C; Thu, 30 Oct 2014 17:47:17 +0100 (CET) Message-ID: <54526B57.8080508@cua.dk> Date: Thu, 30 Oct 2014 17:46:15 +0100 From: Kim Storm User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 2014-10-30 01:47, Stefan Monnier wrote: > Hi Kim, > > Nice to hear from you again. Yes, I wish I had more time to dedicate to emacs ... but there is just too much to do running my own business. From my first impressions with 24.4, I can see that emacs developments are still going strong! Good work! I have taken a shot at adding the missing cua features to 24.4 I don't have time to try to get up to date with the repository stuff, so I have just included some patches for you to look at -- please commit them if you think they are acceptable (they are only lightly tested so far). Note that the new defcustom is unconditionally set to ?0 by cua-mode if cua-mode-copy-to-register-0 is enabled (default), Also, the new replace command only works if save-to-register is non-nil, as it uses the old-text copy in that register (instead of saving another copy as the original code in cua did). Finally, using a C-u arg should replace until eob according to the doc string -- it actually replaces max 1000000 instances; this is just laziness on my part. Kim --- orig.delsel.el 2014-10-30 14:58:32.000000000 +0100 +++ delsel.el 2014-10-30 17:28:41.000000000 +0100 @@ -54,6 +54,15 @@ ;;; Code: +(defcustom delete-selection-save-to-register + nil + "If non-nil, deleted region text is stored in this register. +Value must be the register (key) to use." + :type '(choice + (const :tag "None" nil) + (character :tag "Register (Key)")) + :group 'editing-basics) + ;;;###autoload (defalias 'pending-delete-mode 'delete-selection-mode) @@ -72,16 +81,73 @@ (remove-hook 'pre-command-hook 'delete-selection-pre-hook) (add-hook 'pre-command-hook 'delete-selection-pre-hook))) +(defvar delsel--replace-text-or-position nil) + (defun delete-active-region (&optional killp) "Delete the active region. If KILLP in not-nil, the active region is killed instead of deleted." - (if killp - ;; Don't allow `kill-region' to change the value of `this-command'. - (let (this-command) - (kill-region (point) (mark) t)) - (funcall region-extract-function 'delete-only)) + (message "delete") + (cond (killp + ;; Don't allow `kill-region' to change the value of `this-command'. + (let (this-command) + (kill-region (point) (mark) t))) + (delete-selection-save-to-register + (set-register delete-selection-save-to-register + (funcall region-extract-function t)) + (setq delsel--replace-text-or-position + (cons (current-buffer) + (and (consp buffer-undo-list) (car buffer-undo-list)))) + ) + (t + (funcall region-extract-function 'delete-only))) t) +(defun delete-selection-repeat-replace-region (arg) + "Repeat replacing text of highlighted region with typed text. +Search for the next stretch of text identical to the region last replaced +by typing text over it and replaces it with the same stretch of text. +With arg, repeat that many times. C-u means until end of buffer." + (interactive "P") + (let ((old-text (and delete-selection-save-to-register + (get-register delete-selection-save-to-register))) + (count (if (consp arg) 1000000 (or (prefix-numeric-value current-prefix-arg) 1)))) + (message "old %s" old-text) + (when (and old-text (> (length old-text) 0)) + ;; If this is the first use after overwriting regions, + ;; find the replacement text by looking at the undo list + (when (consp delsel--replace-text-or-position) + (let ((buffer (car delsel--replace-text-or-position)) + (elt (cdr delsel--replace-text-or-position))) + (setq delsel--replace-text-or-position nil) + (with-current-buffer buffer + (save-restriction + (widen) + ;; Find the text that replaced the region via the undo list. + (let ((ul buffer-undo-list) u s e) + (when elt + (while (consp ul) + (setq u (car ul) ul (cdr ul)) + (cond + ((eq u elt) ;; got it + (setq ul nil)) + ((and (consp u) (integerp (car u)) (integerp (cdr u))) + (if (and s (= (cdr u) s)) + (setq s (car u)) + (setq s (car u) e (cdr u))))))) + (cond ((and s e (<= s e) (= s (mark t))) + (setq delsel--replace-text-or-position (filter-buffer-substring s e)) + (set-text-properties 0 (length delsel--replace-text-or-position) + nil delsel--replace-text-or-position)) + ((and (null s) (eq u elt)) ;; nothing inserted + (setq delsel--replace-text-or-position "")) + (t + (message "Cannot locate replacement text")))))))) + (while (and (> count 0) + delsel--replace-text-or-position + (search-forward old-text nil t nil)) + (replace-match delsel--replace-text-or-position nil t) + (setq count (1- count)))))) + (defun delete-selection-helper (type) "Delete selection according to TYPE: `yank' --- orig.cua-base.el 2014-10-30 15:40:12.000000000 +0100 +++ cua-base.el 2014-10-30 16:16:08.000000000 +0100 @@ -277,7 +277,7 @@ (defcustom cua-remap-control-v t "If non-nil, C-v binding is used for paste (yank). -Also, M-v is mapped to `cua-repeat-replace-region'." +Also, M-v is mapped to `delete-selection-repeat-replace-region'." :type 'boolean :group 'cua) @@ -961,46 +961,6 @@ (if cua--rectangle (cua--rectangle-corner 0)))))) -;; Typed text that replaced the highlighted region. -(defvar cua--repeat-replace-text nil) - -(defun cua-repeat-replace-region (arg) - "Repeat replacing text of highlighted region with typed text. -Searches for the next stretch of text identical to the region last -replaced by typing text over it and replaces it with the same stretch -of text." - (interactive "P") - (when cua--last-deleted-region-pos - (with-current-buffer (car cua--last-deleted-region-pos) - (save-restriction - (widen) - ;; Find the text that replaced the region via the undo list. - (let ((ul buffer-undo-list) - (elt (cdr cua--last-deleted-region-pos)) - u s e) - (when elt - (while (consp ul) - (setq u (car ul) ul (cdr ul)) - (cond - ((eq u elt) ;; got it - (setq ul nil)) - ((and (consp u) (integerp (car u)) (integerp (cdr u))) - (if (and s (= (cdr u) s)) - (setq s (car u)) - (setq s (car u) e (cdr u))))))) - (cond ((and s e (<= s e) (= s (mark t))) - (setq cua--repeat-replace-text (cua--filter-buffer-noprops s e))) - ((and (null s) (eq u elt)) ;; nothing inserted - (setq cua--repeat-replace-text - "")) - (t - (message "Cannot locate replacement text")))))) - (setq cua--last-deleted-region-pos nil)) - (if (and cua--last-deleted-region-text - cua--repeat-replace-text - (search-forward cua--last-deleted-region-text nil t nil)) - (replace-match cua--repeat-replace-text arg t))) - (defun cua-help-for-region (&optional help) "Show region specific help in echo area." (interactive) @@ -1333,7 +1293,7 @@ (define-key cua--cua-keys-keymap [(control z)] 'undo)) (when cua-remap-control-v (define-key cua--cua-keys-keymap [(control v)] 'yank) - (define-key cua--cua-keys-keymap [(meta v)] 'cua-repeat-replace-region)) + (define-key cua--cua-keys-keymap [(meta v)] 'delete-selection-repeat-replace-region)) (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler) (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler) @@ -1469,6 +1429,7 @@ (if (and (boundp 'delete-selection-mode) delete-selection-mode) (delete-selection-mode -1))) (if cua-highlight-region-shift-only (transient-mark-mode -1)) + (if cua-delete-copy-to-register-0 (setq delete-selection-save-to-register ?0)) (cua--deactivate)) (cua--saved-state (if (nth 0 cua--saved-state) From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Oct 2014 19:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Kim Storm Cc: 18886@debbugs.gnu.org Received: via spool by 18886-submit@debbugs.gnu.org id=B18886.141469699118555 (code B ref 18886); Thu, 30 Oct 2014 19:24:01 +0000 Received: (at 18886) by debbugs.gnu.org; 30 Oct 2014 19:23:11 +0000 Received: from localhost ([127.0.0.1]:40855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjvJO-0004pC-N7 for submit@debbugs.gnu.org; Thu, 30 Oct 2014 15:23:10 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53005) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjvJM-0004p4-H6 for 18886@debbugs.gnu.org; Thu, 30 Oct 2014 15:23:09 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s9UJN452003172; Thu, 30 Oct 2014 15:23:04 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 36C42660F3; Thu, 30 Oct 2014 15:23:06 -0400 (EDT) From: Stefan Monnier Message-ID: References: <54526B57.8080508@cua.dk> Date: Thu, 30 Oct 2014 15:23:06 -0400 In-Reply-To: <54526B57.8080508@cua.dk> (Kim Storm's message of "Thu, 30 Oct 2014 17:46:15 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5110=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5110> : inlines <1462> : streams <1330653> : uri <1830513> X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > I don't have time to try to get up to date with the repository stuff, > so I have just included some patches for you to look at -- please > commit them if you think they are acceptable (they are only lightly > tested so far). Thanks, installed into emacs-24, with minor changes (mostly I demoted the defcustom to a defvar, because I think the right fix will be to move the setting to simple.el where it will be configured yet differently (probably allowing delete-active-region to be set to a character)). I think further changes will be needed, tho. E.g. cua-delete-region should probably disappear (i.e. be an alias for delete-active-region). > Note that the new defcustom is unconditionally set to ?0 > by cua-mode if cua-mode-copy-to-register-0 is enabled (default), Right, I added a FIXME about it. > Also, the new replace command only works if save-to-register > is non-nil, as it uses the old-text copy in that register (instead > of saving another copy as the original code in cua did). BTW, I think that instead of scavenging the undo log we should place an overlay at the last delete so we can directly grab the "replacement text". > Finally, using a C-u arg should replace until eob according to the > doc string -- it actually replaces max 1000000 instances; this > is just laziness on my part. I used (point-max) which should work well and is only 4 extra characters ;-) Stefan From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: Kim Storm Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Oct 2014 20:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 18886@debbugs.gnu.org Received: via spool by 18886-submit@debbugs.gnu.org id=B18886.141470164226445 (code B ref 18886); Thu, 30 Oct 2014 20:41:03 +0000 Received: (at 18886) by debbugs.gnu.org; 30 Oct 2014 20:40:42 +0000 Received: from localhost ([127.0.0.1]:40871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjwWP-0006sS-E2 for submit@debbugs.gnu.org; Thu, 30 Oct 2014 16:40:41 -0400 Received: from ispc3.dotserv.com ([178.20.216.13]:51704) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjwWJ-0006s3-GJ for 18886@debbugs.gnu.org; Thu, 30 Oct 2014 16:40:37 -0400 Received: from localhost (localhost [127.0.0.1]) by ispc3.dotserv.com (Postfix) with ESMTP id 44D5C8034783C; Thu, 30 Oct 2014 21:40:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ispc3.dotserv.com Received: from ispc3.dotserv.com ([127.0.0.1]) by localhost (ispc3.dotserv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dFHQsjQ8Y21P; Thu, 30 Oct 2014 21:40:20 +0100 (CET) Received: from [10.1.82.9] (1405ds6-amb.0.fullrate.dk [90.184.76.141]) (Authenticated sender: storm@cua.dk) by ispc3.dotserv.com (Postfix) with ESMTPSA id 887AD80347833; Thu, 30 Oct 2014 21:40:20 +0100 (CET) Message-ID: <5452A1F6.2070303@cua.dk> Date: Thu, 30 Oct 2014 21:39:18 +0100 From: Kim Storm User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 References: <54526B57.8080508@cua.dk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 2014-10-30 20:23, Stefan Monnier wrote: >> I don't have time to try to get up to date with the repository stuff, >> so I have just included some patches for you to look at -- please >> commit them if you think they are acceptable (they are only lightly >> tested so far). > Thanks, installed into emacs-24, with minor changes (mostly I demoted > the defcustom to a defvar, because I think the right fix will be to move > the setting to simple.el where it will be configured yet differently > (probably allowing delete-active-region to be set to a character)). Thank you. > > I think further changes will be needed, tho. E.g. cua-delete-region > should probably disappear (i.e. be an alias for delete-active-region). Yes, it should definitely go away. >> Note that the new defcustom is unconditionally set to ?0 >> by cua-mode if cua-mode-copy-to-register-0 is enabled (default), > Right, I added a FIXME about it. Good. > >> Also, the new replace command only works if save-to-register >> is non-nil, as it uses the old-text copy in that register (instead >> of saving another copy as the original code in cua did). > BTW, I think that instead of scavenging the undo log we should place an > overlay at the last delete so we can directly grab the "replacement text". Yes - I would like to do that, as the current code is deficient in the sense that any movement or editing will terminate the "replacement text". I will try it when I have some time to improve on it. > >> Finally, using a C-u arg should replace until eob according to the >> doc string -- it actually replaces max 1000000 instances; this >> is just laziness on my part. > I used (point-max) which should work well and is only 4 extra characters ;-) Nice ! Kim From unknown Sun Jun 22 11:45:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18886: 24.4; M-v no longer works in CUA-mode. Resent-From: Kim Storm Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Nov 2014 17:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18886 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 18886@debbugs.gnu.org Received: via spool by 18886-submit@debbugs.gnu.org id=B18886.14149479612075 (code B ref 18886); Sun, 02 Nov 2014 17:07:01 +0000 Received: (at 18886) by debbugs.gnu.org; 2 Nov 2014 17:06:01 +0000 Received: from localhost ([127.0.0.1]:46298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XkybJ-0000XH-3e for submit@debbugs.gnu.org; Sun, 02 Nov 2014 12:06:01 -0500 Received: from ispc3.dotserv.com ([178.20.216.13]:50716) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XkybG-0000X3-GO for 18886@debbugs.gnu.org; Sun, 02 Nov 2014 12:05:59 -0500 Received: from localhost (localhost [127.0.0.1]) by ispc3.dotserv.com (Postfix) with ESMTP id 3F52380B74788; Sun, 2 Nov 2014 18:05:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ispc3.dotserv.com Received: from ispc3.dotserv.com ([127.0.0.1]) by localhost (ispc3.dotserv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6uBciXqx4sf8; Sun, 2 Nov 2014 18:05:43 +0100 (CET) Received: from [10.1.82.9] (1405ds6-amb.0.fullrate.dk [90.184.76.141]) (Authenticated sender: storm@cua.dk) by ispc3.dotserv.com (Postfix) with ESMTPSA id C033980387236; Sun, 2 Nov 2014 18:05:43 +0100 (CET) Message-ID: <54566423.6050105@cua.dk> Date: Sun, 02 Nov 2014 18:04:35 +0100 From: Kim Storm User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 References: <54526B57.8080508@cua.dk> <5452A1F6.2070303@cua.dk> In-Reply-To: <5452A1F6.2070303@cua.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 2014-10-30 21:39, Kim Storm wrote: > On 2014-10-30 20:23, Stefan Monnier wrote: >> BTW, I think that instead of scavenging the undo log we should place an >> overlay at the last delete so we can directly grab the "replacement >> text". > Yes - I would like to do that, as the current code is deficient in the > sense > that any movement or editing will terminate the "replacement text". > I will try it when I have some time to improve on it. Hi Stefan, I have made some progress on this: The following patch eliminates the undo-list hack. It works much better than before, as it is now possible to edit the replacement text before repeating the substitution using M-v. This has always been annoying for me, so I really appreciate your suggestion. Since there is only one active replacement text across all buffers, it makes more sense for me to use an overlay to keep track of the replacement text. If you could install this, I would appreciate it very much. Kim |2014-11-02 Kim F. Storm * delsel.el (|||delsel--replace-text-or-position): Delete var. ||||| (delete-selection-replacement-face): New defcustom. ||| (delsel--replace-text, delsel--replace-overlay): New vars. | (delete-active-region, delete-selection-repeat-replace-region): Use overlay to track replacement text instead of abusing the undo-list; this allows the text to be edited before it is used for substitutions. Add highlight to the replacement text. | --- tmp/delsel.el 2014-11-02 17:45:25.440201850 +0100 +++ delsel.el 2014-11-02 17:49:49.000000000 +0100 @@ -54,9 +54,23 @@ ;;; Code: -(defvar delete-selection-save-to-register nil +(defcustom delete-selection-save-to-register nil "If non-nil, deleted region text is stored in this register. -Value must be the register (key) to use.") +Value must be the register (key) to use." + :type '(choice + (const :tag "None" nil) + (character :tag "Register (Key)")) + :group 'editing-basics) + +(defcustom delete-selection-replacement-face 'highlight + "If non-nil, active region replacement text is shown in this face. +The highlighted text is the text that will be inserted by +the `delete-selection-repeat-replace-region' command." + :type 'face + :group 'editing-basics + :set (lambda (symbol value) + (if delsel--replace-overlay + (overlay-put delsel--replace-overlay 'face value)))) ;;;###autoload (defalias 'pending-delete-mode 'delete-selection-mode) @@ -76,7 +90,8 @@ (remove-hook 'pre-command-hook 'delete-selection-pre-hook) (add-hook 'pre-command-hook 'delete-selection-pre-hook))) -(defvar delsel--replace-text-or-position nil) +(defvar delsel--replace-overlay nil) ;overlay +(defvar delsel--replace-text nil) ;text from overlay (defun delete-active-region (&optional killp) "Delete the active region. @@ -89,9 +104,14 @@ (delete-selection-save-to-register (set-register delete-selection-save-to-register (funcall region-extract-function t)) - (setq delsel--replace-text-or-position - (cons (current-buffer) - (and (consp buffer-undo-list) (car buffer-undo-list))))) + (if delsel--replace-overlay + (move-overlay delsel--replace-overlay (point) (point) (current-buffer)) + (setq delsel--replace-overlay + (make-overlay (point) (point) (current-buffer) nil t)) + (if delete-selection-replacement-face + (overlay-put delsel--replace-overlay 'face + delete-selection-replacement-face))) + (setq delsel--replace-text nil)) (t (funcall region-extract-function 'delete-only))) t) @@ -106,47 +126,30 @@ (get-register delete-selection-save-to-register))) (count (if (consp arg) (point-max) (prefix-numeric-value current-prefix-arg)))) - (if (not (and old-text - (> (length old-text) 0) - (or (stringp delsel--replace-text-or-position) - (buffer-live-p (car delsel--replace-text-or-position))))) + (if (not (and old-text (> (length old-text) 0))) (message "No known previous replacement") ;; If this is the first use after overwriting regions, ;; find the replacement text by looking at the undo list. - (when (consp delsel--replace-text-or-position) - (let ((buffer (car delsel--replace-text-or-position)) - (elt (cdr delsel--replace-text-or-position))) - (setq delsel--replace-text-or-position nil) - (with-current-buffer buffer - (save-restriction - (widen) - ;; Find the text that replaced the region via the undo list. - (let ((ul buffer-undo-list) u s e) - (when elt - (while (consp ul) - (setq u (car ul) ul (cdr ul)) - (cond - ((eq u elt) ;; got it - (setq ul nil)) - ((and (consp u) (integerp (car u)) (integerp (cdr u))) - (if (and s (= (cdr u) s)) - (setq s (car u)) - (setq s (car u) e (cdr u))))))) - (cond ((and s e (<= s e) (= s (mark t))) - (setq delsel--replace-text-or-position - (filter-buffer-substring s e)) - (set-text-properties - 0 (length delsel--replace-text-or-position) - nil delsel--replace-text-or-position)) - ((and (null s) (eq u elt)) ;; Nothing inserted. - (setq delsel--replace-text-or-position "")) - (t - (message "Cannot locate replacement text")))))))) - (while (and (> count 0) - delsel--replace-text-or-position - (search-forward old-text nil t)) - (replace-match delsel--replace-text-or-position nil t) - (setq count (1- count)))))) + (when (and (null delsel--replace-text) + delsel--replace-overlay + (buffer-live-p (overlay-buffer delsel--replace-overlay))) + (with-current-buffer (overlay-buffer delsel--replace-overlay) + (let ((s (overlay-start delsel--replace-overlay)) + (e (overlay-end delsel--replace-overlay))) + (when (/= s e) + (setq delsel--replace-text + (filter-buffer-substring s e)) + (set-text-properties + 0 (length delsel--replace-text) + nil delsel--replace-text)))) + (delete-overlay delsel--replace-overlay)) + (if delsel--replace-text + (while (and (> count 0) + delsel--replace-text + (search-forward old-text nil t)) + (replace-match delsel--replace-text nil t) + (setq count (1- count))) + (message "Cannot locate replacement text"))))) (defun delete-selection-helper (type) "Delete selection according to TYPE: From unknown Sun Jun 22 11:45:20 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: storm@cua.dk (Kim F. Storm) Subject: bug#18886: closed (Re: bug#18886: 24.4; M-v no longer works in CUA-mode.) Message-ID: References: X-Gnu-PR-Message: they-closed 18886 X-Gnu-PR-Package: emacs Reply-To: 18886@debbugs.gnu.org Date: Sun, 26 Jun 2016 17:56:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1466963761-14622-1" This is a multi-part message in MIME format... ------------=_1466963761-14622-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #18886: 24.4; M-v no longer works in CUA-mode. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 18886@debbugs.gnu.org. --=20 18886: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D18886 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1466963761-14622-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 18886-done) by debbugs.gnu.org; 26 Jun 2016 17:55:39 +0000 Received: from localhost ([127.0.0.1]:57012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHEHT-0003nD-Nz for submit@debbugs.gnu.org; Sun, 26 Jun 2016 13:55:39 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHEHS-0003mu-9e for 18886-done@debbugs.gnu.org; Sun, 26 Jun 2016 13:55:38 -0400 Received: by mail-oi0-f68.google.com with SMTP id d132so26848827oig.2 for <18886-done@debbugs.gnu.org>; Sun, 26 Jun 2016 10:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to; bh=fOueBBR5LcGRjPW4yH2KXll3pH9icfYM6jqRLKPMPOc=; b=dk/f8k46BedXK5F9ziiKX0RDzEpQXnheyT+VEb1KawPdHmtDOTzc6HvxXMCbzx6dL6 TNSDDi3DqAHmQlBmy4NOyTjD1ZD01KL5onXvLqiUT3PHsnt8d5Y+rsXLFCGQHTy857mr MmwTeHvrt+zTK0sVSqu6bb3RunhhJ1fwSNTjzmUb9BIqcQyPqAbD9e30Tzvr161KY+nv aZyfB0B8iE1ALoS3c7mOfL1UryfrrgWhK7FjOA5awEYjeAtaqt32FujN4s5XHf+tn5Pd I8AOIndYsOQ0H1rXfl6PGEoXXAC+Q1wy9vJn686TczlAIWrOX9Hg/SqOhnxPEqY6dixp GQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=fOueBBR5LcGRjPW4yH2KXll3pH9icfYM6jqRLKPMPOc=; b=LueiJcBFF7Y82lSVzLOTJeIKAIhv5QWtdPnpW8Nupez086mhApMiOivhEgZaH+aw/i yP8y/tRovTmpZsvcG0k8Z9NcDpPznEbC9j/kYE6G+iDepg8o/aYwL3YG3GInA4Qss1h5 a94Jfex5hRwUyIgSfzOjj8zltwc0UiByg9/6mjwmfPUAKe8z6bQeWuOmPsGcJ1Uqc8L2 fEtRZRrFqpeI/KF350ql8NNmnBisNl9ybH2fIVMKZVOwOlZQAoKUvCj2FfAuvFEivjhR jS7Hs23K8W+xwWNmWJciaS7UzzgN7UFeE/s7phVPYnABvg+n/BSfrRuLlBAc6UYQMSdj Szdg== X-Gm-Message-State: ALyK8tL81pEwrIDRzeSOAxKInih/XvZwjMsoxe4JpSbJhW9VU3EReKaoASmuGQAbfPqMdEYWdC4vt+um/n5gdg== X-Received: by 10.157.36.227 with SMTP id z90mr9376522ota.124.1466963732647; Sun, 26 Jun 2016 10:55:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.52.238 with HTTP; Sun, 26 Jun 2016 10:55:32 -0700 (PDT) From: Noam Postavsky Date: Sun, 26 Jun 2016 13:55:32 -0400 X-Google-Sender-Auth: 0Ot1qZFYWWaPvmBXmcSRLGwamGg Message-ID: Subject: Re: bug#18886: 24.4; M-v no longer works in CUA-mode. To: 18886-done@debbugs.gnu.org Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18886-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Version: 24.5 Fixes seem to have been applied in 24.5 ------------=_1466963761-14622-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Oct 2014 16:55:58 +0000 Received: from localhost ([127.0.0.1]:39155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjWXI-000709-70 for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57366) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjWWd-0006yS-Hr for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjWWR-0007v7-Ig for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:55:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWR-0007v1-F1 for submit@debbugs.gnu.org; Wed, 29 Oct 2014 12:54:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWL-0004Xz-CX for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjWWC-0007pu-63 for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:53 -0400 Date: Wed, 29 Oct 2014 12:54:53 -0400 Received: from mail1-hoer.fullrate.dk ([90.185.2.131]:43600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjWWB-0007p8-Uk for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 12:54:44 -0400 Received: from kfs-lx2 (1405ds6-amb.0.fullrate.dk [90.184.76.141]) by mail1-hoer.fullrate.dk (Postfix) with SMTP id 5A77DBFAE9 for ; Wed, 29 Oct 2014 17:54:38 +0100 (CET) From: storm@cua.dk (Kim F. Storm) To: bug-gnu-emacs@gnu.org Subject: 24.4; M-v no longer works in CUA-mode. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] Message-ID: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) I have just upgraded from 23.? to 24.4, and found that two (for me) essintial features of cua-mode no longer works: - Deleted text is not saved automatically in register 0 when overwriting highlighted region. - M-v no longer performs the "repeat last replacement" functionality. Both functions are documented in cua-base.el: ;; Typing text replaces the region ;; ------------------------------- ;; When the region is active, i.e. highlighted, the text in region is ;; replaced by the text you type. ;; The replaced text is saved in register 0 which can be inserted using ;; the key sequence M-0 C-v (see the section on register support below). ;; If you have just replaced a highlighted region with typed text, ;; you can repeat the replace with M-v. This will search forward ;; for a stretch of text identical to the previous contents of the ;; region (i.e. the contents of register 0) and replace it with the ;; text you typed to replace the original region. Repeating M-v will ;; replace the next matching region and so on. ;; ;; Example: Suppose you have a line like this ;; The redo operation will redo the last redoable command ;; which you want to change into ;; The repeat operation will repeat the last repeatable command ;; This is done by highlighting the first occurrence of "redo" ;; and type "repeat" M-v M-v. Since the basic functionality has now been split from cua-mode, I think that those functions belongs in delsel (if anywhere). Of course, the M-v binding should still only be active in cua-mode (since cua-mode takes over C-v it can also use M-v). I guess the functionality could be restored by suitable tweaking of the region-extract-function -- I will look into that possibility. -- Kim F. Storm http://www.cua.dk ------------=_1466963761-14622-1--