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

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