[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote bc2ddc4dcb 2/5: Tweak error checking of denote-s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote bc2ddc4dcb 2/5: Tweak error checking of denote-sort-dired |
Date: |
Mon, 11 Dec 2023 04:02:09 -0500 (EST) |
branch: externals/denote
commit bc2ddc4dcb824b5ac67c3dd3b30cd58354ff8b6a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Tweak error checking of denote-sort-dired
This is the same principle as commit 96e5161 by Vedang Manerikar.
Thanks to Vedang for the patch for that commit:
<https://lists.sr.ht/~protesilaos/denote/patches/47625>.
---
denote-sort.el | 43 +++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/denote-sort.el b/denote-sort.el
index c2face4642..d9fd56c24f 100644
--- a/denote-sort.el
+++ b/denote-sort.el
@@ -173,28 +173,27 @@ a non-nil value, respectively."
(denote-files-matching-regexp-prompt)
(denote-sort-component-prompt)
(y-or-n-p "Reverse sort? ")))
- (let* ((default-directory (denote-directory))
- ;; NOTE 2023-12-04: Passing the FILES-MATCHING-REGEXP as
- ;; buffer-name produces an error if the regexp contains a
- ;; wildcard for a directory. I can reproduce this in emacs -Q
- ;; and am not sure if it is a bug. Anyway, I will report it
- ;; upstream, but even if it is fixed we cannot use it for now
- ;; (whatever fix will be available for Emacs 30+).
- (denote-sort-dired-buffer-name (format "Denote sort `%s' by `%s'"
files-matching-regexp sort-by-component))
- (buffer-name (format "Denote sort by `%s' at %s" sort-by-component
(format-time-string "%T")))
- (files (denote-sort-get-directory-files files-matching-regexp
sort-by-component reverse)))
- (if (car files)
- (let ((dired-buffer (dired (cons buffer-name (mapcar
#'file-relative-name files)))))
- (setq denote-sort--dired-buffer dired-buffer)
- (with-current-buffer dired-buffer
- (setq-local revert-buffer-function
- (lambda (&rest _)
- (kill-buffer dired-buffer)
- (denote-sort-dired files-matching-regexp
sort-by-component reverse))))
- ;; Because of the above NOTE, I am printing a message. Not what I
- ;; want, but it is better than nothing...
- (message denote-sort-dired-buffer-name))
- (message "No matching files for %s" denote-sort-dired-buffer-name))))
+ (if-let ((default-directory (denote-directory))
+ (files (denote-sort-get-directory-files files-matching-regexp
sort-by-component reverse))
+ ;; NOTE 2023-12-04: Passing the FILES-MATCHING-REGEXP as
+ ;; buffer-name produces an error if the regexp contains a
+ ;; wildcard for a directory. I can reproduce this in emacs
+ ;; -Q and am not sure if it is a bug. Anyway, I will report
+ ;; it upstream, but even if it is fixed we cannot use it
+ ;; for now (whatever fix will be available for Emacs 30+).
+ (denote-sort-dired-buffer-name (format "Denote sort `%s' by `%s'"
files-matching-regexp sort-by-component))
+ (buffer-name (format "Denote sort by `%s' at %s" sort-by-component
(format-time-string "%T"))))
+ (let ((dired-buffer (dired (cons buffer-name (mapcar
#'file-relative-name files)))))
+ (setq denote-sort--dired-buffer dired-buffer)
+ (with-current-buffer dired-buffer
+ (setq-local revert-buffer-function
+ (lambda (&rest _)
+ (kill-buffer dired-buffer)
+ (denote-sort-dired files-matching-regexp
sort-by-component reverse))))
+ ;; Because of the above NOTE, I am printing a message. Not
+ ;; what I want, but it is better than nothing...
+ (message denote-sort-dired-buffer-name))
+ (message "No matching files for: %s" files-matching-regexp)))
(provide 'denote-sort)
;;; denote-sort.el ends here