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: Is it valid to call isearch-filter-predicate outside isearch? Date: Wed, 31 May 2023 15:22:20 +0000 Message-ID: References: <875y8nks9t.fsf@localhost> <86pm6sb5g8.fsf@mail.linkov.net> <87ttvsn77s.fsf@localhost> <83edmwfz6p.fsf@gnu.org> <87r0qwk6bz.fsf@localhost> <83ttvseg3k.fsf@gnu.org> <87o7m0k1li.fsf@localhost> 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="13615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "juri@linkov.net" , "emacs-devel@gnu.org" To: Ihor Radchenko , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 31 17:23:33 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 1q4Nfg-0003MG-4c for ged-emacs-devel@m.gmane-mx.org; Wed, 31 May 2023 17:23:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4Nek-0006oI-TN; Wed, 31 May 2023 11:22:35 -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 1q4Nee-0006nd-Qb for emacs-devel@gnu.org; Wed, 31 May 2023 11:22:33 -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 1q4Neb-00077s-M6; Wed, 31 May 2023 11:22:28 -0400 Original-Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34VERVYb016267; Wed, 31 May 2023 15:22:23 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=T23n70r9xRkMFh2c8x4OCQEU1uGAjDvdeXCWLmD81Pg=; b=2kotUGKb+xSpKzlK4LDkCWrhXDZ90i+RurnOTDkgBSLfjIAtR8pEq7G0RdEEzSXABu0d mnYL3rPS3menqWyZaJ7/CeZyUhVN6Fm2FHimGXtoBfkv0Gu7LSNYv76ul4tkoOS4eDTc 5wmlk/idANSi+xH+p1pc/ALM9DdthkfXU0CKeHRTS28uxzuMARBquRqb9a0zFGZWKfnt XL0HvHkRE+2ykeT+6sgOuwtd3yu8fr5AYsrFcX2Q1dFu4pR0H/87s4+y6zQhYSbapejR V6C9JqBg4yQqY7Lc97J/fSnRIig8u0iQ+wGP3ye75pO2xayexpOKo/JSj438fd5Jvmf0 4A== 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 3qvhmep54x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 May 2023 15:22:23 +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 34VE1J7Z026133; Wed, 31 May 2023 15:22:22 GMT Original-Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2045.outbound.protection.outlook.com [104.47.73.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3qu8ac9ceq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 May 2023 15:22:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBK5ZS090klt3XGY6W5e/bCdYkdujxuqMCzuCBBiMVUcIiXX+vzkgru/QMzKimuMhsh/qGmb4m9g5BS3KidWsGqr0GYs4McpTvgEp6LqTWPmEJGnNllkIgQK9fjkvz4Ee20Eh5orKHdntloitSl1Wi+F4WPnKnK6k2vOUxFtYsfozIZEJz4t4uDKM90AYUewYIXODXJZAkRYT6am8dQRB17LvXcoQ7U3QCIrvh5fhwVskW+w+sHR1h6v1msCkqkZO6qShoKTPHYbZ9XhCuKJmsMd9305pbND/8JSwzL+wmpjxDeyiTR7Kwu1bdr4wbJuCocQAPMhKF47ETgtBfClVw== 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=T23n70r9xRkMFh2c8x4OCQEU1uGAjDvdeXCWLmD81Pg=; b=SfpDrE9rjaCC190Ciw9TOPQJxbfqWw8pV5U/YA2zUVU9shvewYyy8bf/st3Au5mEkY0IDhkZi6JMpYmvuqZKZDroCbzvaZ8Zb3gfHLkLfC0ekqoQ0c4ZSnIMY0xRN/SEIyC0w4/nQBF837k3bqqy/GXOTUL9WQndEsNvQZP6jv1NEkc1x77uMyAImTLOtw4sCP2BlVfJBEEzCL5t+iLsPPEVvOpRa8pvpypCxV3nkgY4QENxUbs3k0KhfyTAJRh9HRTpQIoN/o/EDlkvDah22R01j3gIplnR82QXsxZxKOJ+cSl1SqnWoJjn8K+BHpJzyb2W45MxM+XdlKrG0B7fZA== 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=T23n70r9xRkMFh2c8x4OCQEU1uGAjDvdeXCWLmD81Pg=; b=y0KpuSjgNu+1Sop9rgtzpN0ePE6IvXWy0O0V6HmYvn2vc3IDhHA5qssdSXr0YdZYo2qUIlVsPONcYsnLUlQdFRhc3lF7LqUUVZGTR2A6iyM8kuEHPXsGlDtUm/a0znwh05OIabUSacDuHv6N1HOiWKS9Bnm1x4Yw0QkorEq34Kg= Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19) by DS7PR10MB7279.namprd10.prod.outlook.com (2603:10b6:8:e2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Wed, 31 May 2023 15:22:20 +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.6433.022; Wed, 31 May 2023 15:22:20 +0000 Thread-Topic: [External] : Re: Is it valid to call isearch-filter-predicate outside isearch? Thread-Index: AQHZk80YFN5EV6OAIEGoMbRknVpfb690ddzQ In-Reply-To: <87o7m0k1li.fsf@localhost> Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR10MB5488:EE_|DS7PR10MB7279:EE_ x-ms-office365-filtering-correlation-id: e5101d95-ee68-44ec-9d42-08db61ead371 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZQ9PeBU9iG8LqkVQ3zrFjqCan5QRikKhtoWE++SFO5yWHpB/JEbwGAYQ1OqGSN9PAk/X2o9ghtYHUTNonOOCroGpko8o+7lKEgammjJu0iiQzRBo3uF3+OWHixuhy6pKm2nnjbBwGtZXsOK3zel+St4ZZIX+FkdSsRfV0hd8UqqIxtCdUQ+Ge9Mnds71XUEq+JkEkHJMTYPdt6nozL4mbOm1OYzqj3jws1NrOSOdlxe8wAlHwvGWbF5oRXxtp7oswcB/xD2eL62SMI7F0DefDy6unuIADADERn5Lblf0KQRalRJZWXJ7jCe8hsUBM3SfNqe6XsF1sdY1o19OWU6ckzy+lBDZmO93U/NKoh9xFHMuOCK5HKd7DL730s0Qe+iSyy5bgSuXICo+9L0uJ5wewWhJxIr6GyFFIoLnRohN0PeJnde7fntbMVhNRrOr2i5K0/giDe3dssc0McGirlVcfbsLk4kPZz+Yk/EIVUeN+Xpsh+tiPRZRPzsetpA0BHJCdaDlm3RqKTuSrjz8W5Er3l/sSH/zw7n6b97yg0wXSLExSzSHWbd2kqUoSF9/r32Xjg+6rGtHu5TgbstzSQ4u1H67eeyroRNA9TCgP/VImXM= 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)(376002)(366004)(346002)(136003)(396003)(451199021)(2906002)(83380400001)(86362001)(33656002)(38070700005)(38100700002)(122000001)(55016003)(966005)(8936002)(8676002)(7696005)(41300700001)(52536014)(5660300002)(54906003)(110136005)(478600001)(64756008)(66446008)(66476007)(66556008)(66946007)(4326008)(76116006)(316002)(71200400001)(186003)(6506007)(9686003)(26005)(44832011); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?qgWhOK3fLUpUf297skMohukLbpwdY6Cdra5RLwgl7jIuiT7WbZC6yf8FHvzw?= =?us-ascii?Q?el1i7mOWGYRgKsa5rD/I/Dt7svRn0TYCVrrgrqKYZ+bTGaJgIO4cs2YDMM/j?= =?us-ascii?Q?QCD8Rs3wHuSey79wCHjwyEzdBDAlV4ate6tM+i0+sAW+i+HArWEJ6GNpUb4s?= =?us-ascii?Q?sqfHEbnIhYYAS4y1Ij/05Gk5Uqyf0DEPUQHw8/5u8+4LYwW75x0QAx+ExQgx?= =?us-ascii?Q?fqMrIBn49G/Pg7DH0LbBMY3k414pYefnwATLu1ercb4cPPS0RiP4QdjgYJiy?= =?us-ascii?Q?Sba7ZT/93QO+N2Yiudm/5u0c1sTjgJSMicyKMNVJSfiXjl+Jqt5qz2PS50jZ?= =?us-ascii?Q?XAJIXN9/DODRkgIxCaTsKB0sdebSytNwLOCLCcTPgjg2zG08NNvQn1iJMVXf?= =?us-ascii?Q?LmK+0f8g2MP7kj7snxoc6D8e4v9tthZMGtrLKxmPUGBrqnIzreQmhbxdMip3?= =?us-ascii?Q?rwi19SJocZGaWRlsabV1nNA30RK0HbyqYjgtYTLbBRcIKbmbP2SrC4zZNaiO?= =?us-ascii?Q?X65OrnxRPmZjCmW+aFc4DIjU0f1TKvUyudRigJZ56YOxvJBmfEhNJlx7Qq3W?= =?us-ascii?Q?UrjQq5dWgQx25gpM9K5oEbv3hXpNAVvOvdenQ27aHXNUd+QvjSbXcO4sXarb?= =?us-ascii?Q?Z4 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LlydHh9REClj2DqEisVXsWG9/35vqFB2DBrlul8FDQHIKNV+crFDII+20BXn+ZXZmD28t1JP8a4MdPzo1d54Dr51wLxUthbBpTum9EiyBbcaAHYrR6PKWTdx2ok9Yz4sysurF7Omm7XHH5ItrpBtWpD6z/P4l0oOoNSXwJNWo9A/N2fckn4XWn1UZzgaAypZcwijGI8l8E/fNHvsC66VuafvTu++FfFgIwttxd+O6O/8gyLVpIHMQRG8Ro8JGMIr/a5d9+sbC7gwmFQM7erBBX0iAwpTZEwxn15uUo0fhPQRLDbRPzGsQp4xq+o9HhhW7srVixsN7fxbjSGk/iLD8SInOQu1u00ULEwz1LPJZg8qwNoOvMm0aGtuyNZ8/pbUSn0dVZuEMoeV+72KyLAzkIAvgvC+GVM5EbRgoIQ2AprjXF64PeKk2MIDpZ8iZ3/qErbL0yXhDTsu920S0QYHOSy/jVjugGv+b1DYICLnaj9EuNoYtQHSD/ZokWJsYKU79KMoJBzKDhZbW1J5y5pcmrdvZrlFFu+qb/27kUMtatmHT207hISxv1Tu2C+sGXEYFc0DPGaRPT0PdnXVQRMlDEQ1U6madGNkv6kPsq6Dd5ZOLAw1u3vvQbtyAV0RoU/BRjc/dt0swD3kM8MRnOp99tend43K+hgMMq1hCFbEuXYxac3t2/Lgt39Br83KEWpoIleiELbdwvQRs+cK7kMXD1Uzt+f4Gbk2N0em9qkLZcw2PY 98nHMnFrKhtZY1AZhK/MuGLwvIAapaHBYLDFy5G3dzPvFs25cyg4IwksH0dFE= 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: e5101d95-ee68-44ec-9d42-08db61ead371 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2023 15:22:20.0215 (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: uQMgQlRNPC/fkH9gU0wDtaKmgr9W4ggLS41l1jGwZwho/ydd4LoJDbu5tfI8WloNQL7xNyVWwvMbLgq0R1yR4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7279 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-05-31_10,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=896 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305310130 X-Proofpoint-ORIG-GUID: ukGB3LASDhSE8ZUNi2ZY_FtU_us23SLg X-Proofpoint-GUID: ukGB3LASDhSE8ZUNi2ZY_FtU_us23SLg 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:306451 Archived-At: > >> I expected `isearch-filter-predicate' to be only used by isearch in > >> isearch-mode. And thus I expected `isearch-mode-end-hook' to be called > >> later. > >> > >> Isn't it a natural expectation? > > > > Evidently, that ship sailed a long time ago: "grep isearch-" yields > > more than 60 hits in replace.el. And then there are many hits in > > comint.el, dired-aux.el, info.el, and even in simple.el. >=20 > Sure. I have no issue with this. That's why I asked to add a word of > warning about the state of affairs to the docstring. It is not normal > that major mode-specific predicates are used elsewhere. Where do you find that "not normal" guideline?=20 In any case, `isearch-filter-predicate' is not a "major mode-specific" predicate. `isearch-mode' is a minor mode. And note that the first line of its doc string says that it's for "Isearch and replace commands." ^^^^^^^^^^^ ___ Wrt whether `isearch-done' should restore the original/previous value of `isearch-filter-predicate': Yes, there's a certain logic to expecting that `isearch-done' would do that. In my library `isearch+.el' `isearch-done' does it. More precisely, it does it depending on a user option, because the library has a feature that lets you alter the predicate on the fly, and you sometimes want to keep the modified predicate for subsequent searching. (You can toggle the option value during Isearch using `C-z S'.) The feature: You can add and remove any number of search filters (predicates) while searching incrementally. The value of `isearch-filter-predicate' is advised by predicates that you add, creating a suite of predicates that act together. (AFAIK, this is the only example of dynamically, interactively, incrementally advising a function, in this case the function value of a variable.) See https://www.emacswiki.org/emacs/DynamicIsearchFiltering. This is the user option that `isearch-done' uses: `isearchp-auto-keep-filter-predicate-flag' is a variable defined in `isearch+.el'. Its value is nil Documentation: Non-nil means automatically apply `C-z s'. Changes to `isearch-filter-predicate' are automatically kept for subsequent searches in this Emacs session when you exit Isearch'. You can toggle this option using `C-z S during Isearch. And this is the advice that implements whether to restore the value: (defadvice isearch-done (after isearchp-restore/update-filter-pred activate) "Reset `isearch-filter-predicate' or `isearchp-kept-filter-predicate'. If `isearchp-auto-keep-filter-predicate-flag' is non-nil then set `isearchp-kept-filter-predicate' to the current value of `isearch-filter-predicate'. Otherwise, do the opposite." (if isearchp-auto-keep-filter-predicate-flag (setq isearchp-kept-filter-predicate isearch-filter-predicate) (setq isearch-filter-predicate isearchp-kept-filter-predicate))) So yes, in general it makes sense for `isearch-done' to restore the predicate value. But it can sometimes make sense for it not to do so. Whether it does so or not should be under user and programmatic control.