emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org d3a9c424ba: org-encode-time: Refactor into top-leve


From: ELPA Syncer
Subject: [elpa] externals/org d3a9c424ba: org-encode-time: Refactor into top-level `defmacro'
Date: Tue, 16 Aug 2022 05:57:54 -0400 (EDT)

branch: externals/org
commit d3a9c424ba32382fff1da4f4ecb447dc99205261
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-encode-time: Refactor into top-level `defmacro'
    
    * lisp/org-macs.el (org-encode-time): Rewrite, avoiding top-level `if'
    statement that triggers
    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56746
    
    Also, fix the docstring warnings.
---
 lisp/org-macs.el | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 9af783e0df..63c7fee9dd 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1363,40 +1363,38 @@ nil, just return 0."
        (b (org-2ft b)))
     (and (> a 0) (> b 0) (\= a b))))
 
-(if (version< emacs-version "27.1")
-    (defmacro org-encode-time (&rest time)
+(defmacro org-encode-time (&rest time)
+  "Compatibility and convenience helper for `encode-time'.
+TIME may be a 9 components list (SECONDS ... YEAR IGNORED DST ZONE)
+as the recommended way since Emacs-27 or 6 or 9 separate arguments
+similar to the only possible variant for Emacs-26 and earlier.
+6 elements list as the only argument causes wrong type argument till
+Emacs-29.
+
+Warning: use -1 for DST to guess the actual value, nil means no
+daylight saving time and may be wrong at particular time.
+
+DST value is ignored prior to Emacs-27.  Since Emacs-27 DST value matters
+even when multiple arguments is passed to this macro and such
+behavior is different from `encode-time'.  See
+Info node `(elisp)Time Conversion' for details and caveats,
+preferably the latest version."
+  (if (version< emacs-version "27.1")
       (if (cdr time)
           `(encode-time ,@time)
-        `(apply #'encode-time ,@time)))
-  (if (ignore-errors (with-no-warnings (encode-time '(0 0 0 1 1 1971))))
-      (defmacro org-encode-time (&rest time)
+        `(apply #'encode-time ,@time))
+    (if (ignore-errors (with-no-warnings (encode-time '(0 0 0 1 1 1971))))
         (pcase (length time) ; Emacs-29 since d75e2c12eb
           (1 `(encode-time ,@time))
           ((or 6 9) `(encode-time (list ,@time)))
           (_ (error "`org-encode-time' may be called with 1, 6, or 9 arguments 
but %d given"
-                    (length time)))))
-    (defmacro org-encode-time (&rest time)
+                    (length time))))
       (pcase (length time)
         (1 `(encode-time ,@time))
         (6 `(encode-time (list ,@time nil -1 nil)))
         (9 `(encode-time (list ,@time)))
         (_ (error "`org-encode-time' may be called with 1, 6, or 9 arguments 
but %d given"
                   (length time)))))))
-(put 'org-encode-time 'function-documentation
-     "Compatibility and convenience helper for `encode-time'.
-May be called with 9 components list (SECONDS ... YEAR IGNORED DST ZONE)
-as the recommended way since Emacs-27 or with 6 or 9 separate arguments
-similar to the only possible variant for Emacs-26 and earlier.
-6 elements list as the only argument causes wrong type argument till Emacs-29.
-
-Warning: use -1 for DST to guess the actual value, nil means no
-daylight saving time and may be wrong at particular time.
-
-DST value is ignored prior to Emacs-27.  Since Emacs-27 DST value matters
-even when multiple arguments is passed to this macro and such
-behavior is different from `encode-time'. See
-Info node `(elisp)Time Conversion' for details and caveats,
-preferably the latest version.")
 
 (defun org-parse-time-string (s &optional nodefault)
   "Parse Org time string S.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]