unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68041: 30.0.50; Tramp error with project-find-file
@ 2023-12-26 13:06 Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-12-26 16:27 ` Dmitry Gutov
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-12-26 13:06 UTC (permalink / raw)
  To: 68041

[-- Attachment #1: Type: text/plain, Size: 4407 bytes --]

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))


[-- Attachment #2: project-find-file.patch --]
[-- Type: text/x-patch, Size: 759 bytes --]

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))))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#68041: 30.0.50; Tramp error with project-find-file
  2023-12-26 13:06 bug#68041: 30.0.50; Tramp error with project-find-file Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-12-26 16:27 ` Dmitry Gutov
  2023-12-26 19:48   ` Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2023-12-26 16:27 UTC (permalink / raw)
  To: Frédéric Giquel, 68041

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

Hi!

On 26/12/2023 15:06, Frédéric Giquel via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> 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).

Thanks for the report.

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?


[-- Attachment #2: project--read-file-cpd-relative-no-connect.diff --]
[-- Type: text/x-patch, Size: 1616 bytes --]

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 0082f12666a..dc0fd9a6efe 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1147,14 +1147,15 @@ project--read-file-cpd-relative
          (new-collection (project--file-completion-table substrings))
          (abs-cpd (expand-file-name common-parent-directory))
          (abs-cpd-length (length abs-cpd))
-         (relname (cl-letf (((symbol-value hist)
-                             (mapcan
-                              (lambda (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))))
-                              (symbol-value hist))))
+         (relname (cl-letf* ((non-essential t) ;Avoid new connections in Tramp.
+                             ((symbol-value hist)
+                              (mapcan
+                               (lambda (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))))
+                               (symbol-value hist))))
                     (project--completing-read-strict prompt
                                                      new-collection
                                                      predicate

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#68041: 30.0.50; Tramp error with project-find-file
  2023-12-26 16:27 ` Dmitry Gutov
@ 2023-12-26 19:48   ` Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-12-27  0:22     ` Dmitry Gutov
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-12-26 19:48 UTC (permalink / raw)
  To: Dmitry Gutov, 68041

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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#68041: 30.0.50; Tramp error with project-find-file
  2023-12-26 19:48   ` Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-12-27  0:22     ` Dmitry Gutov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2023-12-27  0:22 UTC (permalink / raw)
  To: Frédéric Giquel, 68041-done

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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-27  0:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-26 13:06 bug#68041: 30.0.50; Tramp error with project-find-file Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-26 16:27 ` Dmitry Gutov
2023-12-26 19:48   ` Frédéric Giquel via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-27  0:22     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).