unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
@ 2020-12-09 15:08 Tobias Rittweiler
  2020-12-23  2:16 ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Tobias Rittweiler @ 2020-12-09 15:08 UTC (permalink / raw)
  To: 45135


[-- Attachment #1.1: Type: text/plain, Size: 24706 bytes --]

Dear maintainers,

please find patches attached to this e-mail that make it possible to
set 'xref-file-name-display' to 'relative-to-project-root'. If so set,
the file names in the *xref* buffer will be shortened by the 'project-root'
and 'project-external-roots' of 'project-current'. Note that xref.el already
requires 'project'.

The patches are relative to commit 2581beb from Wed Dec 9 00:54:34 2020
+0000

Please note that I marked the NEWS entry as "no documentation update
needed". That is because `xref-file-name-display` does not seem to be
included in the documentation.

I do have copyright-assigments to the FSF in place.

Please let me know what else I can do to get this accepted into Emacs.

Best regards,

Tobias



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0)
 of 2020-12-09 built on samarkand
Repository revision: a5c6f7687d981afce7a823696bac058320327cd2
Repository branch:
trittweiler/add_relative_to_project_root_to_xref_file_name_display
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 20.04.1 LTS

Configured using:
 'configure --prefix=/home/trittweiler/.local/software/emacs-git/'

Configured features:
XPM JPEG TIFF GIF PNG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY
LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER

Important settings:
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Outline

