diff options
author | Marco Wahl <marcowahlsoft@gmail.com> | 2021-08-10 22:02:40 +0200 |
---|---|---|
committer | Marco Wahl <marcowahlsoft@gmail.com> | 2021-08-10 22:20:48 +0200 |
commit | 81eb8c5f9e4e8fe7e97c7358691edad7e694372b (patch) | |
tree | 210270b4c222997e99e40b2b05a4c7c922a6e928 | |
parent | 926dbafe43bbb80ed763d850c86a488e54c7364d (diff) | |
download | org-mode-81eb8c5f9e4e8fe7e97c7358691edad7e694372b.tar.gz |
attach: Fix for Emacs<28
* lisp/org-compat.el: Introduce org-directory-empty-p which is directory-empty-p from Emacs 28.
* lisp/org-attach.el (org-attach-sync): Use org-directory-empty-p instead of directory-empty-p.
* etc/ORG-NEWS: Note about org-directory-empty-p.
Thanks Kyle identifying the issue. Thanks Arthur for suggesting a
fix.
-rw-r--r-- | etc/ORG-NEWS | 2 | ||||
-rw-r--r-- | lisp/org-attach.el | 2 | ||||
-rw-r--r-- | lisp/org-compat.el | 10 |
3 files changed, 13 insertions, 1 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 78a57ba..83a67da 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -421,6 +421,8 @@ Tag completion now uses =completing-read-multiple= with a simple completion table, which should allow better interoperability with custom completion functions. +*** Providing =directory-empty-p= from Emacs 28 as =org-directory-empty-p= + * Version 9.4 ** Incompatible changes *** Possibly broken internal file links: please check and fix diff --git a/lisp/org-attach.el b/lisp/org-attach.el index e8e8ade..f184531 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -622,7 +622,7 @@ empty attachment directories." (let ((files (org-attach-file-list attach-dir))) (org-attach-tag (not files))) (when org-attach-sync-delete-empty-dir - (when (and (directory-empty-p attach-dir) + (when (and (org-directory-empty-p attach-dir) (if (eq 'query org-attach-sync-delete-empty-dir) (yes-or-no-p "Attachment directory is empty. Delete?") t)) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index ff992f3..866e2c3 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -72,6 +72,16 @@ (defvar org-table1-hline-regexp) +;;; Emacs < 28.1 compatibility + +(if (version< emacs-version "28") + (defun org-directory-empty-p (dir) + "Return t if DIR names an existing directory containing no other files." + (and (file-directory-p dir) + (null (directory-files dir nil directory-files-no-dot-files-regexp t 1)))) + (defalias 'org-directory-empty-p #'directory-empty-p)) + + ;;; Emacs < 27.1 compatibility (unless (fboundp 'proper-list-p) |