From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#51622: 29.0.50; [PATCH] Abbreviate remote home directories in `abbreviate-file-name' Date: Sat, 06 Nov 2021 18:41:31 +0100 Message-ID: <87a6ihchbo.fsf@gmx.de> References: <5ac0b5f3-302c-2f96-771c-8d38088aa573@gmail.com> <87mtmhmh60.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34189"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 51622@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 06 18:42:29 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1mjPi0-0008i4-P4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Nov 2021 18:42:28 +0100 Original-Received: from localhost ([::1]:58146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjPhy-00073R-PQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Nov 2021 13:42:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjPhb-0006z6-5C for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 13:42:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjPha-0005P6-NW for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 13:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mjPha-0002wc-FC for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 13:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Nov 2021 17:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51622 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51622-submit@debbugs.gnu.org id=B51622.163622050611296 (code B ref 51622); Sat, 06 Nov 2021 17:42:02 +0000 Original-Received: (at 51622) by debbugs.gnu.org; 6 Nov 2021 17:41:46 +0000 Original-Received: from localhost ([127.0.0.1]:50426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjPhK-0002w7-Bc for submit@debbugs.gnu.org; Sat, 06 Nov 2021 13:41:46 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:50683) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjPhE-0002vo-V1 for 51622@debbugs.gnu.org; Sat, 06 Nov 2021 13:41:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1636220494; bh=f3YNlktQx/h35IiKVExBEJ/ho9akHcRcjQJZyDC8XCo=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=OQAxAxGEPSaEwvkY9MhYm+JELUTiXITblK5WrXzcQTXmGZB8sIFaQErZpJ1Dg8YnB /ZWKeqJRGEjtUQHE7R+C8bDbC8TGhQPRPuvQvyKWFA5BQSTW4BS/sIZoGswNJzH96D 62dJq6qc2R5ffPC545P+OfU7Y+OxfOUBjyUmxWHc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.112.248]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MS3mz-1nBlFm316B-00TQj5; Sat, 06 Nov 2021 18:41:33 +0100 In-Reply-To: (Jim Porter's message of "Sat, 6 Nov 2021 09:38:59 -0700") X-Provags-ID: V03:K1:Y18+XczY5W4ZcT818WeJUGcLTdpDHRWb1n9k3I+yHSi9Xkkz2uP hSHNqREQtwJ2PCb5xJOeyE6Dkb5oczMZ1rUYwaDVrDgLY3W+XaFTWPhthoTBQQx0+MPizly AWAdXuQANzepN11ZTTNAP5KaQ75OcKc271SOXpRJXKqOKoCIjURfF8UBze+MNX1p+vkvClU ZQBqAGQKSKdzOYQIRZNgw== X-UI-Out-Filterresults: notjunk:1;V03:K0:tk2jpxV/NGY=:VzSHL1TXmzBJsU6mpqPGVk i/riJHdBM505Km0SKGl8hpIm7NKT4azapGS48zrFdh57CNmJCfLXtpP13vs4sbUJIZ71CPdeA UQfIXTtNZLpC54uQ5cFN+jLx11I60qr2SP7gDvg0/rTjjcYXmefvt2Kwbx42c2mGb+9LrDakC Zg1XOl2U+qWDMi0lMGhneooQlBnm5uPMmZKtS5dqPb/3NWGl+knt28Howp85bh43yN9IRVcM6 vEvp3QdArGeGrp/bpqJmLf3REua+rxhcPVSzcyCB3Gsw2tF352iO68bD/vVjmvSIsoAx9l0z5 Az9Qbcil7x+1QCBKBvsxHyNi0lviiGVjcYcCySVzYwYZUB1iATBaNNXp4Z6HYyAhFemjyKrYp iy86mEdz9A1bT0wF7tTsexqaECutBXVM4zcA45Q+arq5QrckJRueo9cicDxTqGEgFYO12szqj OIiYe6WsQC5+ZaJdZfffRSvvC4yq6xCsXZcnTwig98ROJJuptCOQXAFF5ROqhmBbKOcLankDq yNuwzRPj6wxlrnwDDSry1VgXNr2qfhVGZ6p1NAh7THl5bCLRY9dLvfCtzJg8nDV8kATkdp+/b CAeNZh4P3vTrFnSDietMNCVE+9T7iqpaz0/B2lFL0/BDqfV54SP0WjOs+bni0NNiUF1lSuF7F 6hkd7P1pWJRHx9WmzYHWDvVS+hSeu0z1Clrzjig+GdgQ9gZOIuOMbOEa4ipoM9kVpPOy8c2VU RIh5sOf6ONcXgcxDla+srlm02nAWk5DGgjhv7bdp8bECGIS90dFd/FTOiiY+tHteumGWIcr5 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219122 Archived-At: Jim Porter writes: Hi Jim, >> I disagree. We shall keep the cached abbreviated-home-dir as *local* >> home directory. Remote home directories shall be handled in Tramp, and >> nowhere else. >> This is a general design goal which I try to follow. Mixing Tramp >> needs >> with other packages is good for trouble, and shall be avoided if possible. > > Ok, I can do that. I could even add caching for remote hosts if people > think it would help (it would probably improve performance, at least a > little bit). However, while I was looking at the implementation of > `abbreviate-file-name', I saw the following comment: > > ;; FIXME Is it even worth caching abbreviated-home-dir? > ;; Ref: https://debbugs.gnu.org/19657#20 > > After looking over the explanation in that link, I decided to see what > the performance impact would be if I removed the caching. In my > opinion, the benchmarks suggest that the caching a small enough impact > that the brittleness with using the cache outweighed the > benefits. However, I don't feel strongly about that and if the cache > should stay, that's ok with me. As said, I have no opinion about this. However, we shall care Eli's opinion, who dislikes such a change. >> The appended patch is a proof of concept w/o any systematic testing, it >> is not ready for commit. You might use it in order to get the idea, and >> to provide an applicable patch. It handles only tramp-sh.el; other Tramp >> backends might need something similar. > > Is it a general rule that all Tramp-specific stuff goes into the Tramp > files, or would it be ok to write a patch that only touches files.el, > so long as the performance for local files isn't hurt? It wouldn't be > terribly difficult to replace `abbreviated-home-dir' with something > that handles multiple hosts, similar to `grep-host-defaults-alist'. > > If I understand things correctly, `file-remote-p' can be non-nil for a > non-Tramp file if it has a file name handler that says so (e.g. if I > wrote my own package that handles some remote files in a different way > from Tramp). Maybe that's an argument in favor of changing this in > `abbreviate-file-name'. Then it works with any remote file. On the > other hand, maybe we need more protocol-specific information to do > this correctly, and I should do this inside Tramp... The general rule is, to keep all this specific handling away from files.el and companions. Emacs has the concept of file name handlers, and if there is something to be done special, a file name handler shall offer an alternative implementation. This is true for remote file names (packages tramp*.el, ange-ftp.el, url-handler.el) as well as for other special handling like automatic compression/decompression of files (jka-compr.el), GPG encryption/decryption (epa*.el), handling image files (mage-file.el), handling of tar files (tar-mode.el) etc. Not every file name handler must implement all "magic" functions, if there's no specific implementation, the original function is used. See (info "(elisp) Magic File Names") for the list of basic functions a file name handler could offer its own implementation, currently these are 75 functions. > Either way, I'll look at your patch and see how it compares; if doing > it that way ends up being better, then I'll try to implement something > like that. I see in your patch that you add to > `directory-abbrev-alist'. Is it ok to change a defcustom automatically > like this? It seems to work in my limited tests, but I thought > defcustoms were for users to set themselves. Should I come up with a > different way to do this if I want to merge it into Emacs? If we want to implement a general purpose solution, not only for remote file names in Tramp, we shall add `abbreviate-file-name' to that list. Different file name handlers could start to offer their own implementation, for the other file name handlers the current default behavior will be kept. Perhaps we shall go this way. And the first candidate would be tramp-sh.el. Best regards, Michael.