From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files Date: Mon, 6 Jan 2020 17:33:06 +0300 Message-ID: <81589ba9-0f93-599d-e55f-6605479454b0@yandex.ru> References: <87r2bt1tio.fsf@gmx.de> <2cfd53b2-8202-a321-a853-da0c949b0f15@yandex.ru> <6cf8bfa8-3873-d3db-9139-854359027e8a@yandex.ru> <87h81mqiq5.fsf@gmx.de> <0ff03b20-20d8-b6c0-c876-3fd525586180@yandex.ru> <87mubdps6s.fsf@gmx.de> <87blrsz3tf.fsf@gmx.de> <87blrrmht9.fsf@gmx.de> <87tv5fs6kf.fsf@gmx.de> <7a1e2e22-89d4-b8b9-6cd4-e6947436138c@yandex.ru> <87mub6uoa6.fsf@gmx.de> <87blrksxco.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4B328464EC878798E2CB7E79" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="233125"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: =?UTF-8?Q?Felici=C3=A1n_?= =?UTF-8?Q?N=C3=A9meth?= , 34343@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 06 15:34:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ioTSM-000yXu-Rf for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Jan 2020 15:34:10 +0100 Original-Received: from localhost ([::1]:52538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioTSL-0000Kz-Mq for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Jan 2020 09:34:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39034) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioTSG-0000Jc-0x for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2020 09:34:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioTSE-0002kq-Qk for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2020 09:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ioTSE-0002km-Ly for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2020 09:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ioTSE-0006al-Hn for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2020 09:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2020 14:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 34343-submit@debbugs.gnu.org id=B34343.157832119825276 (code B ref 34343); Mon, 06 Jan 2020 14:34:02 +0000 Original-Received: (at 34343) by debbugs.gnu.org; 6 Jan 2020 14:33:18 +0000 Original-Received: from localhost ([127.0.0.1]:45340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ioTRW-0006Za-0T for submit@debbugs.gnu.org; Mon, 06 Jan 2020 09:33:18 -0500 Original-Received: from mail-lj1-f170.google.com ([209.85.208.170]:40977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ioTRT-0006ZG-CC for 34343@debbugs.gnu.org; Mon, 06 Jan 2020 09:33:15 -0500 Original-Received: by mail-lj1-f170.google.com with SMTP id h23so51144380ljc.8 for <34343@debbugs.gnu.org>; Mon, 06 Jan 2020 06:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=1xzhbwYDKufvEB8T9Cpd5ismmLyrCfhagDYbbDi6kbM=; b=grdImzf3KNvw9U2LwVaWOxiMA2le/tUoYOb8ey7f2zU3LHPqU723rgn/0aLhputngg 8uanYh+nFIO4IQYEPKyCPBzNR+MW24MjxgtRue94hqAbOQhWAW0p2KDp/0uIY9fjbCRx aNk5/LRLNN5TlU9eGZdISBI0RzU1OoXKmDtu0+Bj4S2gLw060ZnjPWphh3HobVKlzX/R KqbA4eVCgw0RVPHv5jl3TR4Fstj8JwMUW/J8ENXEHzPkjCwVQ4Mehm6lXXSkOZer4Y3W cuzOXuIPs/i9Ynmv7tdJFfU9UhRdM+wQjNgnkk4z1K9sk+rRGhRuhPrKarTkmgpDhaJS fopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=1xzhbwYDKufvEB8T9Cpd5ismmLyrCfhagDYbbDi6kbM=; b=kIOo+9OEM4HSSXyu6RaWRcy+IaxfLGVJN162kEJfxxNCBVhgrUeTdBOdHETSWlucvu MClrZj8TjeZUcJvyWurcWDAd723HJZrWn8sAUN2ZmP9Pqeggz2awnOl9a9ODmQLmv/by ptCnr9Wb68VYZmeDAR0xfIvwuN7xfu/Pgso3vtU7vnbBvtL1LL4MTALWQR/RoTeyU5Ko p2T3aYam4txlxdVyrEJS3hSef5nzN66hbOPtKDXcz7l4UjD7O3Mm6gT5oDhpy1tiWl3D +2zvq89NaJypktk6iuMZsHL3hgdAWryycJ+8+MJlLJKf1TmnBrKqyAojpsNMEVmK02e/ zwpA== X-Gm-Message-State: APjAAAXeNKMp4JE96DK3r+nIFBpfCqnDqRVwAXP4T4Rurc+X2f8ikhgj 1Y7VF5xCDeIYa4qcuesZxn1gnJbC6Lg= X-Google-Smtp-Source: APXvYqy9oK8dhhpjIjNFesJSBxklCdvDVm7Plo90WdsNK0ioA/IIqLFReftNSTgeIZnxZBYXUcdXjQ== X-Received: by 2002:a2e:3608:: with SMTP id d8mr59366522lja.152.1578321188841; Mon, 06 Jan 2020 06:33:08 -0800 (PST) Original-Received: from [192.168.1.142] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id k24sm34725206ljj.27.2020.01.06.06.33.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jan 2020 06:33:07 -0800 (PST) In-Reply-To: <87blrksxco.fsf@gmx.de> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:174235 Archived-At: This is a multi-part message in MIME format. --------------4B328464EC878798E2CB7E79 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Michael, On 03.01.2020 11:28, Michael Albinus wrote: > Yes. But in case you want to be generic (handling all possible remote > file names, not only the Tramp implementation), you must use the file > name handler implementation, as it is described in > (info "(elisp) Magic File Names") As I've shown before, the generic dispatch is far from being the bottleneck at the moment. tramp-file-name-handler doing a lot of unrelated work is what takes the most time. > In case you want to go your own path, I could provide you an own > tramp-file-local-name function, which bypasses this mechanism: Thank you. I see you've already pushed this function to the release branch. I could use it like this, sure, but we can have a significant performance improvement and keep the generic-ness at the same time. The simplest option is below. It works fast enough in my testing (*); a bit slower than calling tramp-file-local-name directly, but not by much. Certainly much faster than the current state of affairs. It's a bit messy, but I'm not sure how to structure the resulting function best. There are several ways, though. What do you think? (*) The 1'000'000 files example was an extreme one, to optimize for when files are local. The 10'000 file project is a real one, on the other hand. P.S. BTW, I think our convention is not to call save-match-data unless obviously required. If the caller needs to save the match data, it will use it itself. --------------4B328464EC878798E2CB7E79 Content-Type: text/x-patch; name="tramp-local-name.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tramp-local-name.diff" diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 85330e98aa..34438bd276 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2322,6 +2322,9 @@ tramp-locker (defun tramp-file-name-handler (operation &rest args) "Invoke Tramp file name handler for OPERATION and ARGS. Fall back to normal file name handler if no Tramp file name handler exists." + (if (and (eq operation 'file-remote-p) + (eq (cadr args) 'localname)) + (tramp-file-local-name (car args)) (let ((filename (apply #'tramp-file-name-for-operation operation args)) ;; `file-remote-p' is called for everything, even for symbolic ;; links which look remote. We don't want to get an error. @@ -2415,7 +2418,7 @@ tramp-file-name-handler ;; When `tramp-mode' is not enabled, or the file name is quoted, ;; we don't do anything. - (tramp-run-real-handler operation args)))) + (tramp-run-real-handler operation args))))) (defun tramp-completion-file-name-handler (operation &rest args) "Invoke Tramp file name completion handler for OPERATION and ARGS. --------------4B328464EC878798E2CB7E79--