From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Partial wdired (edit just filename at the point) Date: Wed, 17 Mar 2021 14:58:47 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7819"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 17 14:59:56 2021 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 1lMWiI-0001tJ-JU for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Mar 2021 14:59:54 +0100 Original-Received: from localhost ([::1]:52634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMWiH-0003JJ-JB for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Mar 2021 09:59:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMWhM-0002qm-6j for emacs-devel@gnu.org; Wed, 17 Mar 2021 09:58:56 -0400 Original-Received: from mail-oln040092067013.outbound.protection.outlook.com ([40.92.67.13]:58681 helo=EUR02-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMWhJ-0000lS-JP for emacs-devel@gnu.org; Wed, 17 Mar 2021 09:58:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eHXq1mfNzFa04ZwgYvY9qeIqSX650yidR06piCrYAZfLer4/H5n9nsiAA65McdAYaUrQh4uJHuTaOSaBQ/2VOpqXxYoLhOGhsh85y5ZsNySMK3V9j9epsLtWpK7h4b0DxlgJ0v2YYdeGrH1SvFMsVpwJUN0oTBPqhadilF5q+ylDZZmUkwYPeliGS5ZhqwnrxV7dStSirO+hK10FOpjtFJTL/6xnAg9D9ww6odJFb177QqbJWa56AeRS9i9EiW+htZdou0UCWWA9OK6btx5eUhPdMFJ/6e3/btKsJuSgU8DF9Cd7Nc22ZZ2bBzl6xixNrTG086QClK6mnW4z9AFrfA== 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-SenderADCheck; bh=dJVKAUlre3w2YeWRYrWEjz+Bfac8IwnhnXWY9Hw5EHU=; b=Eby/ICwsYhI2F+7WBGEkw76NOOQb6zFV4m0+oSOrSbH+GvSnOJNSOdt9i5hQzPArjrSY+xPdsfGeWiWOK7C9848ncZus46VPiQXFQbUr/IzKc3EWxGSNy4az8q4cuqZzufeB96FiwIn+V51VMVDM0Pf0nIaVSPh2eecwtijvdUSj98xnvXgzawLH2j6ml5fOsr4o2ehWKR2xjYPCGDEOABT/sM55aIYmc9+1HA+m3pTCTsGYBRBsEcH8B8ptAPdlOnBe7+HCQcwOtQAqUW7g6zrZQVXbbTc7cUmAtye60TMV3yDRE/WtKLurG85ITdvJNhUQu2tC4IGB7M3+frfsIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dJVKAUlre3w2YeWRYrWEjz+Bfac8IwnhnXWY9Hw5EHU=; b=kSFsHfb17jCLaTdyoP6QMn9ocytbz/Qkoemt1YPhJkYmJrepO2+PgjJIHQeINeqHEzcYTAen5K6z2H5SiV1BgNhDmIwkP3jtc473NqmrPM/qJUxUHFc6GofQps5rbkvMSKIfz6Ym0QvcVRBw+64kqcr18mHBMrRRbcG0yAFTJlv3pmmL7qfGvMGHd2WpmsuWaiKvPMG0Fw95QCYcwyUYAC2v8U8B9ZxzZSEIt2nxbTtwAZoFxLzFjAGINF+3RleZidXuh2HdOlDMeYrXsu2cpAoOEGSic5+zXjpfgf9BuoyJwDW9xrAl66Ev3bNq+jVZk/KseyxLd8KU++ysW7pm/w== Original-Received: from VE1EUR02FT013.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::43) by VE1EUR02HT129.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::384) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 13:58:50 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e1e::4e) by VE1EUR02FT013.mail.protection.outlook.com (2a01:111:e400:7e1e::142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31 via Frontend Transport; Wed, 17 Mar 2021 13:58:50 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3D90BA003C115CD1F38283293021C1FD502AF88C4CB5DC44058F3AEA440E188A; UpperCasedChecksum:0C784E56048EAD101FD25BE10A1068B16E68F56B9C2BDD43EF7E3452627021E1; SizeAsReceived:7626; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b%6]) with mapi id 15.20.3955.018; Wed, 17 Mar 2021 13:58:50 +0000 In-Reply-To: (Stefan Monnier's message of "Tue, 16 Mar 2021 22:34:28 -0400") X-TMN: [eKrAwYm6p5Eui6Gj3xh5z0k7eIYFXR2P] X-ClientProxiedBy: AM6P192CA0088.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::29) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <8735wtanl4.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM6P192CA0088.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 13:58:49 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 43015207-9a8b-48f0-9061-08d8e94cca98 X-MS-TrafficTypeDiagnostic: VE1EUR02HT129: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TaSdmWMnvdwx2Wqz9QIyzfgijK76IR60vHyUvFxQqY5ef/+q/Pbg3VYQgV2N0TxzD1kX3Gpj8IF+zoBAFCqk2AO+nDSDrBqlVXvBzlW9i1Bx6P5KWgb8KGp2/+GufjuaHLMdErco9Z0Q7RuzR63aANTvKu8ar25/KCyFYIfjjB18IxjmsiOUp5d3YRFiORq5HLN/1HrB5O6mzFojHlVVQR9zFk3ONRK7eI1CMUD1JwuwVX76NGoX122RskTQmQK4yAtkDq9t0Bbx6zgGd9Fmrv2s32dA6130i7d70LheRXo+ArBzJ1Vp5vux5c7vXVNaKZW2VIxrCqp+99XoBHBbo0lunb6o8/Y+0H94kHw9V0pYuzRykQ7HwPbxHaPCAFQiPzXIYj4+HuMZAkkdURJJfA== X-MS-Exchange-AntiSpam-MessageData: FRdpnsnyJlSDPbNJPZWbNy0aFEb5ipYX2d+kkSIWO+xPdk5kWo+/PGYM6d76BJwuSdkfL+0wUm7aC/sVRvQaRbfQjI24S2xdbPitDP6zvafoESQJwETaS9zCkJ7UWZVzuOmsi8dVUAqgvbJNDdq90w== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43015207-9a8b-48f0-9061-08d8e94cca98 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 13:58:50.2580 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT013.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT129 Received-SPF: pass client-ip=40.92.67.13; envelope-from=arthur.miller@live.com; helo=EUR02-AM5-obe.outbound.protection.outlook.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, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:266523 Archived-At: Stefan Monnier writes: >> Never used 'before-change-function, so I didn't think about it :). >> >> Sure, as a strategy it sounds good indeed, but I am not sure I >> understand how to apply that hook in this case. Docs says it is called >> before any buffer mdification, but I am not sure what it means: before >> every key-press in this case or what is ment with buffer modification here? > > Not "before a key press" because it can't know you're about to press > a key, and even if it knows, it can't easily know what that command > will do. Well of course not; Emacs can't know when I am going to press a key, :-), that is not what I ment. I ment after a key is pressed Emacs will call it before the actuall character is inserted into buffer. What I want to know is if it is going to be called in context of every keypress, i.e. every insert, and from your following statement it seems it will be. The problem here is how aborting changes is implemented in wdired: undo is disabled and original code just copies entire buffer and pastes it back when changes are aborted. I do same strategy but just for the line in question. Question is how to do this when multiple lines are edited. I would like to skip copying entire buffer into buffer-string as wdired does originally. I'll see if enabling undo stack can help; I think the problem will be to keep away from editing certain part of lines (timestamps and alike). > Yes, I understand, but I think we can have our cake and eat it too: be > super-fast when editing only a single line yet without having to tell > Emacs in advance whether we plan to edit only a single line or all > the lines. I agree with you, but I am not sure how to implement it. My hack was literally less than a 5 minute change, I just removed loops and changed mode name so I can abort it properly. It would be actually very trivial if wdired didn't manipulated text properties for entire buffer; i.e. if we used only read-only property for entire buffer, i.e. a "naive approach" where entire buffer is guarded with just one variable. I understand original author choosed to go via text properties for a good reason, I am not sure which one though: just extra safety in case of accidental change, or is there some other?