all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Eli Zaretskii <eliz@gnu.org>, 59575@debbugs.gnu.org
Subject: bug#59575: 29.0.50; add-log-current-defun-header-regexp matches Windows drive letter
Date: Sun, 27 Nov 2022 12:11:03 +0100	[thread overview]
Message-ID: <CAAeL0SSr3c1phkkzCFcwUxJs1LGK9ARX2PfcfuqKe9XJ18+4FA@mail.gmail.com> (raw)
In-Reply-To: <CAAeL0SQGSRs_8ueifPejEYxSESkHaqM1p61LvQWkDSNtmdeY7w@mail.gmail.com>

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

On Sun, Nov 27, 2022 at 9:29 AM Juanma Barranquero <lekktu@gmail.com> wrote:
>
> This works, for example:
>
> (defun xref--add-log-current-defun ()
>   (if-let (item (xref--item-at-point))
>       (xref-file-location-file (xref-match-item-location item))
>     (xref--imenu-extract-index-name)))
>
> (setq-local add-log-current-defun-function #'xref--add-log-current-defun)

In fact, to respect the value of `xref-file-name-display' (which seems a
good idea) a bit more complexity is required:

(defun xref--add-log-current-defun ()
  "Return the string used to group a set of locations.
This function is used as a value for `add-log-current-defun-function'."
  (xref--group-name-for-display
   (if-let (item (xref--item-at-point))
       (xref-location-group (xref-match-item-location item))
     (xref--imenu-extract-index-name))
   (xref--project-root (project-current))))

but that uncovers a different bug in xref--group-name-for-display:

   (cl-ecase xref-file-name-display
     (abs group)
     (nondirectory
      (if (string-match-p "\\`~?/" group)
          (file-name-nondirectory group)
        group))

that is, for the 'nondirectory case it tries to match against ~/filename or
/filename, but (again) ignores absolute Windows paths with a drive letter.

That should be changed to

   (cl-ecase xref-file-name-display
     (abs group)
     (nondirectory
-     (if (string-match-p "\\`~?/" group)
+     (if (string-match-p "\\`\\(~\\|[A-Za-z]:\\)?/" group)
          (file-name-nondirectory group)
        group))
     (project-relative

or something similar.

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

  reply	other threads:[~2022-11-27 11:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25 15:53 bug#59575: 29.0.50; add-log-current-defun-header-regexp matches Windows drive letter Juanma Barranquero
2022-11-26 13:03 ` Eli Zaretskii
2022-11-26 13:17   ` Juanma Barranquero
2022-11-27  1:54   ` Dmitry Gutov
2022-11-27  6:49     ` Eli Zaretskii
2022-11-27 12:33       ` Dmitry Gutov
2022-11-27 12:40         ` Juanma Barranquero
2022-11-27  8:29     ` Juanma Barranquero
2022-11-27 11:11       ` Juanma Barranquero [this message]
2022-11-27 11:22         ` Juanma Barranquero
2022-11-27 13:04           ` Dmitry Gutov
2022-11-27 13:22             ` Juanma Barranquero
2022-11-27 13:05       ` Dmitry Gutov
2022-11-27 13:18         ` Juanma Barranquero
2022-11-27 13:41           ` Dmitry Gutov
2022-11-27 14:02             ` Juanma Barranquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAeL0SSr3c1phkkzCFcwUxJs1LGK9ARX2PfcfuqKe9XJ18+4FA@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=59575@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.