Subject: 29.0.50; xref-search-program breaks if programm not installed on a remote host

From: Philip Kaludercic <[email-masked]>
Date: Sun, 30 Jan 2022 23:38:40 +0000

When invoking a command that respects xref-search-program via TRAMP,
e.g. on a remote system that doesn't have (in my case ripgrep)
installed, an error is signalled indicating that the search query
couldn't be executed.

I managed to temporarily circumvent the issue with this patch

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index c812f28c1b..92c3d5c9d5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -794,6 +794,11 @@ project-find-regexp
   (let* ((caller-dir default-directory)
          (pr (project-current t))
          (default-directory (project-root pr))
+         (xref-search-program
+          (if (and (eq xref-search-program 'ripgrep)
+                   (not (executable-find "rg" t)))
+              'grep
+              xref-search-program))
          (files
           (if (not current-prefix-arg)
               (project-files pr)

but just assuming that grep is available might just push the actual
problem aside.  Should xref-search-program be able to indicate a
failback, and perhaps even eventually fall back onto a elisp grep that
might be slow but at least would do the job?

In GNU Emacs 29.0.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2022-01-21 built on icterid
Repository revision: 98355833ba0d7dc20742122334be1bfaefac7873
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-x-toolkit=athena --with-native-compilation
 'CFLAGS=-Os -march=native -mtune=native -pipe' LDFLAGS=-flto'

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 WEBP X11 XDBE XIM XPM LUCID ZLIB

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

Major mode: ELisp/l

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  shell-dirtrack-mode: t
  bug-reference-prog-mode: t
  rcirc-track-minor-mode: t
  outline-minor-mode: t
  corfu-mode: t
  flymake-mode: t
  flyspell-mode: t
  recentf-mode: t
  repeat-mode: t
  display-time-mode: t
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  winner-mode: t
  windmove-mode: t
  vertico-multiform-mode: t
  vertico-mode: t
  electric-pair-mode: t
  save-place-mode: t
  savehist-mode: t
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-save-visited-mode: t

Load-path shadows:
/home/philip/.config/emacs/site-lisp/eglot/eglot hides /home/philip/.config/emacs/elpa/eglot-1.8/eglot
/home/philip/.config/emacs/site-lisp/eglot/eglot-tests hides /home/philip/.config/emacs/elpa/eglot-1.8/eglot-tests
/home/philip/.config/emacs/site-lisp/vc-backup/vc-backup hides /home/philip/.config/emacs/elpa/vc-backup-1.1.0/vc-backup
/home/philip/.config/emacs/elpa/transient-0.3.7/transient hides /home/philip/Source/emacs/lisp/transient
~/.config/emacs/site-lisp/autoload hides /home/philip/Source/emacs/lisp/emacs-lisp/autoload

Features:
(shadow emacsbug etags fileloop generator eglot array jsonrpc ert
flymake-shellcheck sh-script smie executable perl-mode vc-mtn vc-hg
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs grep flymake-cc
yasnippet-snippets yasnippet cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs debug shell-command+
dired-aux gnus-dired org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete org-list
org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval
org-table oc-basic bibtex ol org-keys oc org-compat advice org-macs
org-loaddefs cal-menu calendar cal-loaddefs debbugs-gnu debbugs
soap-client rng-xsd rng-dt rng-util xsd-regexp tar-mode arc-mode
archive-mode url-http url-gw url-cache url-auth cus-edit pp cus-start
finder-inf cl-print edebug backtrace whitespace vc-annotate qp
magit-extras face-remap magit-submodule magit-obsolete magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode git-commit
log-edit add-log magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process with-editor shell pcomplete
server magit-mode transient edmacro kmacro format-spec magit-git
magit-section magit-utils crm dash mailalias smtpmail avy mule-util
char-fold misearch multi-isearch pulse color xref vc-git bug-reference
find-func help-fns autocrypt-message copyright vc-backup log-view
pcvs-util time-stamp sort smiley gnus-cite mm-archive mail-extr textsec
uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check
gnus-async gnus-bcklg gnus-ml autocrypt-gnus autocrypt nndraft nnmh
utf-7 nnfolder gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig nntp
gnus-cache gnus-sum shr pixel-fill kinsoku svg dom gnus-group gnus-undo
gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7
netrc nnoo gnus-spec gnus-int gnus-range message yank-media rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
gnus-win modus-vivendi-theme gnutls network-stream puny nsm rmc epa-file
epa epg rfc6068 epg-config rcirc parse-time iso8601 vertico-directory
vertico-flat noutline outline corfu checkdoc flymake-proc flymake
derived project thingatpt flyspell ispell comp comp-cstr warnings
cl-extra auth-source-pass recentf tree-widget repeat dired-x dired
dired-loaddefs time sendmail gnus nnheader gnus-util time-date
mail-utils range wid-edit help-at-pt diff-hl-flydiff diff diff-hl vc-dir
ewoc vc vc-dispatcher diff-mode hippie-exp winner windmove rx
vertico-multiform vertico easy-mmode pcase elec-pair saveplace savehist
xt-mouse modus-operandi-theme modus-themes rot13 disp-table icomplete
cus-load setup help-mode compile text-property-search comint ansi-color
ring autoload radix-tree lisp-mnt mail-parse rfc2231 rfc2047 rfc2045
mm-util ietf-drums mail-prsvr slime-autoloads info package browse-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars
seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
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 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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button 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 x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 1126377 131479)
 (symbols 48 44180 90)
 (strings 32 188808 12506)
 (string-bytes 1 5609582)
 (vectors 16 107028)
 (vector-slots 8 2610956 134057)
 (floats 8 793 733)
 (intervals 56 49401 625)
 (buffers 992 94))

-- 
	Philip Kaludercic