Minor modes in effect:
  bug-reference-mode: t
  shell-dirtrack-mode: t
  counsel-mode: t
  ivy-mode: t
  global-company-mode: t
  company-mode: t
  winner-mode: t
  global-whitespace-cleanup-mode: t
  whitespace-cleanup-mode: t
  override-global-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
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-10/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-10/emacs
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-10/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-4.0/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-4.0/emacs
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-4.0/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-7/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-7/emacs
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-7/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-8/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-8/emacs
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-8/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-9/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-9/emacs
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-9/tablegen-mode
/usr/share/emacs/site-lisp/cmake-mode hides
/home/trittweiler/.emacs.d/elpa/cmake-mode-20190710.1319/cmake-mode
/home/trittweiler/src/open-source/elisp/eglot.git/eglot hides
/home/trittweiler/.emacs.d/elpa/eglot-20200416.2220/eglot
/home/trittweiler/.emacs.d/elpa/org-9.4/org-compat hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-compat
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-dot hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-dot
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-eval hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-eval
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-fortran hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-fortran
/home/trittweiler/.emacs.d/elpa/org-9.4/org-feed hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-feed
/home/trittweiler/.emacs.d/elpa/org-9.4/org-mouse hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-mouse
/home/trittweiler/.emacs.d/elpa/org-9.4/org-keys hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-keys
/home/trittweiler/.emacs.d/elpa/org-9.4/org-colview hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-colview
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-eww hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-eww
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-awk hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-awk
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-mhe hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-mhe
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-org hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-org
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-coq hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-coq
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-calc hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-calc
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-js hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-js
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-matlab hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-matlab
/home/trittweiler/.emacs.d/elpa/org-9.4/org-inlinetask hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-inlinetask
/home/trittweiler/.emacs.d/elpa/org-9.4/org-agenda hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-agenda
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-io hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-io
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-docview hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-docview
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-beamer hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-beamer
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-eshell hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-eshell
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-octave hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-octave
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-makefile hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-makefile
/home/trittweiler/.emacs.d/elpa/org-9.4/org-tempo hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-tempo
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ruby hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ruby
/home/trittweiler/.emacs.d/elpa/org-9.4/org-capture hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-capture
/home/trittweiler/.emacs.d/elpa/org-9.4/org-src hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-src
/home/trittweiler/.emacs.d/elpa/org-9.4/ob hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-screen hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-screen
/home/trittweiler/.emacs.d/elpa/org-9.4/org-footnote hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-footnote
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-shen hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-shen
/home/trittweiler/.emacs.d/elpa/org-9.4/org-indent hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-indent
/home/trittweiler/.emacs.d/elpa/org-9.4/org-attach hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-attach
/home/trittweiler/.emacs.d/elpa/org-9.4/org-datetree hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-datetree
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-clojure hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-clojure
/home/trittweiler/.emacs.d/elpa/org-9.4/org-timer hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-timer
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-stan hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-stan
/home/trittweiler/.emacs.d/elpa/org-9.4/org-archive hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-archive
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-irc hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-irc
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-texinfo hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-texinfo
/home/trittweiler/.emacs.d/elpa/org-9.4/org-protocol hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-protocol
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-info hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-info
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-asymptote hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-asymptote
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-haskell hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-haskell
/home/trittweiler/.emacs.d/elpa/org-9.4/org-duration hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-duration
/home/trittweiler/.emacs.d/elpa/org-9.4/org-macro hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-macro
/home/trittweiler/.emacs.d/elpa/org-9.4/ol hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-bibtex hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-bibtex
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-ascii hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-ascii
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-exp hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-exp
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-latex hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-latex
/home/trittweiler/.emacs.d/elpa/org-9.4/org-pcomplete hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-pcomplete
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-w3m hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-w3m
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-rmail hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-rmail
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-scheme hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-scheme
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-table hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-table
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-md hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-md
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-perl hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-perl
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-hledger hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-hledger
/home/trittweiler/.emacs.d/elpa/org-9.4/org-clock hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-clock
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-mscgen hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-mscgen
/home/trittweiler/.emacs.d/elpa/org-9.4/org-list hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-list
/home/trittweiler/.emacs.d/elpa/org-9.4/org-mobile hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-mobile
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-icalendar hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-icalendar
/home/trittweiler/.emacs.d/elpa/org-9.4/org-num hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-num
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-C hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-C
/home/trittweiler/.emacs.d/elpa/org-9.4/ox hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-lisp hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-lisp
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-shell hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-shell
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-forth hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-forth
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-org hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-org
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-lob hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-lob
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-publish hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-publish
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ref hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ref
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-man hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-man
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ditaa hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ditaa
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-latex hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-latex
/home/trittweiler/.emacs.d/elpa/org-9.4/org-crypt hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-crypt
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-sql hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-sql
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-css hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-css
/home/trittweiler/.emacs.d/elpa/org-9.4/org-habit hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-habit
/home/trittweiler/.emacs.d/elpa/org-9.4/org-macs hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-macs
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-tangle hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-tangle
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-groovy hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-groovy
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-html hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-html
/home/trittweiler/.emacs.d/elpa/org-9.4/org-ctags hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-ctags
/home/trittweiler/.emacs.d/elpa/org-9.4/org-table hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-table
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ocaml hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ocaml
/home/trittweiler/.emacs.d/elpa/org-9.4/org-loaddefs hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-loaddefs
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-gnus hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-gnus
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-gnuplot hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-gnuplot
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-lua hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-lua
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-emacs-lisp hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-emacs-lisp
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-vala hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-vala
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-python hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-python
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-eshell hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-eshell
/home/trittweiler/.emacs.d/elpa/org-9.4/org hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ledger hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ledger
/home/trittweiler/.emacs.d/elpa/org-9.4/ox-odt hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ox-odt
/home/trittweiler/.emacs.d/elpa/org-9.4/ol-bbdb hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ol-bbdb
/home/trittweiler/.emacs.d/elpa/org-9.4/org-id hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-id
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-java hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-java
/home/trittweiler/.emacs.d/elpa/org-9.4/org-lint hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-lint
/home/trittweiler/.emacs.d/elpa/org-9.4/org-install hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-install
/home/trittweiler/.emacs.d/elpa/org-9.4/org-goto hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-goto
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-J hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-J
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-plantuml hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-plantuml
/home/trittweiler/.emacs.d/elpa/org-9.4/org-attach-git hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-attach-git
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-lilypond hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-lilypond
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-comint hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-comint
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-abc hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-abc
/home/trittweiler/.emacs.d/elpa/org-9.4/org-element hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-element
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-picolisp hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-picolisp
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-maxima hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-maxima
/home/trittweiler/.emacs.d/elpa/org-9.4/org-plot hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-plot
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-sed hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-sed
/home/trittweiler/.emacs.d/elpa/org-9.4/org-entities hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-entities
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-core hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-core
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-sass hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-sass
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-processing hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-processing
/home/trittweiler/.emacs.d/elpa/org-9.4/org-faces hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-faces
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-sqlite hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-sqlite
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-ebnf hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-ebnf
/home/trittweiler/.emacs.d/elpa/org-9.4/ob-R hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/ob-R
/home/trittweiler/.emacs.d/elpa/org-9.4/org-version hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/org/org-version
/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides
/home/trittweiler/.local/software/emacs-git/share/emacs/28.0.50/lisp/language/thai-word

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
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 bug-reference
tabify vc-mtn vc-hg vc-git diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs vc vc-dispatcher paredit company-oddmuse company-keywords
company-etags company-gtags company-dabbrev-code company-dabbrev
company-files company-clang company-capf company-cmake company-semantic
company-template company-bbdb settings systemd conf-mode protobuf-mode
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs vmd-mode bazel-mode bazel-util python tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
pcomplete parse-time iso8601 time-date ls-lisp format-spec ffap
cmake-mode derived eglot array filenotify jsonrpc ert ewoc debug
backtrace find-func flymake-proc flymake warnings imenu google-c-style
slime etags fileloop generator arc-mode archive-mode noutline outline pp
hyperspec thingatpt lice counsel xdg xref project dired dired-loaddefs
compile text-property-search comint ansi-color swiper ivy delsel
ivy-faces ivy-overlay colir color company pcase server edmacro kmacro
find-file winner ring windmove framemove whitespace-cleanup-mode advice
whitespace gruvbox-light-soft-theme gruvbox-theme gruvbox autothemer
dash cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core finder-inf slime-autoloads rx info package
easymenu 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 subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type 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 elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu 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 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
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 232115 17230)
 (symbols 48 23907 1)
 (strings 32 81463 3260)
 (string-bytes 1 2672785)
 (vectors 16 37219)
 (vector-slots 8 456398 16522)
 (floats 8 196 35)
 (intervals 56 365 45)
 (buffers 984 12))

