Subject: bug#68041: closed (Re: bug#68041: 30.0.50; Tramp error with project-find-file)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 27 Dec 2023 00:23:02 +0000

Your bug report

#68041: 30.0.50; Tramp error with project-find-file

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
68041: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68041
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#68041: 30.0.50; Tramp error with project-find-file
From: Dmitry Gutov <[email-masked]>
To: Frédéric Giquel <[email-masked]>, [email-masked]
Date: Wed, 27 Dec 2023 02:22:04 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On 26/12/2023 21:48, Frédéric Giquel wrote:
> Le mardi 26 décembre 2023 à 18:27 +0200, Dmitry Gutov a écrit :
>> How about the attached patch instead?
>>
>> Skipping expand-file-name altogether would likely drop the respective
>> entries from history as well.
>>
>> I'm curious whether expand-file-name hits the remote every time when
>> called, though (100 times the latency would be a wait too long). If
>> you
>> have remote entries in history, could you try and see how the
>> performance is when working on that remote, too?
> I tested your patch. It works well: no error and no perceived latency.

Great! Thanks for testing, pushed to master.

Subject: 30.0.50; Tramp error with project-find-file
From: Frédéric Giquel <[email-masked]>
To: [email-masked]
Date: Tue, 26 Dec 2023 14:06:20 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Commits from last week on project.el
(338409c1f19e1d3a97d12edaf5ac36f1a781d08a and
	0d518b78d785613967fb1b375aa7932385991891) introduce problems when fileshistorycontainsTrampreference.

Here is the procedure to repoduce :
- launch an 'emacs -Q' session
- eval (add-to-list 'file-name-history "/ssh:inaccessible-host:~/") to
add Tramp reference in file history
- open a local file from a project with 'find-file'
- do 'M-x project-find-file'

This results in a 'Tramp failed to connect' error. If the host is
accessible, there is no error but we can see trace of an SSH connection
(with the associated latency). It's not something we expect when we're
working on an entirely local project.

As far as I understand the 'project--read-file-cpd-relative' function,
a simple fix is to limit 'expand-file-name' to local files (as in the
attached patch).

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.39, cairo version 1.18.0) of 2023-12-26 built on guiriden
Repository revision: 60199ac01d711d3240146afedd830b774eb5c5d2
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version
11.0.12302003
System Description: Debian GNU/Linux trixie/sid

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2
XPM GTK3 ZLIB

Important settings:
  value of $LANG: fr_FR.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tramp-cmds tramp-cache time-stamp tramp-sh tramp trampver
tramp-integration tramp-message help-mode tramp-compat xdg shell
pcomplete parse-time iso8601 time-date format-spec auth-source eieio
eieio-core cl-macs password-cache json subr-x map tramp-loaddefs vc-git
diff-mode easy-mmode vc-dispatcher thingatpt cl-seq project byte-opt gv
compile text-property-search comint ansi-osc ansi-color ring comp-run
bytecomp byte-compile comp-common rx dired-aux cl-loaddefs cl-lib
files-x dired dired-loaddefs rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd
fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-
generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo gtk
x-toolkit xinput2 x multi-tty move-toolbar make-network-process
native-compile emacs)

Memory information:
((conses 16 120492 10139) (symbols 48 9772 0) (strings 32 32853 1588)
 (string-bytes 1 1030498) (vectors 16 21995)
 (vector-slots 8 428265 15164) (floats 8 36 28) (intervals 56 690 0)
 (buffers 992 14))

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 0082f12666a..d12c5ff8db7 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1150,7 +1150,8 @@ project--read-file-cpd-relative
          (relname (cl-letf (((symbol-value hist)
                              (mapcan
                               (lambda (s)
-                                (setq s (expand-file-name s))
+                                (unless (file-remote-p s)
+                                  (setq s (expand-file-name s)))
                                 (and (string-prefix-p abs-cpd s)
                                      (not (eq abs-cpd-length (length s)))
                                      (list (substring s abs-cpd-length))))