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: Commands that change user options? [was: Turning on/off tree-sitter modes] Date: Sun, 24 Nov 2024 05:32:37 +0000 Message-ID: References: <864j43t8t9.fsf@gnu.org> <4cc676e8-cac5-4348-99b0-243baf74687e@gutov.dev> <8634jnt5e3.fsf@gnu.org> <4864104c-cb23-4356-ad89-2fea111db66c@gutov.dev> <86ttc2rrh8.fsf@gnu.org> <86cyipsp94.fsf@gnu.org> <9cd17f8b-f88c-49f6-9024-0b6d297e18ac@gutov.dev> <867c8xsmri.fsf@gnu.org> <566ac897-ea5e-4141-bcb3-306d43c9118a@gutov.dev> <865xohrvfa.fsf@gnu.org> <86wmgwnyle.fsf@gnu.org> <178dfc7f-bc2d-4e3b-8417-a616ccc0eef3@gutov.dev> <86v7wgnxlz.fsf@gnu.org> <01d83ec8-c02b-4806-8764-38dc89a89125@gutov.dev> <86ttbzojho.fsf@gnu.org> <930f5c8e-1481-43a5-8f1d-2c13a98df74f@gutov.dev> <86r072krq5.fsf@gnu.org> <8b907a41-aa08-4b61-bced-7d4d3fcef4b2@gutov.dev> <87frnhsvp3.fsf@mail.linkov.net> <865xodlr7t.fsf@gnu.org> 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="38973"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Dmitry Gutov , "johan.myreen@gmail.com" , "emacs-devel@gnu.org" To: Eli Zaretskii , Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 24 06:33:42 2024 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 1tF5Fd-000A1S-Im for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Nov 2024 06:33:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tF5Ev-0004as-Cj; Sun, 24 Nov 2024 00:32:58 -0500 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 1tF5Em-0004af-VK for emacs-devel@gnu.org; Sun, 24 Nov 2024 00:32:49 -0500 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 1tF5Ek-0003vd-Or; Sun, 24 Nov 2024 00:32:48 -0500 Original-Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AO4pBcU015186; Sun, 24 Nov 2024 05:32:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=PKa5K2GMeS0JwHgeINnlpLkaeepXWpNONAQ8ZaBZIlo=; b= BFf0GFFK27Ve/Je4vjDhaoZx0dCpAks49twZoxJx/z94d4MvaIK3URMaWcWLEnh1 E+PDLouDNQicT8c5xwrlGIw3vVDUkBuBQUqjX5coFlLe2mp1BuvGjfyNVx5kd+B5 iecSacwMV5gYhJPxdM2vnGC8/CVKAeosesJwo0wKS/3X80oDdXujb935e8uPt2c6 r6SBVkRccbEIXWPS+p2jNOHoMLLX1cnymM9+sWUpJjA60+YKNLryfF29LlM2CkNx Y+r+UrR6hYZ5m2RWWQnYip/Q77Nk+Ox6zI2D7rwCNda42Q0QhYoxmtD+nriISduA PG09wxM2l1BLvk31Ji7AiQ== Original-Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 433838h7x3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Nov 2024 05:32:41 +0000 (GMT) Original-Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AO5V1fl019375; Sun, 24 Nov 2024 05:32:39 GMT Original-Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4335gcr6ud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Nov 2024 05:32:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wSmwJmkFOmPWY6cokPQZawDc1n6YtGlvbngsgSQ6lQ0K/HKAjlD+GfxUueW/QbbqBCVRHh68ylNEFEpKn48NzL3WitjWyxxYdk0qVDbL6TSs8igBGCoRB0pk/xmeF5W6U0NGGPIMZZEqkpIJjDYtfdyKWFbM0yYQ+g+APXjs6NkX+AODq9Fff7bkwKcQHaYwcKOuQcJZZ0v3tR1FpH5x337r8t6/uIBPUc8yfzXsKMl/uOgTQv50VHHNDD3Cb6j1HT4rX6dLes4oWaPmPd3DdlKjUfc100bnIiQxEmC3RCiFIu+2ClrCUK3VZZP6ts6sfiUSrr+aNR1Oc8Ll31YrbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PKa5K2GMeS0JwHgeINnlpLkaeepXWpNONAQ8ZaBZIlo=; b=UliQW1p5KqZO7EfxSBn/zbRI7OUzfefF3WA/O2lHVhb/9jvRCGxkpqOkL2ZtXWn1khaYrlekQAY49uYc3kGqnUYRSVN2vXlhNMUo5f5oi9xFo5U1tusCsJ/w8e4NXNSGEeypaVU/3/bXq5I2k67h8x8f2kWmaBEqhyhiA/bsvXB+LFnKAgxVbDLTkyrFJq2uNkwlc/GSjwYKVbVsd3S6NV7PpzVIskU7i33a+45Ydg+CJLAt94yGxHZTBLHocrg5SbLd7quj3FU/faDyFR6Q+WUdIcY5gHbq9ARGbs7AIedsbRIOlMJLPce06hzBCSmbPg6oJDNKrVFIIPrIHa8D9Q== 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=PKa5K2GMeS0JwHgeINnlpLkaeepXWpNONAQ8ZaBZIlo=; b=jQ5FpBwKbfDzvWiCD/k71PAwc5HOrSaoofMV5kicyh+ygZCrRdqJeke4fo9Ge57kBw4Gyhl4gNuUpOMbvxWOLuEO8/fSyUfpmlnMLl7AiziR6rGoQY+GfLvXzFOIJHm2XAGR8TlE8kBjWYnxUrfq9TwHiKjV3wcJ98T10EqYVSE= Original-Received: from DS7PR10MB5232.namprd10.prod.outlook.com (2603:10b6:5:3aa::24) by DM6PR10MB4282.namprd10.prod.outlook.com (2603:10b6:5:222::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.19; Sun, 24 Nov 2024 05:32:37 +0000 Original-Received: from DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324]) by DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324%4]) with mapi id 15.20.8182.016; Sun, 24 Nov 2024 05:32:37 +0000 Thread-Topic: Commands that change user options? [was: Turning on/off tree-sitter modes] Thread-Index: Ads+MkCrMG2U9tTFRqytAfxZSbmv2A== In-Reply-To: <865xodlr7t.fsf@gnu.org> Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR10MB5232:EE_|DM6PR10MB4282:EE_ x-ms-office365-filtering-correlation-id: a0125cc2-16a5-481a-ca50-08dd0c49681e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?1rFDl6Nk9Aq0aZoMASZvexGmNi7J7NhzwD/31/8RNyLMhqTMaPsoWxq3Z6po?= =?us-ascii?Q?dsd9pXAjImOeeyEa5eT4GK/uWsK8uMvxjcuFYzZRhsWzAEh/xxdD6Mdk6mZQ?= =?us-ascii?Q?g2g/YWJcXcQzVR+6kLqUfiBh7MwaJ4cKEuzgIXu90i/LWYDAhHsrS6iDduYg?= =?us-ascii?Q?kvOOPjVcIl8D/sW66ezGyDtpDANyhk5QWtLSTjECsHqumnPjBNYkopNwRAvh?= =?us-ascii?Q?63TnEO8lBpEyXeiVZ3EQNIjMYZGwRNfq/Ddxw5aQJBgXL+JMjCj8T4E7Fn3G?= =?us-ascii?Q?HnHhkB5bNk9xBPhQ2XM92omwCdeFHyLMDy20FebzxJmZwHgP+e5104JGBag8?= =?us-ascii?Q?F+hFuBqC9RBGLpdcEP4u42yo0FNz9ww3Zlz7U5zz7IVB5baEFyR+mzu2hgMq?= =?us-ascii?Q?/8TFGlYIiP/9sEeU7oh5/EnDro0vEMsNThDZmFC8B2htITHVDdim0V6Jc3MW?= =?us-ascii?Q?h88TUkbt0W7o+tr0i4lngBZJqEnyy6zKPGGaGnUB1bA2viA90fKxN/eGbGe3?= =?us-ascii?Q?jK4KtEwTtFx1JUg73Gse5l+SEgvGacMqu3I7/z5e+iAsB4GAYkp8ghd/fRj9?= =?us-ascii?Q?k/EH4XcJ49oQqN/ZGJyEeATAmmj/PqMXVY9hUi9KNGRO26GduEkHPXY6ExVh?= =?us-ascii?Q?M6JlN x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR10MB5232.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?xzH6gmH8SdnvSlv/mE3k7ojPipT+qMFLD49QwXcvLM5buQ8GxyBLXHoPON+2?= =?us-ascii?Q?ZVjL3pIyHqsXeahI0s6gCiBdyIgxOLRVqctqiGumsDoUcJHIkS5hB/two8MG?= =?us-ascii?Q?y5ZiR//RY/QaRW37gOAQR4mBPgT0mMX+mVwc2Cl96yP+rtzG/sjv/kXdgQTs?= =?us-ascii?Q?m7lu7xL822Ol5kyWvcjIEVWPHH7yJu2eEp2ROB6NfSfn1y5016q3YGQVWDrm?= =?us-ascii?Q?INue/9NFHBhAFjCehHBBXAEwGFLwuAqZhkfNWuna9oGYQF0i5QoUoMhC5Ahh?= =?us-ascii?Q?Qb1lY3/NQPJ0pc/oRg6ZTEHvBC1U3llT2KTRQYul0Qk+/ARh4fqFzTgSZ8aj?= =?us-ascii?Q?E/QEMgUOdQYw8k32GUfjKC51HoFbGYMP9vQ0Hmx/21B7EAO/DVQuIFXLP1cs?= =?us-ascii?Q?tw3STM5eJQ++LPPCUvjf9B3de3nlQ5xj1vmEFFeAHnGPK3Che0lQZuA6+8DE?= =?us-ascii?Q?uYx3myeGDgsXvkAyxdcWJiffi9wBDjq/q81eXGRLVsA4cBcq2HKtZFP2M0Y2?= =?us-ascii?Q?3xXR64FTLyKZQsjj7zeEPkJcsd/ocQva4ckllHY8MW+V69/OX9g99XqTweYN?= =?us-ascii?Q?sM3fz809URXAkyVxL5gyfTfOORrz3ZcrEZg1iD1SyizyU8H5u9qhhV0xAp6q?= =?us-ascii?Q?iJ X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6u+xkE4Sk6kgmuZvJjaIu0SfeoG2qpYeFjKNOYFFbZQeEVV8GfbfRaRWYEiEZvJCPtwWUZa/zYi1AlxDJSQA+o4S6G6cGf1OHOpojMJ2r7JDx+YtJ3CZ+uO80RZgJKW1A1dHp7WNIttz/+ooqNS3UW+t4mLCPTpb7cOJZe2U1h8T63CLx6XYR3pS3483gghm/YxzsP7g5TD3uUJVMYdbb5xu3c+SQpyMXuSb760QcHj5ZHtX0M48DrnZPKg3ud/3fdzs22W229TIULwbdCwSN4J9BVBPOPbFwY2VPhXr9qZacKc7K9J4CP5eXdQKq0BjO5qjXtEXIG41fkFWmHgt/PgGe9IblldL/3A/VefweH65K+fMVumZ9SwVjKshN6ce0XoPThAsYTyZJZGzNEHf0ouyqLJZgISNcO4PJATDrxHHiHm2O4YIcIZK1ONGcBeAw8/jzeMH9QRcb3i7nU48Kyj/x+Ud91LkwFjNcZyldGhQ2n4kiYGMDN/aT4fO3Vpx9nw/hVH9XYFJDn0VLjdrsWHzvc/k5EVhFEVxSIElv/Uno+kKvzFmfW8ItRbdL7X5Df79grWp0lwmAme3xtq+TIExJh5c5v2Bw/JdxzvTqUM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5232.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0125cc2-16a5-481a-ca50-08dd0c49681e X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2024 05:32:37.5169 (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: +6u+1l9rvdsMYUNonDkHIMupm96I05YbykIV8bkhIncPDDzr/NI34B2og5ULMhmkWhbNNfsuBzwZADO54aAcmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4282 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-24_03,2024-11-21_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411240044 X-Proofpoint-ORIG-GUID: 8kRWwHOhTmoZ19U4eER-_fNQZ7ZCfccT X-Proofpoint-GUID: 8kRWwHOhTmoZ19U4eER-_fNQZ7ZCfccT 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:325647 Archived-At: > From: Eli Zaretskii Sent: Saturday, November 23, 2024 10:51 AM >=20 > But is it okay to have a command modify a user option? > Do we have examples of this anywhere else? Changing the Subject/thread. (I know and care nothing about tree-sitter modes, so far.) ___ IMHO, it's not a problem to have a command that changes the value of a user option. That can even be the main, or even the only, point of a command. The command's doc string should say that it does that, of course. That's important. A user using a command to change an option value is no different from a user using the Customize UI to do so. A command is just a different UI. I've never agreed with the idea that Emacs must not allow a command to set/change a user option - providing its doc says clearly that that's its job (or part of its job). It's typical for a minor mode toggle command to do that, for instance. And before we had minor modes (or at least before we used them much) we had commands that toggled user options. There should be nothing shocking about this. ___ FWIW: Vanilla isearch.el goes out of its way in a few places to have additional variables that are defvars, and to allow commands to change those vars instead of corresponding user options, because of the (misguided, IMO) belief that commands shouldn't ever change option values. Or to give it the benefit of the doubt, because it assumes that any such changes shouldn't persist beyond the current search. In isearch+.el I've tried to get along with (accommodate) the vanilla Isearch way of handling such states (vars). To do that (i.e., to allow some commands to toggle user options, but not to impose that behavior) I've even added an option, `isearchp-toggle-option-flag', which if non-nil lets Isearch toggling commands affect option values. And=20 a nonvanilla command, `isearchp-toggle-option-toggle', toggles that option! That option applies only to the standard Isearch commands `isearch-toggle-invisible' and `isearch-toggle-case-fold'. In vanilla Emacs, those toggle non-option vars. (But the first toggles non-option `isearch-invisible' between the two values of option `search-invisible'...) To me, it's often useful to be able to toggle something like case-folding and have that effect persist beyond a single search. It's also useful to have it _not_ persist beyond a single search - both behaviors are useful. My version of `isearch-toggle-case-fold' says this in its doc string: Toggle case sensitivity on or off during incremental searching. If `isearchp-toggle-option-flag' is non-nil then toggle the value of option `isearchp-case-fold'. If it is nil then toggle the behavior only temporarily, so that the option value is unchanged for subsequent searches. A prefix argument flips the sense of the last paragraph, so that the option is updated only if `isearchp-toggle-option-flag' is nil instead of non-nil. Similarly, for `isearch-toggle-invisible'. =20 I also have toggling commands for nonvanilla options and non-option vars that I provide (prefix `isearchp-'). The doc strings of such commands say whether they toggle an option or an internal variable. (It's only in order to play nice with those two vanilla variables that I provide `isearchp-toggle-option-flag' and its toggle command.) ___ Really, IMO the simplest thing to do is allow a command to toggle - or otherwise change - the value of an option or a non-option, as long as its doc says what it does. But I've said all of this before - long ago. Hasn't convinced anyone in charge, so far. But I'm glad to see you pose the question now, Eli. Maybe it's time to loosen up on this? I don't want Emacs to trounce a user's chosen value for a user option any more than anyone else. Such settings are the province of users. But I consider commands to be UI's, and some can be UI's that affect options. All a command needs to do is let users know what it does. ___ Is there some downside to allowing a command to change an option value (toggle or another kind of change)? Only this minor one, that I'm aware of: I have a function in my `kill-emacs-query-functions' value called `customize-unsaved'. If there are any options whose values I've changed and not saved then it opens Customize to show me them. I appreciate such notification, but I rarely want to save any changes. (A typical change is toggling some minor mode.)