[-- Attachment #1.2: Type: text/html, Size: 25857 bytes --]

[-- Attachment #2: 0002-Add-relative-to-project-root-as-value-for-xref-file-.patch --]
[-- Type: text/x-patch, Size: 6633 bytes --]

From a5c6f7687d981afce7a823696bac058320327cd2 Mon Sep 17 00:00:00 2001
From: Tobias Rittweiler <trittweiler@gmail.com>
Date: Tue, 8 Dec 2020 10:03:28 +0100
Subject: [PATCH 2/2] Add 'relative-to-project-root' as value for
 'xref-file-name-display'

* lisp/progmodes/xref.el (xref-file-name-display): Document new value.
(xref-location-group) [relative-to-project-root]: Display files names
in an xref buffer with prefixes cut off that match any of the root
directories of the current project.
(xref--project-roots): Extracted from default method of
'xref-backend-references' so it can be used in above's new code. Also
make it more correct as the previous implementation would cons a
list (return value of 'project-roots') onto another list (return value
of 'project-external-roots').

* test/lisp/progmodes/xref-tests.el: Add test cases for the three
possible settings of 'xref-file-name-display'.
---
 etc/NEWS                          |  5 ++++
 lisp/progmodes/xref.el            | 49 ++++++++++++++++++++++++-------
 test/lisp/progmodes/xref-tests.el | 31 +++++++++++++++++++
 3 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 83fe7a349e..60c4de5b55 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1210,6 +1210,11 @@ searches.
 These commands are bound respectively to 'P' and 'N', and navigate to
 the first item of the previous or next group in the "*xref*" buffer.
 
+---
+*** New value 'relative-to-project-root' for 'xref-file-name-display'
+If chosen, file names in *xref* buffers will be displayed relatively
+to the 'project-root' of the current project, if available.
+
 ** json.el
 
 ---
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 389b7cf247..b43af2b003 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -105,10 +105,23 @@ xref-match-length
 
 (defcustom xref-file-name-display 'abs
   "Style of file name display in *xref* buffers.
+
 If the value is the symbol `abs', the default, show the file names
 in their full absolute form.
+
 If `nondirectory', show only the nondirectory (a.k.a. \"base name\")
-part of the file name."
+part of the file name.
+
+If `relative-to-project-root', show only the path fragment relative
+to the root of the current project.  If there is no current project,
+or if a file name does not seem to be relative to the root, show
+that particular file in its full absolute form.
+For example \"foo/bar.c\" for \"~/src/quux.git/foo/bar.c\"
+assuming \"~/src/quux.git/\" is the `project-root' of
+`project-current'.)
+
+This customizable variable was introduced in Emacs 27.1. The
+`relative-to-project-root' value was added in Emacs 28.1."
   :type '(choice (const :tag "absolute file name" abs)
                  (const :tag "nondirectory file name" nondirectory))
   :version "27.1")
@@ -147,8 +160,22 @@ xref-location-marker
 
 (cl-defmethod xref-location-group ((l xref-file-location))
   (cl-ecase xref-file-name-display
-    (abs (oref l file))
-    (nondirectory (file-name-nondirectory (oref l file)))))
+    (abs
+     (oref l file))
+    (nondirectory
+     (file-name-nondirectory (oref l file)))
+    (relative-to-project-root
+     (let* ((file (oref l file))
+            (expanded-file-name (expand-file-name file))
+            (project (project-current nil))
+            (project-roots (when project
+                             (mapcar 'expand-file-name
+                                     (xref--project-roots project)))))
+       (cl-loop for root in project-roots
+                if (string-prefix-p root expanded-file-name)
+                  return (substring expanded-file-name (length root))
+                finally
+                  return file)))))
 
 (defclass xref-buffer-location (xref-location)
   ((buffer :type buffer :initarg :buffer)
@@ -267,13 +294,7 @@ xref-backend-references
   (mapcan
    (lambda (dir)
      (xref-references-in-directory identifier dir))
-   (let ((pr (project-current t)))
-     (cons
-      (if (fboundp 'project-root)
-          (project-root pr)
-        (with-no-warnings
-          (project-roots pr)))
-      (project-external-roots pr)))))
+   (xref--project-roots (project-current t))))
 
 (cl-defgeneric xref-backend-apropos (backend pattern)
   "Find all symbols that match PATTERN string.
@@ -343,6 +364,14 @@ xref--search-property
     (cond (value)
           (t (goto-char start) nil))))
 
