From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#13312: 24.3.50; delete selection mode not killing on overwrite Date: Sat, 19 Oct 2013 19:28:45 +0300 Organization: JURTA Message-ID: <87vc0tfcn6.fsf@mail.jurta.org> References: <87wql9i8l5.fsf@mail.jurta.org> <761f4d61-cd53-4371-9744-70f08619c75b@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1382200400 5079 80.91.229.3 (19 Oct 2013 16:33:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2013 16:33:20 +0000 (UTC) Cc: 13312@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 19 18:33:23 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1VXZSn-0006u4-QU for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2013 18:33:18 +0200 Original-Received: from localhost ([::1]:33837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXZSn-0007M0-Es for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2013 12:33:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXZSf-0007Kr-HA for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2013 12:33:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXZSY-0005Zu-Oi for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2013 12:33:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXZSY-0005Zq-Ko for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2013 12:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VXZSX-00089Y-Oe for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2013 12:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2013 16:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13312 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 13312-submit@debbugs.gnu.org id=B13312.138220034631293 (code B ref 13312); Sat, 19 Oct 2013 16:33:01 +0000 Original-Received: (at 13312) by debbugs.gnu.org; 19 Oct 2013 16:32:26 +0000 Original-Received: from localhost ([127.0.0.1]:58095 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXZRx-00088f-Rd for submit@debbugs.gnu.org; Sat, 19 Oct 2013 12:32:26 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:45131 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXZRv-00088U-K5 for 13312@debbugs.gnu.org; Sat, 19 Oct 2013 12:32:24 -0400 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 85845258B9E935; Sat, 19 Oct 2013 09:32:21 -0700 (PDT) In-Reply-To: <761f4d61-cd53-4371-9744-70f08619c75b@default> (Drew Adams's message of "Sat, 19 Oct 2013 08:37:22 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:79391 Archived-At: > Did you read the bug description and the associate StackOverflow > question? The bug is that when you put `kill' as the > `delete-selection' property value on `self-insert-command' the > region is not killed - it is not added to the `kill-ring'. Ah, I thought this is a new bug report from you. But I still can't find a link to the associate StackOverflow question. What I wanted to suggest is to add more self-inserting commands to delsel like `insert-char' and `quoted-insert'. I guess they don't need the same `self-insert-uses-region-functions' like the currently existing `self-insert-iso' doesn't use that. But when you want put `kill' as the `delete-selection' property then it's better to use this code: (put 'self-insert-command 'delete-selection (lambda () (and (not (run-hook-with-args-until-success 'self-insert-uses-region-functions)) 'kill))) It currently doesn't work properly because `kill-region' overwrites the value of `this-command'. This is a bug that can be fixed by this patch that also fixes overwrite-mode for `kill' and puts `delete-selection' on more commands: === modified file 'lisp/delsel.el' --- lisp/delsel.el 2013-01-01 09:11:05 +0000 +++ lisp/delsel.el 2013-10-19 16:24:16 +0000 @@ -78,7 +78,9 @@ (defun delete-active-region (&optional k "Delete the active region. If KILLP in not-nil, the active region is killed instead of deleted." (if killp - (kill-region (point) (mark)) + ;; Prevent `kill-region' from changing the value of `this-command'. + (let (this-command) + (kill-region (point) (mark))) (delete-region (point) (mark))) t) @@ -102,7 +104,13 @@ (defun delete-selection-helper (type) FUNCTION should take no argument and return one of the above values or nil." (condition-case data (cond ((eq type 'kill) - (delete-active-region t)) + (delete-active-region t) + (if (and overwrite-mode + (eq this-command 'self-insert-command)) + (let ((overwrite-mode nil)) + (self-insert-command + (prefix-numeric-value current-prefix-arg)) + (setq this-command 'ignore)))) ((eq type 'yank) ;; Before a yank command, make sure we don't yank the ;; head of the kill-ring that really comes from the @@ -166,6 +174,8 @@ (put 'self-insert-command 'delete-select 'self-insert-uses-region-functions)))) (put 'self-insert-iso 'delete-selection t) +(put 'insert-char 'delete-selection t) +(put 'quoted-insert 'delete-selection t) (put 'yank 'delete-selection 'yank) (put 'clipboard-yank 'delete-selection 'yank) @@ -175,6 +185,7 @@ (put 'delete-backward-char 'delete-selec (put 'backward-delete-char-untabify 'delete-selection 'supersede) (put 'delete-char 'delete-selection 'supersede) +(put 'reindent-then-newline-and-indent 'delete-selection t) (put 'newline-and-indent 'delete-selection t) (put 'newline 'delete-selection t) (put 'open-line 'delete-selection 'kill) @@ -203,9 +214,9 @@ (defun delsel-unload-function () (define-key minibuffer-local-completion-map "\C-g" 'abort-recursive-edit) (define-key minibuffer-local-must-match-map "\C-g" 'abort-recursive-edit) (define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit) - (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank + (dolist (sym '(self-insert-command self-insert-iso insert-char quoted-insert yank clipboard-yank insert-register delete-backward-char backward-delete-char-untabify - delete-char newline-and-indent newline open-line)) + delete-char reindent-then-newline-and-indent newline-and-indent newline open-line)) (put sym 'delete-selection nil)) ;; continue standard unloading nil)