Fix broken buttons in backlinks' buffer

Sorting them after they are inserted breaks them.  Thanks to Sven
Seebeck for reporting the regression in issue 16 over at the GitHub
mirror: <https://github.com/protesilaos/denote/issues/16>.
This commit is contained in:
Protesilaos Stavrou 2022-06-18 07:14:03 +03:00
parent f21a99775d
commit 429763c246
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -215,17 +215,11 @@ format is always [[denote:IDENTIFIER]]."
buf
`(,@denote-link-backlinks-display-buffer-action)))
;; NOTE 2022-06-17: This is a `defvar' on purpose, like
;; `denote-link-add-links'. Read its comment.
(defvar denote-link-backlinks-sort nil
"Add REVERSE to `sort-lines' of `denote-link-backlinks' when t.")
(defun denote-link--prepare-backlinks (id files &optional title)
"Create backlinks' buffer for ID including FILES.
Use optional TITLE for a prettier heading."
(let ((inhibit-read-only t)
(buf (format "*denote-backlinks to %s*" id))
start)
(buf (format "*denote-backlinks to %s*" id)))
(with-current-buffer (get-buffer-create buf)
(erase-buffer)
(special-mode)
@ -234,13 +228,11 @@ Use optional TITLE for a prettier heading."
(heading (format "Backlinks to %S (%s)" title id))
(l (length heading)))
(insert (format "%s\n%s\n\n" heading (make-string l ?-))))
(setq start (point))
(mapc (lambda (f)
(insert (file-name-nondirectory f))
(make-button (point-at-bol) (point-at-eol) :type 'denote-link-find-file)
(newline))
files)
(sort-lines denote-link-backlinks-sort start (point))
(goto-char (point-min))
;; NOTE 2022-06-15: Technically this is not Dired. Maybe we
;; should abstract the fontification into a general purpose