瀏覽代碼

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.
Marco Wahl 3 年之前
父節點
當前提交
81eb8c5f9e
共有 3 個文件被更改,包括 13 次插入1 次删除
  1. 2 0
      etc/ORG-NEWS
  2. 1 1
      lisp/org-attach.el
  3. 10 0
      lisp/org-compat.el

+ 2 - 0
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

+ 1 - 1
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))

+ 10 - 0
lisp/org-compat.el

@@ -71,6 +71,16 @@
 (defvar org-table-tab-recognizes-table.el)
 (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