From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#51622: 29.0.50; [PATCH] Abbreviate remote home directories in `abbreviate-file-name' Date: Sat, 6 Nov 2021 09:38:59 -0700 Message-ID: References: <5ac0b5f3-302c-2f96-771c-8d38088aa573@gmail.com> <87mtmhmh60.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15325"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51622@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 06 17:40:26 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 1mjOjx-0003nf-Vi for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Nov 2021 17:40:26 +0100 Original-Received: from localhost ([::1]:56304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjOjw-0000HC-KR for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Nov 2021 12:40:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjOjc-0000GT-2S for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 12:40:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjOja-0002jg-5a for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 12:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mjOja-0001FP-3G for bug-gnu-emacs@gnu.org; Sat, 06 Nov 2021 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Nov 2021 16:40: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.16362167474703 (code B ref 51622); Sat, 06 Nov 2021 16:40:02 +0000 Original-Received: (at 51622) by debbugs.gnu.org; 6 Nov 2021 16:39:07 +0000 Original-Received: from localhost ([127.0.0.1]:50293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjOig-0001Dm-PH for submit@debbugs.gnu.org; Sat, 06 Nov 2021 12:39:07 -0400 Original-Received: from mail-pg1-f173.google.com ([209.85.215.173]:35669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjOif-0001DH-8G for 51622@debbugs.gnu.org; Sat, 06 Nov 2021 12:39:05 -0400 Original-Received: by mail-pg1-f173.google.com with SMTP id p17so11071181pgj.2 for <51622@debbugs.gnu.org>; Sat, 06 Nov 2021 09:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=obFwab9kvHrFQhvG8kXsNaUVEwpLx1T0nHXOH96esIY=; b=ZPVQrUo2Bq62Zm3rcOz1iOqIw/bOnF936WrzL8Rqvc87EpaSlA2RskJFuqC5eiaeyT CaCXTdeuBIY3wV0RPf2OAl12OYDjWIZYOp1wnTf/IJBM/s9FisuFDgXhIwKboXQbWSUp 4n51B96/KkaDDEcDHid9vjYthhw1piSfAuCZ5GikDEJ7tcu+nhmS+ayfLHjeH7yK9Y// 5qIFNjpYJYJTWUSS322H1pcwu2ZE2l96o2hcS3PNvmV6sqeTeLcsHb359I7VMU8b6w/X gGCq0pLxAn+Qd5NXlHxnBJ4lu9Xf+j4MO9LjH8UKjvnlF8A6Mdg+nW5M8k0IoDjP0HrZ 8sxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=obFwab9kvHrFQhvG8kXsNaUVEwpLx1T0nHXOH96esIY=; b=WC9stuP8991m9lcgSKJCGlou0iE+0GG0NqF+5OVUuifJ99MaNHUZhw5ps/Ttib4MdF T6wDXarj1/wKsDX6h365WIUe1yQKg6l2xp/hUzClrutS1CEk0s30Z4NRVjaApEstdZyg /O8YmjY2VsfivFx5SY8svF6K0cQnMLhpBumZ97LIpcG8AHbyyLWligR51Pv42uex6nCH 8hQwZ79PzRLn0Yz8Xmo/Ht+TmlcAD14vx4kpHMQRO/J0lJxZetPC+VUFmPDFhuJhfB6j qANB4oTJ21IBjGkudC6eywd6elont1nrQP4W4xExaLdejJJP14GyIOZKvIJloODUVNn3 wu1g== X-Gm-Message-State: AOAM532v7SsHPfMX5iT44jWhN3a/tMWdJTM/S8WZfqt7tD7ZLymkQ4er 0P35dIRrOaw0zsjF5DD2Tjt71mr/5Ks= X-Google-Smtp-Source: ABdhPJxx6nnEAGM/15mltOG2xQPgGjOVocdVKO/tK5Be06oRpDZBeDCe1ie42NKIst5KMusDiouZBw== X-Received: by 2002:a05:6a00:17a5:b0:49f:add2:3c85 with SMTP id s37-20020a056a0017a500b0049fadd23c85mr4557159pfg.48.1636216739337; Sat, 06 Nov 2021 09:38:59 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id h3sm11516618pfi.207.2021.11.06.09.38.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Nov 2021 09:38:58 -0700 (PDT) In-Reply-To: <87mtmhmh60.fsf@gmx.de> Content-Language: en-US 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:219116 Archived-At: On 11/6/2021 8:34 AM, Michael Albinus wrote: > 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. > I believe there is a much simpler solution: Add the following entry > (derived from your example) to directory-abbrev-alist: > > ("\\`/sshx:localhost:/home/jim" . "/sshx:localhost:~") I had thought about doing that originally, but when I looked into the implementation to understand why home-dir abbreviation didn't work on remote files, I figured the better long-term solution is to fix `abbreviate-file-name' somehow. Then everyone benefits from the improvement. > 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... 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? > Tramp tests could be added to tramp-tests.el. You'll see there a Tramp > mockup method which gives you the possibility to add a test w/o a > working ssh connection or alike. Thanks, I'll take a look.