From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Another Emacs incompatibilty Date: Mon, 24 Aug 2020 21:09:50 -0700 (PDT) Message-ID: References: <86r1s648dc.fsf@shell.gmplib.org> <86wo1xz4lt.fsf@shell.gmplib.org> <83imdhgsqo.fsf@gnu.org> <86blj9xc2z.fsf@shell.gmplib.org> <87blj8gbmh.fsf@ericabrahamsen.net> <878secyj10.fsf@ebih.ebihd> <875z9gg5qm.fsf@ericabrahamsen.net> <83sgckftm5.fsf@gnu.org> <87pn7owmjn.fsf@ebih.ebihd> <83mu2sfrci.fsf@gnu.org> <87o8n1nmxl.fsf@ebih.ebihd> <59772f2d-8346-43ae-b9de-d7016dc49797@default> <87ft8bmxuq.fsf@ebih.ebihd> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19080"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 25 06:12:16 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAQJj-0004pO-T0 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 06:12:15 +0200 Original-Received: from localhost ([::1]:48742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAQJi-0007Mg-V0 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 00:12:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAQJR-0007MN-0E for help-gnu-emacs@gnu.org; Tue, 25 Aug 2020 00:11:57 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:45174) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAQJP-0003zX-0a for help-gnu-emacs@gnu.org; Tue, 25 Aug 2020 00:11:56 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07P49CnF061502; Tue, 25 Aug 2020 04:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=P6AJr6ya2267M1vTOYTY+/EjdrzzOX7zQsMmp5DTihA=; b=NT+QL6vYK5vRfsNFkvPyVTaFI9HkJdURq1BFXrL7+NsoujdpAxsKol1ZuFnl0cL0geKV g395kssBCS/stKfDXJLcnkV3g2oFqDvnTmgR029aduGwlJXlSIxXXkCjtOiviOCMQmcN /ULWKNCHu3q2IjjkYNEKFqSjiiOm5ciFVm4FMpr6WCeCyA3n5BWrSHUmrqQYx71AUiRB 1Fr+1lyQpdEsrZ8mh3wRr2l7UXtRS5YeOkcF6OtLoKLlqLCas/21u6xuxmmRvuSH8Vsr yJZJyj87jSxCjoDqx0gs3/6j+LlwcnG7IRpFtzVGcjOaP487KdoiXfR2zHdpxKIaqto4 og== Original-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 333w6tpjtu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 25 Aug 2020 04:11:53 +0000 Original-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07P40k1c147798; Tue, 25 Aug 2020 04:09:52 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 333r9jdf7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Aug 2020 04:09:52 +0000 Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07P49qtx026067; Tue, 25 Aug 2020 04:09:52 GMT In-Reply-To: <87ft8bmxuq.fsf@ebih.ebihd> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5044.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250030 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250031 Received-SPF: pass client-ip=156.151.31.85; envelope-from=drew.adams@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/25 00:08:29 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.956, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:123753 Archived-At: [Sending again, explicitly ccing help-gnu-emacs@gnu.org this time. I need to remember that "Reply All" to you doesn't work, at least not with my mail client (Outlook).] > >> Is it currently possible, if d-s-m is active, to > >> easily retrieve the deleted/replaced item? > > > > Yes, on a per-command basis. >=20 > OK, I have an idea for a rule guys, whenever someone > asks if something is possible, please do not just > answer "yes" whenever it is, also show how one is > suppose to actually do it :) FWIW, I didn't only offer that one-liner in that msg. And another message of mine in this thread cited how it's done, quoting what `delsel.el' says about it. ;; Commands which will delete the selection need ;; a `delete-selection' property on their symbols... https://lists.gnu.org/archive/html/help-gnu-emacs/2020-08/msg00105.html But OK. Someone asked _how_ to put that property on a command's symbol, or perhaps the question was also what a command's _symbol_ is. How is described in the Commentary of library `delsel.el'. (Old-school: doc in the file itself.) Anyway, here's what you do: To make command `insert-char' first delete the selection (active region), before performing its action (which is to insert one or more chars), put property `delete-selection' on the symbol `insert-char' - the symbol whose `symbol-function' is the function name "insert-char". Give the property the value `t'. (put 'insert-char 'delete-selection t) That's all. Without that property, i.e., if (get 'insert-char 'delete-selection) is nil, `delete-selection-mode' has no effect on the given command (`insert-char') - the command just does its normal thing. `insert-char is already set up that way for `delete-selection-mode' (it deletes the selection first), in `delsel.el'. But if you want `insert-char' to do nothing besides insert its arg chars, i.e., not kill and not delete the selection first, do this, to override its default behavior in `delete-selection-mode': (put 'insert-char 'delete-selection nil) Or if you instead want `insert-char' to kill the selected text (so you can later yank it) instead of just deleting it, add this to your init file, to override the default behavior: (put 'insert-char 'delete-selection 'kill) That gives you the same effect as using `C-w' when the region's active, before using the command in question (`insert-char', here). (But unlike `C-w', it has no effect if the region is not active - which is the case when `transient-mark-mode' is off.) And if you have your own command `foo', which does , and you want it to first delete the active region, then do this: (put 'foo 'delete-selection t) And if you want to override the normal behavior of your command `tata' and ONLY delete the active region, then do this: (put 'tata 'delete-selection 'supersede) And if you want your command `titi' to delete the selection sometimes, and kill it other times, before it does whatever else it does normally, then do this: (put 'titi 'delete-selection 'titi-kill/del) where `titi-kill/del' is a function that DTRT to the active region: kill, delete, or nothing at all, according to the current context - phase of the moon, your pulse rate, the number of kilometers you've ridden your bike so far today, roll of phantom dice... Does this help? If not, just try it - try various `delete-selection' values for a few commands. The default `delete-selection' behavior (value `t') is the "select-and-type-to-replace" behavior that's fairly common outside Emacs.