+(defun xref--project-roots (project)
+  "All root directories of `project'."
+  (let ((externals (project-external-roots project)))
+    (if (fboundp 'project-root)
+        (cons (project-root project) externals)
+      (with-no-warnings
+        (append (project-roots project) externals)))))
+
 \f
 ;;; Marker stack  (M-. pushes, M-, pops)
 
diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el
index e52cc20053..61a6250519 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -97,3 +97,34 @@ xref--buf-pairs-iterator-cleans-up-markers
     (should (null (marker-position (cdr (nth 0 (cdr cons1))))))
     (should (null (marker-position (car (nth 0 (cdr cons2))))))
     (should (null (marker-position (cdr (nth 0 (cdr cons2))))))))
+
+(ert-deftest xref--xref-file-name-display-is-abs ()
+  (let ((xref-file-name-display 'abs))
+    (should (equal (delete-dups
+                    (mapcar 'xref-location-group
+                            (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))
+                   (list
+                    (concat xref-tests--data-dir "file1.txt")
+                    (concat xref-tests--data-dir "file2.txt"))))))
+
+(ert-deftest xref--xref-file-name-display-is-nondirectory ()
+  (let ((xref-file-name-display 'nondirectory))
+    (should (equal (delete-dups
+                    (mapcar 'xref-location-group
+                            (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))
+                   (list
+                    "file1.txt"
+                    "file2.txt")))))
+
+(ert-deftest xref--xref-file-name-display-is-relative-to-project-root ()
+  (let* ((data-parent-dir
+          (file-name-directory (directory-file-name xref-tests--data-dir)))
+         (project-find-functions
+          #'(lambda (_) (cons 'transient data-parent-dir)))
+        (xref-file-name-display 'relative-to-project-root))
+    (should (equal (delete-dups
+                    (mapcar 'xref-location-group
+                            (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))
+                   (list
+                    "xref-resources/file1.txt"
+                    "xref-resources/file2.txt")))))
-- 
2.25.1


[-- Attachment #3: 0001-Minor-refactoring-of-xref-tests.patch --]
[-- Type: text/x-patch, Size: 4869 bytes --]

From da4535cd825b5bc854f754fa6762a3e3ded5c850 Mon Sep 17 00:00:00 2001
From: Tobias Rittweiler <trittweiler@gmail.com>
Date: Tue, 8 Dec 2020 09:59:15 +0100
Subject: [PATCH 1/2] Minor refactoring of xref-tests

* test/lisp/progmodes/xref-tests.el (xref-tests-data-dir): Renamed to
'xref-tests--data-dir'
(xref-tests--matches-in-data-dir, xref-tests--locations-in-data-dir):
New functions. Factored out from test cases and updated usage sites to
use them.
---
 test/lisp/progmodes/xref-tests.el | 38 ++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el
index 038f9d0e30..e52cc20053 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -27,27 +27,34 @@
 (require 'xref)
 (require 'cl-lib)
 
-(defvar xref-tests-data-dir
+(defvar xref-tests--data-dir
   (expand-file-name "xref-resources/"
                     (file-name-directory
                      (or load-file-name buffer-file-name))))
 
+(defun xref-tests--matches-in-data-dir (regexp &optional files)
+  (xref-matches-in-directory regexp (or files "*") xref-tests--data-dir nil))
+
+(defun xref-tests--locations-in-data-dir (regexp &optional files)
+  (let ((matches (xref-tests--matches-in-data-dir regexp files)))
+    ;; Sort in order to guarantee an order independent from the
+    ;; filesystem traversal.
+    (cl-sort (mapcar #'xref-item-location matches)
+             #'string<
+             :key #'xref-location-group)))
+
 (ert-deftest xref-matches-in-directory-finds-none-for-some-regexp ()
-  (should (null (xref-matches-in-directory "zzz" "*" xref-tests-data-dir nil))))
+  (should (null (xref-tests--matches-in-data-dir "zzz"))))
 
 (ert-deftest xref-matches-in-directory-finds-some-for-bar ()
-  (let* ((matches (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
-         (locs (cl-sort (mapcar #'xref-item-location matches)
-                        #'string<
-                        :key #'xref-location-group)))
-    (should (= 2 (length matches)))
+  (let ((locs (xref-tests--locations-in-data-dir "bar")))
+    (should (= 2 (length locs)))
     (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
     (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs))))))
 
 (ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line ()
-  (let* ((matches (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
-         (locs (mapcar #'xref-item-location matches)))
-    (should (= 2 (length matches)))
+  (let ((locs (xref-tests--locations-in-data-dir "foo")))
+    (should (= 2 (length locs)))
     (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
     (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs))))
     (should (equal 1 (xref-location-line (nth 0 locs))))
@@ -56,15 +63,14 @@ xref-matches-in-directory-finds-two-matches-on-the-same-line
     (should (equal 4 (xref-file-location-column (nth 1 locs))))))
 
 (ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match ()
-  (let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil))
-         (locs (mapcar #'xref-item-location matches)))
-    (should (= 1 (length matches)))
+  (let ((locs (xref-tests--locations-in-data-dir "^$")))
+    (should (= 1 (length locs)))
     (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
     (should (equal 1 (xref-location-line (nth 0 locs))))
     (should (equal 0 (xref-file-location-column (nth 0 locs))))))
 
 (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
-  (let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
+  (let* ((xrefs (xref-tests--matches-in-data-dir "foo"))
          (iter (xref--buf-pairs-iterator xrefs))
          (cons (funcall iter :next)))
     (should (null (funcall iter :next)))
@@ -72,7 +78,7 @@ xref--buf-pairs-iterator-groups-markers-by-buffers-1
     (should (= 2 (length (cdr cons))))))
 
 (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 ()
-  (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
+  (let* ((xrefs (xref-tests--matches-in-data-dir "bar"))
          (iter (xref--buf-pairs-iterator xrefs))
          (cons1 (funcall iter :next))
          (cons2 (funcall iter :next)))
@@ -82,7 +88,7 @@ xref--buf-pairs-iterator-groups-markers-by-buffers-2
     (should (= 1 (length (cdr cons2))))))
 
 (ert-deftest xref--buf-pairs-iterator-cleans-up-markers ()
-  (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
+  (let* ((xrefs (xref-tests--matches-in-data-dir "bar"))
          (iter (xref--buf-pairs-iterator xrefs))
          (cons1 (funcall iter :next))
          (cons2 (funcall iter :next)))
-- 
2.25.1


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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-09 15:08 bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root Tobias Rittweiler
@ 2020-12-23  2:16 ` Dmitry Gutov
  2020-12-26  2:21   ` Dmitry Gutov
  2020-12-27  7:10   ` Tobias Rittweiler
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Gutov @ 2020-12-23  2:16 UTC (permalink / raw)
  To: Tobias Rittweiler, 45135

Hi Tobias,

On 09.12.2020 17:08, Tobias Rittweiler wrote:

> please find patches attached to this e-mail that make it possible to
> set 'xref-file-name-display' to 'relative-to-project-root'. If so set,
> the file names in the *xref* buffer will be shortened by the 'project-root'
> and 'project-external-roots' of 'project-current'. Note that xref.el already
> requires 'project'.
> 
> The patches are relative to commit 2581beb from Wed Dec 9 00:54:34 2020 
> +0000

Could you clarify the reason for the first patch? Did you have any test 
failures (on Ubuntu 20.04.1?) with the current test code because of the 
"random" filesystem traversal order? Thanks!

Re: patch 2, I have an idea that would make it a bit simpler and less 
coupled to project.el, but behave the same in the usual cases. Stay tuned.





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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-23  2:16 ` Dmitry Gutov
@ 2020-12-26  2:21   ` Dmitry Gutov
  2020-12-26  7:54     ` Eli Zaretskii
  2020-12-27  6:55     ` Tobias Rittweiler
  2020-12-27  7:10   ` Tobias Rittweiler
  1 sibling, 2 replies; 8+ messages in thread
From: Dmitry Gutov @ 2020-12-26  2:21 UTC (permalink / raw)
  To: Tobias Rittweiler, 45135

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

On 23.12.2020 04:16, Dmitry Gutov wrote:
> Re: patch 2, I have an idea that would make it a bit simpler and less 
> coupled to project.el, but behave the same in the usual cases. Stay tuned.

Not as clean as I hoped, but here's something that should work just as 
well, and a lot faster to boot (project-current lookup for every file 
name is slow when there are a lot of matches, even if each individual 
project-current call looks fast).

We could remove the explicit dependency on the "current project" if it 
was always passed in from the outside (e.g. by project-find-regexp's 
setup), but we probably want this display mode to work with 
xref-find-references as well.

Also simplified the docstring a bit.

Tobias, please try the attached patch.

[-- Attachment #2: xref-file-name-display-relative.diff --]
[-- Type: text/x-patch, Size: 4552 bytes --]

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 181f94b0bc..d7f9fd91f5 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -109,12 +109,20 @@ xref-match-length
 
 (defcustom xref-file-name-display 'abs
   "Style of file name display in *xref* buffers.
+
 If the value is the symbol `abs', the default, show the file names
 in their full absolute form.
+
 If `nondirectory', show only the nondirectory (a.k.a. \"base name\")
-part of the file name."
+part of the file name.
+
+If `relative', show only the path fragment relative to the
+current project root.  If there is no current project, or if the
+file name resides outside of its root, show that particular file
+in its full absolute form."
   :type '(choice (const :tag "absolute file name" abs)
-                 (const :tag "nondirectory file name" nondirectory))
+                 (const :tag "nondirectory file name" nondirectory)
+                 (const :tag "relative to project root" relative))
   :version "27.1")
 
 ;; FIXME: might be useful to have an optional "hint" i.e. a string to
@@ -149,10 +157,21 @@ xref-location-marker
             (forward-char column))
           (point-marker))))))
 
+(defvar-local xref--search-root nil
+  "The current search root.")
+
 (cl-defmethod xref-location-group ((l xref-file-location))
   (cl-ecase xref-file-name-display
-    (abs (oref l file))
-    (nondirectory (file-name-nondirectory (oref l file)))))
+    (abs
+     (oref l file))
+    (nondirectory
+     (file-name-nondirectory (oref l file)))
+    (relative
+     (let ((file (oref l file)))
+       (if (and xref--search-root
+                (string-prefix-p xref--search-root file))
+           (substring file (length xref--search-root))
+         file)))))
 
 (defclass xref-buffer-location (xref-location)
   ((buffer :type buffer :initarg :buffer)
@@ -273,10 +292,7 @@ xref-backend-references
      (xref-references-in-directory identifier dir))
    (let ((pr (project-current t)))
      (cons
-      (if (fboundp 'project-root)
-          (project-root pr)
-        (with-no-warnings
-          (project-roots pr)))
+      (xref--project-root pr)
       (project-external-roots pr)))))
 
 (cl-defgeneric xref-backend-apropos (backend pattern)
@@ -902,26 +918,39 @@ xref--analyze
 
 (defun xref--show-xref-buffer (fetcher alist)
   (cl-assert (functionp fetcher))
-  (let* ((xrefs
-          (or
-           (assoc-default 'fetched-xrefs alist)
-           (funcall fetcher)))
-         (xref-alist (xref--analyze xrefs)))
+  (let ((xrefs
+         (or
+          (assoc-default 'fetched-xrefs alist)
+          (funcall fetcher))))
     (with-current-buffer (get-buffer-create xref-buffer-name)
       (xref--xref-buffer-mode)
-      (xref--show-common-initialize xref-alist fetcher alist)
+      (xref--show-common-initialize xrefs fetcher alist)
       (pop-to-buffer (current-buffer))
       (current-buffer))))
 
-(defun xref--show-common-initialize (xref-alist fetcher alist)
+(defun xref--project-root (project)
+  (if (fboundp 'project-root)
+      (project-root project)
+    (with-no-warnings
+      (project-roots project))))
+
+(defun xref--expanded-seach-root (alist)
+  (let ((root
+         (or (assoc-default 'search-root alist)
+             (let ((pr (project-current)))
+               (and pr (xref--project-root pr))))))
+    (and root (expand-file-name root))))
+
+(defun xref--show-common-initialize (xrefs fetcher alist)
   (setq buffer-undo-list nil)
   (let ((inhibit-read-only t)
         (buffer-undo-list t))
+    (setq xref--original-window (assoc-default 'window alist)
+          xref--original-window-intent (assoc-default 'display-action alist)
+          xref--search-root (xref--expanded-seach-root alist))
     (erase-buffer)
-    (xref--insert-xrefs xref-alist)
     (goto-char (point-min))
-    (setq xref--original-window (assoc-default 'window alist)
-          xref--original-window-intent (assoc-default 'display-action alist))
+    (xref--insert-xrefs (xref--analyze xrefs))
     (setq xref--fetcher fetcher)))
 
 (defun xref-revert-buffer ()
@@ -965,7 +994,7 @@ xref--show-defs-buffer-at-bottom
      (t
       (with-current-buffer (get-buffer-create xref-buffer-name)
         (xref--transient-buffer-mode)
-        (xref--show-common-initialize (xref--analyze xrefs) fetcher alist)
+        (xref--show-common-initialize xrefs fetcher alist)
         (pop-to-buffer (current-buffer)
                        '(display-buffer-in-direction . ((direction . below))))
         (current-buffer))))))

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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-26  2:21   ` Dmitry Gutov
@ 2020-12-26  7:54     ` Eli Zaretskii
  2020-12-27  6:55     ` Tobias Rittweiler
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-26  7:54 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: trittweiler, 45135

> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Sat, 26 Dec 2020 04:21:47 +0200
> 
>  (defcustom xref-file-name-display 'abs
>    "Style of file name display in *xref* buffers.
> +
>  If the value is the symbol `abs', the default, show the file names
>  in their full absolute form.
> +
>  If `nondirectory', show only the nondirectory (a.k.a. \"base name\")

The first "If" clause says "If the value is the symbol FOO", which is
clear, but the other clauses say just "If FOO", which is much less
clear.  I suggest to say something intermediate like

  If the value is FOO, ...

> +If `relative', show only the path fragment relative to the

The GNU project's coding conventions frown on using "path" for
anything but PATH-style directory lists.  Suggest to say

  If it is `relative', show only the file-name fragment relative
  to the project root directory.

Thanks.





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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-26  2:21   ` Dmitry Gutov
  2020-12-26  7:54     ` Eli Zaretskii
@ 2020-12-27  6:55     ` Tobias Rittweiler
  2020-12-30 12:05       ` Dmitry Gutov
  1 sibling, 1 reply; 8+ messages in thread
From: Tobias Rittweiler @ 2020-12-27  6:55 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 45135

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

On Sat, 26 Dec 2020 at 03:21, Dmitry Gutov <dgutov@yandex.ru> wrote:

> On 23.12.2020 04:16, Dmitry Gutov wrote:
> > Re: patch 2, I have an idea that would make it a bit simpler and less
> > coupled to project.el, but behave the same in the usual cases. Stay
> tuned.
>
> Not as clean as I hoped, but here's something that should work just as
> well, and a lot faster to boot (project-current lookup for every file
> name is slow when there are a lot of matches, even if each individual
> project-current call looks fast).
>
> We could remove the explicit dependency on the "current project" if it
> was always passed in from the outside (e.g. by project-find-regexp's
> setup), but we probably want this display mode to work with
> xref-find-references as well.
>
> Also simplified the docstring a bit.
>
> Tobias, please try the attached patch.
>

Hi Dmitry,

Thank you. I tested the patch and it works fine.

Some comments on the patch itself:

1. 'xref--project-root' returns a project root if 'project-root' is fboundp.
    Otherwise it returns a *list* of roots.

2. And in the second case, 'xref-backend-references' conses that list
    of roots to the list of external roots. I.e. it constructs an improper
list
    which it then passes to 'mapcan'. This is a bug, isn't it?

3. 'xref-expanded-seach-root` mispells "search"

[-- Attachment #2: Type: text/html, Size: 1867 bytes --]

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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-23  2:16 ` Dmitry Gutov
  2020-12-26  2:21   ` Dmitry Gutov
@ 2020-12-27  7:10   ` Tobias Rittweiler
  2020-12-30  2:06     ` Dmitry Gutov
  1 sibling, 1 reply; 8+ messages in thread
From: Tobias Rittweiler @ 2020-12-27  7:10 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 45135

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

On Wed, 23 Dec 2020 at 03:16, Dmitry Gutov <dgutov@yandex.ru> wrote:

> Hi Tobias,
>
> On 09.12.2020 17:08, Tobias Rittweiler wrote:
>
> > please find patches attached to this e-mail that make it possible to
> > set 'xref-file-name-display' to 'relative-to-project-root'. If so set,
> > the file names in the *xref* buffer will be shortened by the
> 'project-root'
> > and 'project-external-roots' of 'project-current'. Note that xref.el
> already
> > requires 'project'.
> >
> > The patches are relative to commit 2581beb from Wed Dec 9 00:54:34 2020
> > +0000
>
> Could you clarify the reason for the first patch? Did you have any test
> failures (on Ubuntu 20.04.1?) with the current test code because of the
> "random" filesystem traversal order? Thanks!
>

The original code *did* already fix the file order in the test where it
actually mattered:
'xref-matches-in-directory-finds-some-for-bar'. Note that no other test
actually involve
locations from multiple files in a way that is dependent on the order.

The patch does not serve any actual utility except for code hygiene: it
reduces a bit
of trivial code duplication. Feel free to ignore it. (But in case you do
add tests for
'xref-file-name-display' being 'relative', please make sure you write the
tests in a way
that makes it independent from the filesystem traversal order.)

Tobias

[-- Attachment #2: Type: text/html, Size: 1876 bytes --]

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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-27  7:10   ` Tobias Rittweiler
@ 2020-12-30  2:06     ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2020-12-30  2:06 UTC (permalink / raw)
  To: Tobias Rittweiler; +Cc: 45135

On 27.12.2020 09:10, Tobias Rittweiler wrote:
>     Could you clarify the reason for the first patch? Did you have any test
>     failures (on Ubuntu 20.04.1?) with the current test code because of the
>     "random" filesystem traversal order? Thanks!
> 
> 
> The original code *did* already fix the file order in the test where it 
> actually mattered:
> 'xref-matches-in-directory-finds-some-for-bar'. Note that no other test 
> actually involve
> locations from multiple files in a way that is dependent on the order.
> 
> The patch does not serve any actual utility except for code hygiene: it 
> reduces a bit
> of trivial code duplication. Feel free to ignore it. (But in case you do 
> add tests for
> 'xref-file-name-display' being 'relative', please make sure you write 
> the tests in a way
> that makes it independent from the filesystem traversal order.)
> Tobias

Thanks for the explanation (and the patch), I just wanted to make sure 
whether I missed something. I'll push this one now.





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

* bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root
  2020-12-27  6:55     ` Tobias Rittweiler
@ 2020-12-30 12:05       ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2020-12-30 12:05 UTC (permalink / raw)
  To: Tobias Rittweiler; +Cc: 45135-done

Version: 28.1

Hi Tobias,

On 27.12.2020 08:55, Tobias Rittweiler wrote:

> Thank you. I tested the patch and it works fine.
> 
> Some comments on the patch itself:
> 
> 1. 'xref--project-root' returns a project root if 'project-root' is fboundp.
>      Otherwise it returns a *list* of roots.
> 
> 2. And in the second case, 'xref-backend-references' conses that list
>      of roots to the list of external roots. I.e. it constructs an 
> improper list
>      which it then passes to 'mapcan'. This is a bug, isn't it?
> 
> 3. 'xref-expanded-seach-root` mispells "search"

Thanks for the comments, I fixed them now.

Also I've simplified the change closer to your original code. If 
anything, that made satisfying the tests easier.

Pushed as 13b59c690a.

That code also doesn't consider the "external roots", I figured it would 
be better to keep the group names unique.

But we can revisit that later, if you or others do find those external 
long file names annoying (let me know). For now, closing.





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

end of thread, other threads:[~2020-12-30 12:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 15:08 bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root Tobias Rittweiler
2020-12-23  2:16 ` Dmitry Gutov
2020-12-26  2:21   ` Dmitry Gutov
2020-12-26  7:54     ` Eli Zaretskii
2020-12-27  6:55     ` Tobias Rittweiler
2020-12-30 12:05       ` Dmitry Gutov
2020-12-27  7:10   ` Tobias Rittweiler
2020-12-30  2:06     ` 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).