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 22:46:49 -0700 (PDT) Message-ID: <58ef0b19-cbc4-42df-86e4-6407ef77752f@default> 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> <874kor9wk4.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="10471"; 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 07:47:17 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 1kARnh-0002b5-1q for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 07:47:17 +0200 Original-Received: from localhost ([::1]:38296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kARng-0005Sp-0Y for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Aug 2020 01:47:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kARnM-0005Sb-6S for help-gnu-emacs@gnu.org; Tue, 25 Aug 2020 01:46:56 -0400 Original-Received: from userp2130.oracle.com ([156.151.31.86]:58362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kARnJ-0007e9-Tz for help-gnu-emacs@gnu.org; Tue, 25 Aug 2020 01:46:55 -0400 Original-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07P5dOGV008502; Tue, 25 Aug 2020 05:46:52 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=58kbImlMxNb9f7qfmKJkfWOtLZ84nNCQW2FgYSwx9RM=; b=neKh3gEOtsqrVD8tkKtXkfc87b+7U+wH5MELxGNrJeVjIzgz8ssmPx+JUv8zpnekasHf 86L5aMAKmFJQDYvBAjZBszAEMjHguspJy8k2PUxufjpEjUWtVPtzMbhu3E4OLipne4/0 PuDIJpWx00JC6BJKh94TKLC5GhfdtAkjh1GsV2TJ7/5HhjsJ9SyEKtv4WHvmFq3tHFDB ahIuTvW8qvHP0deZs1k0Hz/XWzcbuSV/agJCOk64NECyAg5ujivJydjg1/jykQZ3XDgl otGKiMScosfaEcY1ZsNyg/DIUD1GQ9ASqvAuql7h3ElBKuue5behgt2ILTVBCYTM1G7r 2w== Original-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 333csj0b4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 25 Aug 2020 05:46:51 +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 07P5el9p077216; Tue, 25 Aug 2020 05:46:51 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 333r9jfdn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Aug 2020 05:46:51 +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 07P5koRW031888; Tue, 25 Aug 2020 05:46:50 GMT In-Reply-To: <874kor9wk4.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=905 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250044 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 clxscore=1015 spamscore=0 priorityscore=1501 impostorscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=898 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008250044 Received-SPF: pass client-ip=156.151.31.86; envelope-from=drew.adams@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/25 01:46:52 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:123757 Archived-At: > > (put 'insert-char 'delete-selection t) >=20 > OK, so that's the syntax. This must be a very arcane > way of configuration. I did use `put' but only to > enable and disable, as in >=20 > (put 'help-for-help 'disabled t) >=20 > But, what are properties and how do I know what > properties a function has? https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Properties= .html Ask Emacs: `C-h i m Elisp i symbol property' A Lisp symbol is an object of sorts. It has a name and possibly other properties/attributes: * a name - `symbol-name' * a function value - `symbol-function' * a variable value - `symbol-value' * a property list - `symbol-plist' And you can add any other properties you like. Enjoy. > And how do I write a function with properties? (I > don't think I want to, in general, but I always want > to do things I didn't do, at least once...) As I think I said before, it's not really the function that has properties. It's the function symbol - the symbol whose `symbol-function' is the function named with the function's name (which is also the symbol's name). (defun foo ...) (symbol-function 'foo) =3D> foo ; symbol with name "foo" (setq foo 42) (symbol-value 'foo) =3D> 42 See also `C-h f symbol-plist'. > > 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) >=20 > `insert-char'? Sure, that's ONE way to insert, but > there are many other ways to insert things, and not > just a single char,=20 It was an _example_. A command whose `delete-selection' property is defined to kill, not delete. To show that you can change the behavior to kill instead of only delete. > and then (if you desire this > functionality to begin with, that is) then you > _always_ want the selection to be killed, I think is > the objective here? It presumably is your objective, if you use `kill'. Again, an _example_ of getting kill behavior. Do I think you'd likely really prefer to have `insert-char' kill instead of delete? No. But you might. Or some library might. > Anyway, I don't get it to work: >=20 > (delete-selection-mode) ; t > (put 'insert-char 'delete-selection 'kill) ; kill > I type this > set-mark-command > beginning-of-line > set-mark-command > s ("I type this" disappears, the letter s appears) > yank > "I type this" does NOT appear In your example, the kill behavior applies to `insert-char', not to `self-insert-command', which is what `s' is bound to. So don't expect that when you type `s' to replace the active region you can then yank what was deleted. If you instead select some text and use `C-x 8 RET' `LATIN CAPITAL LETTER M', then the selected text is replaced by `M', AND it's put in the kill ring. Maybe using `insert-char' to illustrate wasn't the best choice. I did so because it was the first one in `delsel.el' after `self-insert-command' (which is a special case). > Here is a 19-liner how to do it: > (delete-selection-mode) > (defun delete-selection-pre-hook () > (when (and delete-selection-mode > (use-region-p) > (not buffer-read-only) ) > (if (member this-command '(self-insert-command insert-char insert) ) > (delete-selection-helper 'kill) > (delete-selection-helper > (and (symbolp this-command) > (get this-command 'delete-selection) ))))) You don't need to redefine `delete-selection-pre-hook'. You typically need only put a `delete-selection' property on a command's symbol, to get the behavior you want for it, which is just delete-the-selection in most cases, i.e., value `t'. And most people will never need to do even that. They'll just use the out-of-the-box behavior. People who add commands that insert or do some other things might want to configure them to take advantage of `delete-selection-mode'. And even then, they mostly just use `t': delete. You didn't ask how to use `delete-selection-mode'. I think you asked about its various behaviors and configuring them by putting properties on command symbols. It can do more than your average "select and type to replace".