Subject: Emacs `compile' command does not handle remote (over TRAMP) file name correctly

From: Duncan Greatwood <[email-masked]>
Date: Sun, 22 Dec 2019 21:05:08 -0800

Emacs version aside, this appears almost identical to the other bug
of same name: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38648

Using tramp, I had a remote cpp file open in a window.

I pressed "C-c c", which invokes a function in my .emacs called
compile-hereish, which (in this case) invokes the compile command with
the remote directory containing the remote cpp.

Compilation runs as expected, throwing certain cpp syntax errors. Now,
if I click on the red error text in the *compilation* window, I get a
prompt like:
Find this error in (default <remote filename>):
/ssh:<username>@<hostname>:/System/Volumes/Data/<remote path to file>

If I press enter, to confirm, I get a [No match] error

I believe this may be a newly revealed issue under macos Catalina. Of
possible note (especially the last), these are the mounts on local
(macos) machine:

$ sudo mount
  /dev/disk1s5 on / (apfs, local, read-only, journaled)
  devfs on /dev (devfs, local, nobrowse)
  /dev/disk1s1 on /System/Volumes/Data (apfs, local, journaled, nobrowse)
  /dev/disk1s4 on /private/var/vm (apfs, local, journaled, nobrowse) map
  auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)

Might the fix in 27.1 referenced in report #38648 need to be back-ported
to 26.x?

As per autogenerated report below, I am using emacs 26.2 installed via
brew on macos.

The remote machine is running Ubuntu and:
$ ssh -V
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017

In GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20
Version 10.14.3 (Build 18D109))
 of 2019-04-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.1894
Recent messages:
Tramp: Encoding local file
‘/var/folders/nh/nhxs1bmd3h79lvh_z2lpfl700000gn/T/tramp.KiHs9f.cpp’ using
‘(lambda (beg end) (let ((coding-system-for-write (quote binary))
(coding-system-for-read (quote binary))) (apply (quote
tramp-call-process-region) (quote (tramp-file-name ssh <username> nil
<hostname> nil
/home/<username>/Dropbox/progs/FUSEScatterFS/sbshared/src/SB_RemCli.cpp
nil)) beg end (car (split-string env GZIP= gzip)) t t nil (cdr
(split-string env GZIP= gzip)))) (base64-encode-region (point-min)
(point-max)))’...done
Tramp: Decoding remote file
‘/ssh:<username>@<hostname>:/home/<username>/Dropbox/progs/FUSEScatterFS/sbshared/src/SB_RemCli.cpp’
using ‘(base64 -d -i | env GZIP= gzip -d >%s)’...done
Wrote
/ssh:<username>@<hostname>:/home/<username>/Dropbox/progs/FUSEScatterFS/sbshared/src/SB_RemCli.cpp
Tramp: Opening connection for <username>@<hostname> using ssh...
Tramp: Sending command ‘exec ssh -q -l <username>  -o ControlMaster=auto -o
ControlPath='tramp.%C' -o ControlPersist=no -e none <hostname>’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘<hostname>’
Tramp: Opening connection for <username>@<hostname> using ssh...done
Compilation finished
Wrote /Users/<username>/.emacs.d/dotemacs-persistent-scratch.txt

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Compilation

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-auto-complete-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/Users/<username>/.emacs.d/lisp/linum hides
/Applications/Emacs.app/Contents/Resources/lisp/linum

Features:
(shadow sort mail-extr emacsbug message rmc puny seq rfc822 mml mml-sec
epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
compile thingatpt linum cus-edit cus-start cus-load wid-edit cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs vc-git diff-mode easymenu make-mode dired dired-loaddefs files-x
misearch multi-isearch elec-pair tramp-cmds tramp-cache tramp-sh tramp
tramp-compat tramp-loaddefs trampver shell pcomplete comint ansi-color
ring parse-time format-spec auth-source cl-seq eieio byte-opt bytecomp
byte-compile cconv eieio-core eieio-loaddefs password-cache refill
easy-mmode server persistent-todo persistent-scratch
solarized-dark-theme solarized color dash advice undo-tree diff
auto-complete-config auto-complete popup string-inflection paren unbound
cl-macs cl gv delsel edmacro kmacro cl-loaddefs cl-lib time-date tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic 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 charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information: ((conses 16 579216 42454) (symbols 48 31163 2)
(miscs 40 320 1931) (strings 32 240818 5539) (string-bytes 1 2586465)
(vectors 16 55106) (vector-slots 8 1767127 124118) (floats 8 330 479)
(intervals 56 9362 551) (buffers 992 35))