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.devel Subject: RE: [External] : Re: Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?] Date: Wed, 7 Jun 2023 02:01:01 +0000 Message-ID: References: <87edmo17v7.fsf@web.de> 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="18154"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ihor Radchenko , "emacs-devel@gnu.org" To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jun 07 04:02:17 2023 Return-path: Envelope-to: ged-emacs-devel@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 1q6iV6-0004ZB-RT for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Jun 2023 04:02:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6iU9-0000QI-1k; Tue, 06 Jun 2023 22:01:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6iU6-0000Pq-4P for emacs-devel@gnu.org; Tue, 06 Jun 2023 22:01:15 -0400 Original-Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6iU2-0001hQ-3f for emacs-devel@gnu.org; Tue, 06 Jun 2023 22:01:13 -0400 Original-Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356IYmHV005691; Wed, 7 Jun 2023 02:01:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=vzaa57IeHA6oIXgm4DyX9WpTDhq0yXR9Wqo7+0FBRzg=; b=c80WTU5yiXRWiPKRpT/RP6pAQKNo3Zti+G+37F8gGmDxuCZjweZmbWK5oRKTOKVNFQMU oc+Z6gSIBceCVQYC+mixHFEPMEn8yaBYAVgVF9OFtgvLgP0WzyDuU+fqi8pBWVhhcFDY WrCowDwDgB0A7JvASnvGlSUY4WbVVsfMU0dUKoYTOp5KT0tfXxEsdQjn0R/1qYFuKqMh eNTOYpVZPq8peTPtrue6RmFuglMjldFC3mamqTQzO2q7961hPDvbC+ANGaVbO7IWzcA9 WnB4Yg0zfM3SgAw35Yn0l9G4q8C2alNL4DJUnIDJxpq1+BRcflEpxlgE4Qq6hM3sKvUI 6g== Original-Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r2a6pgqeh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jun 2023 02:01:06 +0000 Original-Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3571tW2B035983; Wed, 7 Jun 2023 02:01:05 GMT Original-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r2a6qv71u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jun 2023 02:01:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hJsVANO4plqJ6LrW+Ra3oaTzkZk2RMsLcTMpcgtf+pO4B2b2B77VbcvgTeTBDQ7JAoQLdvjXax2LZHGYd1qgc6ZUdPhRVR89JQlGBnwdusJwXmi+6XrkvQJepZJFIQGMWyAOjZixDPOQuhEpUJlm8RSDzrvSx27lOiU5krFC0TTo6TQz4wRwXfmQIAzobh3ue49twguQptin4oVblKVFo+i6B9ALiwH8vuGUdwZ72Lw5ogeDRDUjaQFvn1b/WYpzxXIZW7QmNc4dyMwPYDf8bxXv1HHcx0GPNJK2IrXD3jeyYhu1YhbZyta6nViikWybbbFAEraM5Z4MfE6t14BT5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vzaa57IeHA6oIXgm4DyX9WpTDhq0yXR9Wqo7+0FBRzg=; b=iG2musw3Vxc9lwBYVP6dVxnN1A98h54klm5jPxKTHznT8W/rXQTtRpuV7as702UY46Pey71W0smfvONShJOxzi0+i3sZNgabUSp/FscuyPgZKCJ9Dlu2e9HzkBSd0dcvP3RM6HFbTvwHY4q6WSOOv1tX+kqP3psPzbToVefTiW38k2vXyqKi0tmjUeGtx/CzVhKIedaj/NHZoQpB32SyX/Sa6vXyeNF3CH5t0DEAE2NLZTU2I1VkaAzG2uO9KbqJFhYUPK4+fAk5WzDILcsvY6/JsamWwPfh9FtShyVANwZDNupt7AC7GkB8UjABo1f5tUOOOi9SN+gOIP8OE3MQ4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vzaa57IeHA6oIXgm4DyX9WpTDhq0yXR9Wqo7+0FBRzg=; b=gxl1Lbo14RNsvtFw5xT2IS1KmaHgRmLEzDSsZM9dqOZDyxwglkzvWdkIj7Udgxh9sQKAuAQI5oGw8O0J3gIvHY2IQzGyiRkpfYpNoLJZ9fk0+NqHdxbzGjByCtWH+XE7MXO9kaga40j0aJlLx2UCG4FhL3Y68H4MWvlA6eoPxoY= Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19) by CY8PR10MB6803.namprd10.prod.outlook.com (2603:10b6:930:9a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Wed, 7 Jun 2023 02:01:01 +0000 Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::a995:2ae5:2745:24ff]) by SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::a995:2ae5:2745:24ff%6]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 02:01:01 +0000 Thread-Topic: [External] : Re: Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?] Thread-Index: AQHZmM+5NjLRvaqum0KPCsbMXlQ1Za9+jxqQ In-Reply-To: <87edmo17v7.fsf@web.de> Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR10MB5488:EE_|CY8PR10MB6803:EE_ x-ms-office365-filtering-correlation-id: 455d98b7-d3a7-4e1f-eb96-08db66fb0b74 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XCGUd8fcWrbAFrfrwuX8CNV+N3UDFdw7T29mLrz75eF18dR9O0ZsFWXziTJWGmST2t862pHNyMlFSJT84XyKZu78mzGeJZ2Nz9gwzfFHFXRSpL55OLIiyPz3WXbYfAWvc1+nyR/Vvp8X3/ckiy4yiq0GGvKD6oh2VgSnHNvQTjP4LnxX2+vgGIfhlAXcTGiCZjFQ4cbxTU46EiWs1hbE2IAJ/liecwbIp+QDfkWu2Ar5Adaoi3Hk6RYflD8GvXxcxOItFrbMdgTtaQm5ZZ0FHAv3jkjzKV0GDzPr0PTZHVmw18wiCXfPoEUEMeiOAFEMabvhdWFRulInf4g29O4sT/pjO8U1G36pDSHGvh0wZUOQBbni1fQHGatnHka2Gf2L8ij5g3l0hN4NnchfIDgxEXpy7TFTJAOrLec//WO7ivXWqlCuWWlrt2iXIp9tW4iW8i9P+OVHrSfaJOuDQngr6VsP3Fg1ZN31vzNVfa1tL0fHJO/POdzlgR2DxHRrsnepd8ozcTEZ23OBwbMhc7GoG68nPeySIDkFyTa9/xU8k2rid0nym1e6oObhfGRWMJ1ZmdjRMtvWILy4Xg0z1jwfkuk8cesqA0ZutIAxc34iYgkwnRvoDteaJJ9l4DeqBDy5 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR10MB5488.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(136003)(346002)(366004)(376002)(396003)(451199021)(83380400001)(2906002)(86362001)(33656002)(38070700005)(122000001)(38100700002)(55016003)(41300700001)(316002)(52536014)(5660300002)(8936002)(8676002)(7696005)(478600001)(54906003)(71200400001)(64756008)(66946007)(66556008)(66446008)(66476007)(6916009)(76116006)(4326008)(6506007)(9686003)(26005)(186003)(44832011); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?X/O/MlkXqqkTO/yOtj++rnete9FeFL1JvGnNtv/1GivPLKR5I3QY7fNKHOXL?= =?us-ascii?Q?ITWQrgvVFbIQd7aTjgmvOEXziIatOmHaO5Pr+TaafgYtgVah3gKPbJTujI2F?= =?us-ascii?Q?QE78uyhEYUpkOVRCICs8Q6UFIrrxxdVe6aCZcGa33dh5DTpG2EN5d6Uj+vLs?= =?us-ascii?Q?DnEYuHSv2PSbH1swQ6SikGm3MkukYFJsK+97gWIf8M8ra/T5ol7N+B9Qna6N?= =?us-ascii?Q?2q7dY+eQwQn20pwmTXKagxh3bG1d5bPDRBcVsz8o97ZsswbjK0AqSWT6sjc/?= =?us-ascii?Q?Lxff3sd3NusJPxRk+tm1koJYIPRZ0QP86PodwjkfXP11/F3MHv26lqcLwAQ1?= =?us-ascii?Q?bYj7io1WuuvU6OHSlUkyElbS/kISgXi+PAc9xret7qIURBRLezVyERUPepBz?= =?us-ascii?Q?WbqEJER8eaKRgrxXKdxA/Lm6Z2nhE4mkPg4nystAFCzJW+TWCV3zDywOpC2X?= =?us-ascii?Q?zh2YymQK5SEtdgqc4nEVm5cjDQpczV5o3SVjqJt/dJcQw2ofX7eWDlTEbACP?= =?us-ascii?Q?xAFDlZwSivApejFRuHolHWCHaWioa5kLVB64DLC4OB1Z9faUQeru5l7aCW4C?= =?us-ascii?Q?fBC0mJrOV69kYvIB1ixDOMsh+JsTAfnqUY2u91suH18x7nR6KAc9AijhzTHS?= =?us-ascii?Q?YC X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tQJ+bI79wzQZg+R+6Ese/8KatqCDtJFpA5fYaxL3ALKzh6PGey3InQpydypkW9uNzKflCqk/1BM2hXxcQcCamWdyo4i89ZOv63Zd4Nwz88bf+1WWa5rK5yJt0UG4OJfVDMg7VvpKV66MdbxBKQZ5Abc8bEyCfKwE5vyMibEuWX5SO5f9GAnCKfxP/Snhv8LM0oqtBWvQNGhZSNNFDmmPQwM+3QqnjjdpA43YgLcVExsw/wIcShq3vzM8l79yNUAUaowrovXkn6G2wnzI64p2LDAd6W+67+phT5fWSZ6Mrc1RSXa6fQdLk+M4/FtwLXL1b+BQSB6Wr8eBZbQqn+qimWo7E1PChk2xORCAXuCPk/yMAIyxQJuNJaVt0bP0kT9Zb1meTVgd3G5QMFK1GmWUBl172Vm3tsw15yW33ZdoQWw+0nLvJmVC/Q3MDJxp58SC+9rfgk0b0MfVOoVseDHuWugI4ron7rWc6C41k7MuU0eMxiKyCyvCgAhAqQv2ZGkhKgQuXH7UMNhi6NUy8zCWG53vgFp+AaBUIpd1T9iney84VEvmcUZwaEzyqLOEBBi5YWVXPUVdQ61WInaolPtxujHhO+mlCIN/eHrEZOZG1FH+lcoe1uirZZgRo4ZRYmJdoUgXulLUHbF+YAFzsmBsaEnJTjKL7ILIcAAClooDCXGZ3DeXBT52TCfsp2mBR3w38LH9ckGSbPHfL1DmAylUg8M8vVXUzScFpHwj4L8Ntr83rZ uPCasKnXFaMH5j7pRjNXWKUlHlCEaIzQxRpXcoMRMmUkS3AoIKs0IyRsVZL/Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5488.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 455d98b7-d3a7-4e1f-eb96-08db66fb0b74 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2023 02:01:01.7522 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R9NmClLOoJK0CIAD9ZP7iWdxXBgxAuAFN4d747/Mvi+YFmU3echh0pwHa3AXi6BYU+8jM6DrmLRDfVES4izMBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6803 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_18,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=833 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306070013 X-Proofpoint-ORIG-GUID: 2Tng_E1K1xWB_uVwx6z1UR1HcyffcT_Z X-Proofpoint-GUID: 2Tng_E1K1xWB_uVwx6z1UR1HcyffcT_Z Received-SPF: pass client-ip=205.220.177.32; envelope-from=drew.adams@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306677 Archived-At: > if you use named advices, > debugging and analyzing can be simple. Yes. Naming advice is pretty essential if you want some flexibility - being able to add & remove bits etc. > In the Elisp sources, instead of modifying > the function binding of a variable ... the > bound function could maybe just be changed > to handle all situations. Then the code > would not have to change the variable at all. Not sure what you have in mind there. In the application I spoke of, the value (of `isearch-filter-predicate') gets advised. And advised, and advised,..., accumulating advice to tweak/refine the behavior. And any added advice can get also get removed. A user does this interactively. Any given state of the variable can be saved and restored, so if something (you or something else) changes the variable value for some reason you can easily get back to a previous state if you want. This particular interactive use of advice isn't about the Elisp sources using advice. So I guess it's not quite the same thing you're talking about. > ... advised variables are more like hooks: you > add and remove functions, but you don't set it. Coming back to the example I referred to, yes, that's why I used advice. But with hooks you have only the order of the hook functions to fiddle with. With advice you have greater flexibility. Wrt "you don't set it": You _can_ replace the original effect completely, which is essentially setting it. (And both a variable setting and a replacement advice can be reversed/restored, with some foresight.) Advice lets you do pretty much anything to the behavior. But again, yes, to be able to add/subtract etc. easily you really want to use _named_ advice. > Dunno if it would be worth it that variables which are considered to be > modified by advising should have a special suffix (like "-hook" for > hooks). Or maybe we already more or less have it: "...-function". > `setq'ing such variables in the Emacs sources is probably not user > friendly. By "considered to be" I guess you mean "intended" or "expected" to be. I guess you're talking about a variable that's expected to be used a bit like a hook. That's the case, BTW, for variables such as `isearch-filter-predicate'. (OK, it uses suffix `-predicate' instead of `-function' or `-hook'. But the idea's the same.) > Anyway, I think we (at least I) still learn about the consequences of > having this tool. The "see what is going on" part would maybe be > facilitated if the *Help* pages would show a combined overview showing > which types of advices are applied in which order and at which depth > around an advised function (at least in not trivial cases). +1 to that. I expect more needs to be done wrt the debugger as well, to make what's going on clearer.