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: Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?] Date: Sat, 3 Jun 2023 15:22:08 +0000 Message-ID: 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="15388"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: Ihor Radchenko , Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 03 17:23:48 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 1q5T6Z-0003nk-NT for ged-emacs-devel@m.gmane-mx.org; Sat, 03 Jun 2023 17:23:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5T5V-0001qK-Qd; Sat, 03 Jun 2023 11:22:52 -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 1q5T5C-0001hy-Il for emacs-devel@gnu.org; Sat, 03 Jun 2023 11:22:26 -0400 Original-Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5T55-00051R-8d for emacs-devel@gnu.org; Sat, 03 Jun 2023 11:22:19 -0400 Original-Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35340Vv8010778; Sat, 3 Jun 2023 15:22:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=/n8081E+f4GF0JFtOm8VMwXRGe7Ue7Nu6AqcaZbtgpI=; b=BWIRR27g0cg8fDGdmD0my+4qEbTEltVS9HrDkXmON+ke1O6khFcb5V5n159n4cFwWy/U 1j7sm2dq939wTJrFTasK5eB6R/1p3Mx6UThUl+oAzAhqrzDXyTwnfXR0XkO2rrY8Grdu dbYpEskeeQsns4Ek1pOtOmvHVodf4F9teTFQizsbwoxHT4G4aGjLz2FqsyuiDmN/B5nT o0n/27ENWzOifOit4IlWxe5VuYZXEqV9T6aVn+6JYMC2Qq1A3z31QdGhYTIqVAUDe8yr ftwED89UsePCxHCmJrgcY7k6ghbADYkDwkQ4vLRwAyhF2hHZ6pfWeGk+CAYo7mbFnkoE gA== Original-Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43rkae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Jun 2023 15:22:12 +0000 Original-Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 353FFex3011087; Sat, 3 Jun 2023 15:22:11 GMT Original-Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3qyuy7uv8d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Jun 2023 15:22:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l279REx6ckF/BCG148m3BplclVzxO+DD1Zcbudb5/+slJtjKhRocvY3UuFgUGuBz1z0lmSTygrUdqebxYCxSBqlPkp/EpsKWrZj2mwcdiSv/PxPrcXnK9qjDUym2nn4LMCCHnbz+qQCwYwYlRPWhrwdYPF58yNhK8bB942l64eisHvMpaHq/N5G38z5Qd9Bk7kcn+SCOXtrpE3BC8i7DwYRfJY40iqypt3MOMwOPi9dM4OT2011l0CwSz5v3ROkY4uEgtzwqRQbkIIti0XbW+Tj9lSbuULG3bg+SZLC1C/m6acjztEmb+y3IpxYWrkxev0dkMLpUbKezOgYcB1vubA== 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=/n8081E+f4GF0JFtOm8VMwXRGe7Ue7Nu6AqcaZbtgpI=; b=AmRA9S02+RDwQCaGgyjwiJcfqnaXLYcyORB33Q/wlISE3OfrWP9qKfTfYaHyx8IGZioRy8e7nXQ6EMG321p+dj8EDSuC2Cke+FufOIttQZwa0q8abQdFXGLg7OT7mqPZVGoLsqrG6X02Ovs7SzpalGktNEecmWS05uQnRjkO4nabaFKXaMKQCLhM5ThuS3rnl3St5rYEitejTV4SKFfwnmQ3glwBi/3nJy15ZovPpn21HKlUooCmn+9x0hTiItU1MMIRTYhcSWKcS1qz8D00VnOJ3wAsA/iiARHE9O168yjZbv6nGcSFUEgwtD15BZRGwLjBmKdZQftprfe7hPVXlQ== 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=/n8081E+f4GF0JFtOm8VMwXRGe7Ue7Nu6AqcaZbtgpI=; b=mNzlgAV3NY+axnNBM+hC5DyI6bwox/c3bJFnveDwqwayIqsXzj4s1qMbj0ahXsJGFgokap1mRZCjuhlTgXVTp8Hnvafktw/9NAmvMakb4lUQ1WlX8suzxbXwNba2mng15UX0LyxY7DwdqF82y8s/q43PdrfrK4oLZcx5wcTrXzo= Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19) by PH7PR10MB5676.namprd10.prod.outlook.com (2603:10b6:510:130::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.28; Sat, 3 Jun 2023 15:22:09 +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.027; Sat, 3 Jun 2023 15:22:08 +0000 Thread-Topic: Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?] Thread-Index: AdmWLcwk4jMOMdVbR6KmFHCbgyp6Gw== Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR10MB5488:EE_|PH7PR10MB5676:EE_ x-ms-office365-filtering-correlation-id: 3be7eda1-f739-4aed-0a25-08db64464c08 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MHtR5qhxbrGieBa3jvT9d8WewroKrkxKuAGZjCaPnDqG3eU0nC/T4TjvXxtHsXQtMSGR6rTPnqR9rwTwEZAoEHTrxJNWkCjJ2JTNzWk4bztswLDUZCe1y5m6GzcRQQoTSVVpKJhHT4loPr3r22h70qXasIEqGWHI3Y9XgKH/YuRAmwN0+Qmu5byxxBQCuxBNARiYacQtF7rfP+VU0JOWGKjTCiyWJO+dhFKzwrT3Vsu7MPSzcgWeZwIV5Vlt5WIjtg37fL47xk73WpCcrAXLpYaJrAAnIiWHc17zNcrWO77vlzN4MLNwPisDnBGN5njutgwMxV7/Xv9cWwcyJiOiWnnjkSPt1Uy0bYMHXUhYojToIlx/MJMzrtSAMYmcaAaL4007iH6vxdg5mqKDYiii46W9KZxrQRFGIHqJlays+YyutYWHUXoIuvBxwPtQu5QOsFdaR7F/2TAcOSnpPjTcBMvJ7QztPG6NdUd/A7Mmh6DpoeVsydiwRmAsM0cecyEpHxbCHtzYMIMBLwhZYKzyGU4eLvLGDfO41XxZUTm08BH1R8E7jrycTLZYeb7EqOuUgZV+hr9K9z8EM+moPGiZk1U/hAjl4FUqkzfo8RWyh1IbnncxJeyZTmU+JFFIeRyS 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)(136003)(376002)(366004)(346002)(39860400002)(396003)(451199021)(9686003)(26005)(6506007)(38100700002)(41300700001)(7696005)(186003)(71200400001)(478600001)(110136005)(66899021)(4326008)(64756008)(66446008)(66556008)(122000001)(66476007)(66946007)(55016003)(316002)(76116006)(8936002)(5660300002)(52536014)(8676002)(44832011)(86362001)(33656002)(2906002)(38070700005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?QrCDGJvafvkKp0RAtwpu3KLl9af0VCDbljG/kzpbBndYN5Wau/t9H+2RZBOa?= =?us-ascii?Q?5W886wMDcsmCKbzXlUnx4hqrV6sSS15zNGouFMVCluMagM3L5DeUHfRd1e4K?= =?us-ascii?Q?+eQ6M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MtHfaTmjJWc/AZ0tXdEu2UFCTm3AkqstJfHkYhVuJYlXyM0b8UFbJimYwaABi4HsxistL3oGxwKBW2ap/4fp0heRergHpBQKDwUoBxBn3gMd2gIhdb4U/ArlabRSttiA4k01mLzBuCqRG85QcgnvmqNFMhIM+eLLS3VEPmH3Mqtg1mTgXQszpUUAnvKN9vRXMk5TelARX1enlL8nOE7oyUfX4aLwiaVttKzdGBluqVTgYHjnTHBdUM13GWxzlzsEbIvdS0O73TML3ycfZaTi8d5NoKPfSG5TO7k/UAht7XoR9eLJEGfF4RHPCOVUr1aqdyJPqwgf+mut9U5KrPz4XlPxA2UUpPUXg/Vh+h28TeJ/cAr2nqs7EPZMnr9yPdVCyFQ4slVIP3UPSed2YCsOJA2dcXuyWjIda3dI9a 1B2J7jDiFi9rfxtS7GgF6uW4oIUivAqhCfHcPfT5A4FiNATc0qYo+7kruMG3c= 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: 3be7eda1-f739-4aed-0a25-08db64464c08 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jun 2023 15:22:08.8906 (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: JM+Ur+9Ra5jVpYOfAzoSRn5TFb8Dx97gSqdODdObu9wMjEGy8THUOLhoGV1Uhjp/A3WCknZKMO4dbxTzBVY7KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5676 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-03_08,2023-06-02_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306030140 X-Proofpoint-ORIG-GUID: baWpRaeuxCa6D8M3tpvv6LtwBCQp5YI2 X-Proofpoint-GUID: baWpRaeuxCa6D8M3tpvv6LtwBCQp5YI2 Received-SPF: pass client-ip=205.220.165.32; envelope-from=drew.adams@oracle.com; helo=mx0a-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:306596 Archived-At: > >> 2. It feels against the interface. If advising this predicate is > >> expected, why not convert it into an abnormal hook? > > > > It's more flexible and expressive, as Drew already mentioned. For > > example, how the members of a hook are logically combined (`and'ed, > > `or'ed) is fixed in a hook, but not when using advising. >=20 > Interesting. > From Elisp Tips in the manual, I always felt that using advices is > always frowned upon. And you are suggesting that they are the better way > to go in these situations. > I am wondering if this thing with modifying predicates should be > documented somewhere and recommended approach. This is a good point/question. FWIW, IMO (so far) - and obviously I don't speak for Emacs and I'm no expert on this: 1. I think the guideline is (has been) for Emacs code (i.e., what GNU Emacs delivers) to avoid use of advice in favor of hooks etc. It may also be a useful guideline for users, but I think it's more for Emacs developers. The reasons given for the avoidance include that the use of advice is opaque/complicated - it can make things harder for users (or for other code) to see and analyze what's going on (e.g. in a debugger). This is an important consideration. 2. There's a difference between the old advice and the new one (nadvice). Dunno how relevant it might be, here. The capabilities, opaqueness, and fragility of the two aren't the same, I think. The general guideline to avoid use of advice was established when the old advice was used. Maybe it needs some nuance/seasoning now (?). 3. #1 doesn't take away from the fact that advice (particularly nadvice) also offers additional flexibility/power. A hook or a function-valued variable doesn't offer the same things. IOW, there are upsides as well as downsides to using advice. But I think it's still generally true that IF you can do XYZ just as well without using advice, THEN do so. What's good is to understand the tradeoffs. 4. Yes, it might be good to (somehow) document the use of advice more/better, including tradeoffs involved. This won't be easy to do well, I expect. Someone who knows nadvice well, like Stefan or Michael H, might need to get involved, to come up with accurate & useful guidance for us mere users. ;-) =20 If done poorly the result might be worse than the current relative lack of such guidance. Or not. We won't know till someone tries.