On 4/30/22 04:22, Max Nikulin wrote:
I posted a corrected version of my `org-encode-time' macro, but I did
not add you to Cc (I sent reply through news.gmane.io), and it has no
special case to check whether `encode-time' supports 6 elements list
argument:
Thanks, I looked at that and have a couple of questions.
As I understand it, org-encode-time is intended to be a compatibility
function like org-newline-and-indent and org-string-distance. Those are
in org-compat.el, so I assumed org-encode-time would be there too.
Also, if the intent is to emulate Emacs 29 encode-time, can't we do
something like the attached instead? The idea is to implement Emacs 29
encode-time both on pre-29 Emacs (that don't support lists of length 6)
and post-29 Emacs (which might drop support for the obsolescent form).
From 2f44ee7524e5b2e53f912cff1276f7817495c657 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 30 Apr 2022 19:27:15 -0700
Subject: [PATCH] org-encode-time compatibility function
* lisp/org/org-compat.el (org-encode-time): New function.
---
lisp/org/org-compat.el | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 3e394fbab1..0a0025fa0d 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -144,6 +144,16 @@ org-file-has-changed-p--hash-table
(defun org-time-convert-to-list (time)
(seconds-to-time (float-time time))))
+(if (ignore-errors (encode-time '(0 0 0 1 1 1971)))
+ (if (ignore-errors (encode-time 0 0 0 1 1 1971))
+ (defalias 'org-encode-time #'encode-time)
+ (defun org-encode-time (time &rest args)
+ (encode-time (if args (cons time args) time))))
+ (defun org-encode-time (time &rest args)
+ (if args
+ (apply #'encode-time time args)
+ (apply #'encode-time time))))
+
;; `newline-and-indent' did not take a numeric argument before 27.1.
(if (version< emacs-version "27")
(defsubst org-newline-and-indent (&optional _arg)
--
2.34.1