Authentication-Results: mail-b.sr.ht; dkim=none Received: from outbound.soverin.net (outbound.soverin.net [185.233.34.18]) by mail-b.sr.ht (Postfix) with ESMTPS id 33F7411EF8C for <~protesilaos/denote@lists.sr.ht>; Thu, 27 Oct 2022 15:04:01 +0000 (UTC) Received: from smtp.soverin.net (c04smtp-lb01.int.sover.in [10.10.4.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 4Mypq35xwmz6G; Thu, 27 Oct 2022 15:03:59 +0000 (UTC) Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4Mypq33qZBz9q; Thu, 27 Oct 2022 15:03:59 +0000 (UTC) X-Soverin-Authenticated: true From: Noboru Ota To: ~protesilaos/denote@lists.sr.ht Cc: Protesilaos Stavrou Subject: Re: [PATCH] Display context of identifier in backlinks buffer with xref In-Reply-To: <87o7tzl1zv.fsf@protesilaos.com> Date: Thu, 27 Oct 2022 17:03:58 +0200 Message-ID: <86h6zpmhpd.fsf@nobiot.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain > This is the current commit log, since our last exchange: > [... omitted ...] > Please let me know if you are okay with them. > [... omitted ...] > I believe I have not missed anything from the latest set of patches you > sent. If I did, it was not intentional, and please tell me about it. All well on my end. I tested commit ee69dae; it works for (both with/without context). Thank you. Your reasoning makes sense to me; I agree. > I believe the way I implemented those wrappers accommodates both the old > backlinks' buffer and the new one with the added context. Please let me > know if this is true on your end. One thing I noticed is you use 'funcall'. You could just call the function (?) One additional thing I have noticed. I am sending a patch; no functional change. Just to align the variable name 'xrefs-alist' (xrefs, plural) to the built-in library (Xref uses singular 'xref-alist') while it is still "hot". Cheers, nobiot --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Update-xrefs-alist-xref-alist.patch Content-Description: Patch From 80e3663a51c9dbb76d360168d11ab9655ea64bd1 Mon Sep 17 00:00:00 2001 From: Noboru Ota Date: Thu, 27 Oct 2022 16:48:10 +0200 Subject: [PATCH] Update xrefs-alist -> xref-alist No functional change. 'xref-alist' is the convention that Xref follows. --- denote.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/denote.el b/denote.el index a2a0a14..1b25aa5 100644 --- a/denote.el +++ b/denote.el @@ -1154,14 +1154,14 @@ The xrefs are returned as an alist." (lambda (x) (xref-location-group (xref-item-location x))))) -(defun denote--retrieve-files-in-xrefs (xrefs-alist) - "Return sorted, deduplicated file names from XREFS-ALIST." +(defun denote--retrieve-files-in-xrefs (xref-alist) + "Return sorted, deduplicated file names from XREF-ALIST." (sort - (delete-dups (mapcar #'car xrefs-alist)) + (delete-dups (mapcar #'car xref-alist)) #'string-lessp)) (defun denote--retrieve-process-grep (identifier) - "Process lines matching IDENTIFIER and return list of xrefs-alist." + "Process lines matching IDENTIFIER and return list of xref-alist." (assoc-delete-all (buffer-file-name) (denote--retrieve-xrefs identifier))) @@ -2636,8 +2636,8 @@ nil)." (make-obsolete-variable 'denote-backlink-mode 'denote-backlinks-mode "0.6.0") -(defun denote-link--prepare-backlinks (id xrefs-alist &optional title) - "Create backlinks' buffer for ID using XREFS-ALIST. +(defun denote-link--prepare-backlinks (id xref-alist &optional title) + "Create backlinks' buffer for ID using XREF-ALIST. Use optional TITLE for a prettier heading." (let ((inhibit-read-only t) (buf (format "*denote-backlinks to %s*" id)) @@ -2653,18 +2653,18 @@ Use optional TITLE for a prettier heading." (insert (format "%s\n%s\n\n" heading (make-string l ?-)))) ;;; We could have a user option to use the current backlink buffer (if denote-backlinks-show-context - (denote-xref--insert-xrefs xrefs-alist) + (denote-xref--insert-xrefs xref-alist) (mapc (lambda (x) (insert (denote-get-file-name-relative-to-denote-directory (car x))) (make-button (line-beginning-position) (line-end-position) :type 'denote-link-backlink-button) (newline)) - xrefs-alist)) + xref-alist)) (goto-char (point-min)) (setq-local revert-buffer-function (lambda (_ignore-auto _noconfirm) (when-let ((buffer-file-name file) - (xrefs-alist (denote--retrieve-process-grep id))) - (denote-link--prepare-backlinks id xrefs-alist title))))) + (xref-alist (denote--retrieve-process-grep id))) + (denote-link--prepare-backlinks id xref-alist title))))) (denote-link--display-buffer buf))) (defun denote-xref--insert-xrefs (xref-alist) @@ -2739,9 +2739,9 @@ default, it will show up below the current window." (let* ((id (denote-retrieve-filename-identifier file)) (file-type (denote-filetype-heuristics file)) (title (denote-retrieve-title-value file file-type))) - (if-let ((xrefs-alist (denote--retrieve-process-grep id))) + (if-let ((xref-alist (denote--retrieve-process-grep id))) (progn (xref--push-markers) - (denote-link--prepare-backlinks id xrefs-alist title)) + (denote-link--prepare-backlinks id xref-alist title)) (user-error "No links to the current note")))))) (defalias 'denote-link-show-backlinks-buffer (symbol-function 'denote-link-backlinks)) -- 2.34.1 --=-=-=--