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 03:21:57 +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="18200"; 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 03:37:45 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 1lMM49-0004eI-Kl for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Mar 2021 03:37:45 +0100 Original-Received: from localhost ([::1]:52596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMM48-0006dm-Lv for ged-emacs-devel@m.gmane-mx.org; Tue, 16 Mar 2021 22:37:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMM3Z-0006Cy-1e for emacs-devel@gnu.org; Tue, 16 Mar 2021 22:37:09 -0400 Original-Received: from mail-oln040092072034.outbound.protection.outlook.com ([40.92.72.34]:61757 helo=EUR03-VE1-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 1lMM3W-0006YT-5A for emacs-devel@gnu.org; Tue, 16 Mar 2021 22:37:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b7ohrm1t2eJA1d3i6b6/Vu01yGN1RPpTfaifFr4Ouf0s9aJa2OQdcrg7SUyNM9rvN3r5bx7DBBxOD10DYXdKHAqDW9a0QKvagcC+cTEEsxbTkJgKbqXb1Uq3sAoDAcclvHz1XXE175GYq5s91QF6Ss7ydyd4uJLrRXs+oT4uCcbVfNwzonC8AgGIpBw5YJHkum0POvCJan6xn1I7/qX4N3e9hKTElUitrZgFkz4bC4AVpOGMU0B5U+lI4w00i5XKQ16jg+7vO7lcSdS/On+qf2g0yoMYHMIrl82Uq5jdNLdZB1T+AIJMDrJt1DDS/Ed3ZrjIbC/do1UcgbfFbz5uww== 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=FmHdneuQKKWg0VdOq8sfk4ApVS3xSo61PwwsAHU8LEU=; b=lg8OdyPKq5bdVzkk3JzYz2EtgzsykIWaMgbu++hh58Oyse9f3/yIBAsQ8prAOSmaEB12uXe8bUMpnp4tt53hiLlqI+kSGsW9UBsisgRU/u1B2LHRaJPw3VYbTK4Fpn0kQqHJxljvbZ8lDjl3kl9eE7D3gEpt55Fmt5vIUj5DbhROptfvXTrTkMWad+pjFzkhdCAjJH495ndOK5CmEGvitnF43FtaZAwXxpGJ2uljsQkyMsgQ0SYEnNGYS6TvNJ28FqL0+p8ncU7cnv+esHABA7+8WEMrNu7yNdoHXTmiBJQljn0OLRfqo8UubnjZIMQjO5o2ZNx0sdhjzbfyz1nmxg== 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=FmHdneuQKKWg0VdOq8sfk4ApVS3xSo61PwwsAHU8LEU=; b=vIE0u/CB180tOGfPWZEwjiEyolfe9Yxm+OL61qY2CYhF4n1zzUah3OCmOdTZv39WG9cYca/GvaE3kOHpon89cUr/Unuc7XEuKG7rzt0y4obN/i+20FobDymjQmpnkl6oOKw3wfcslmJ7vbHH/5yHGXLuZ56I03B9NfjcmBUCPOw2pkLR/2TfmxhPtEstrBNdOt3Okb2CksAyWzoTFQFxOGUUZBnv2XiRvjPrhMv2tjDCrNK/4pxqp6TpekVECddJR7JMCgCo4g9qNppYS7bh6Zk9iyqOvuK3Dk5iUfN3VkYdMrdnKOAzLNMlURnjwkF0A5czyo3rxeQZXKMmNHBoJw== Original-Received: from VE1EUR03FT013.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::4e) by VE1EUR03HT162.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::442) 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 02:21:58 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e09::4f) by VE1EUR03FT013.mail.protection.outlook.com (2a01:111:e400:7e09::293) 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 02:21:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:F11BBD9FD768A4676D9B0ED5028E5034BB4515166EDE4C30F6B19B7A0C1FD18B; UpperCasedChecksum:5832C948645832C1830F199549D1E94164C09FAB9FC14B2A549FEB74745D0C8B; SizeAsReceived:7507; 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 02:21:58 +0000 In-Reply-To: (Stefan Monnier's message of "Tue, 16 Mar 2021 21:18:47 -0400") X-TMN: [GV5k8qq2jy5jceOrfN97KbMYHZ9xew9X] X-ClientProxiedBy: AS8PR04CA0141.eurprd04.prod.outlook.com (2603:10a6:20b:127::26) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87k0q634fu.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AS8PR04CA0141.eurprd04.prod.outlook.com (2603:10a6:20b:127::26) 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 02:21:57 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: bed51712-3f79-4df6-a80e-08d8e8eb70ba X-MS-TrafficTypeDiagnostic: VE1EUR03HT162: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4DJHuWCtcT0j2KRCBvZi7Dxvvb9DHXaVq5mtRbHerdnXqk+zx+MCTEC3jCQIx6EOB3IAJ79x3xlqUtUfOVIQ9wN5w3iGcVftYUxYJ0aadFvo/fpdyvSiXtrOeqzRSqPDc2fJ8OlKOX+PSNx9o6CuZgq5LqKd12oKKRoBD6OsowZVtXUeuTQ7m2suUuDi+XlhUM9PotDe3BhLKXcuefTY4sinbYY2wLujSb0lysQ6u6tnTL5Z5FsDBWzoVhqvYN6HLV6wC6jB9jxm/CVGDdcG//H72eSGofp9bsct8m8VUIUEwlpsYPWRETIEt4RYYNcAI0am06vrMteNPt+H/1Cti1re78w4QcnnyqsHuHivAMFFu1FT5VEJJliAT/KQRbsSNANY7P/a4pwbs2f+Own1qQ== X-MS-Exchange-AntiSpam-MessageData: q1qqX7euX4AbVwxho9V1bZq2v00nMm3zZAkgJQtHxrlDYj8ovv17Np3LDcWDUqwwiImLwCuHQwEfnjxB7eq2hYJYbizhAKBVkdVaD4WpZQkYhNqXgowEe/kVY6Shtv4nesl0ZLHyvbK1PI2otOCFiA== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: bed51712-3f79-4df6-a80e-08d8e8eb70ba X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 02:21:58.2529 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT013.eop-EUR03.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: VE1EUR03HT162 Received-SPF: pass client-ip=40.92.72.34; envelope-from=arthur.miller@live.com; helo=EUR03-VE1-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:266516 Archived-At: Stefan Monnier writes: >> Wdired is really nice for batch renaming files, but I have noticed that >> in case there are lots of files, starting wdired mode and finalizing >> changes can take a while. Sometimes I switch to wdired mode just to rename >> a single file. On my machine, a directory with ~700 - 800 files causes >> a noticable delay. I haven't measured but it is in range of 2-3 >> seconds I would guess. I had one directory with almost 2000 files and >> when tested it took quite a bit of time. > > It seems to scale linearly, so it will indeed get slower with very large > directories, tho it should stay manageable (i.e. if it took 2-3s for > 700 files, it should still take less than 6-9s for 2000 files). Something like that indeed. I haven't done measurements. Not that I practice to have thousands of files in every directory, but those small delays are still noticable and slightly annoying. > But yes, it's a problem. Even if there is just like few tens of files, it saves battery on laptop if unnecessary processing is ommited :). >> I traced it down to how dired/wdired use text properties to controll if >> text is writable or not. When switching to, wdired goes three times >> through entire buffer (filenames, perms and symlinks) and changes text >> properties to writable text. > > The profiler suggests that most of the time is spent in > `wdired-preprocess-files` which does one of those traversals. Probably; file names are most of a dired buffer; usually there are not so many symlinks, and permissions are not so much of text. >> I have rewritten those few functions to drop to wdired mode to only work >> on a line under the point; it is just quick copy/paste hack. It >> works fine for my needs and wdired starts without noticable delay, but >> there is one cosmetic detail: despite me changing properties only for >> current line, wdired still let me edit other text in dired buffer >> itself. > > I'd rather try and speed up the general code. How 'bout making > `wdired-preprocess-files` work one line at a time and do it lazily, > using a `before-change-function`? 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? > This way entering `wdired` should be instantaneous but you can still > edit any line you like. The actual edits would be slightly slowed down, > but that shouldn't be nearly as problematic. I agree it shouldn't be noticable; it is how the implementation I attached works; it is just that I do it explicitly with a "manual" call to function that change properties just for the line at the point. Thanks for looking at it.