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

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

[elpa] externals/org a04e16bd11 082/101: lisp/org-macs.el: Restructure f


From: ELPA Syncer
Subject: [elpa] externals/org a04e16bd11 082/101: lisp/org-macs.el: Restructure file outline, fixing compiler warning
Date: Sat, 1 Jul 2023 09:59:16 -0400 (EDT)

branch: externals/org
commit a04e16bd113fb81bd972e25872040463f9eb39ff
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    lisp/org-macs.el: Restructure file outline, fixing compiler warning
    
    Add new section "Misc", moving all the functions that do not belong to
    other sections below.  This also fixes defun order for
    `org-compile-file' that needs `org-trim' to be defined.
---
 lisp/org-macs.el | 181 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 91 insertions(+), 90 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index dbc4acc02a..2eed0028e5 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -371,96 +371,6 @@ in target-prerequisite files relation."
   (let ((mtime (file-attribute-modification-time (file-attributes file))))
     (and mtime (or (not time) (time-less-p time mtime)))))
 
-(defun org-compile-file (source process ext &optional err-msg log-buf spec)
-  "Compile a SOURCE file using PROCESS.
-
-See `org-compile-file-commands' for information on PROCESS, EXT, and SPEC.
-If PROCESS fails, an error will be raised.  The error message can
-then be refined by providing string ERR-MSG, which is appended to
-the standard message.
-
-PROCESS must create a file with the same base name and directory
-as SOURCE, but ending with EXT.  The function then returns its
-filename.  Otherwise, it raises an error.
-
-When PROCESS is a list of commands, optional argument LOG-BUF can
-be set to a buffer or a buffer name.  `shell-command' then uses
-it for output."
-  (let* ((commands (org-compile-file-commands source process ext spec err-msg))
-         (output (expand-file-name (concat (file-name-base source) "." ext)
-                                   (file-name-directory source)))
-         (log-buf (and log-buf (get-buffer-create log-buf)))
-         (time (file-attribute-modification-time (file-attributes output))))
-    (save-window-excursion
-      (dolist (command commands)
-        (cond
-         ((functionp command)
-          (funcall command (shell-quote-argument (file-relative-name source))))
-         ((stringp command) (shell-command command log-buf)))))
-    ;; Check for process failure.  Output file is expected to be
-    ;; located in the same directory as SOURCE.
-    (unless (org-file-newer-than-p output time)
-      (ignore (defvar org-batch-test))
-      ;; Display logs when running tests.
-      (when (bound-and-true-p org-batch-test)
-        (message "org-compile-file log ::\n-----\n%s\n-----\n"
-                 (with-current-buffer log-buf (buffer-string))))
-      (error
-       (format
-        "File %S wasn't produced%s"
-        output
-        (if (org-string-nw-p err-msg)
-            (concat "  " (org-trim err-msg))
-          err-msg))))
-    output))
-
-(defun org-compile-file-commands (source process ext &optional spec err-msg)
-  "Return list of commands used to compile SOURCE file.
-
-The commands are formed from PROCESS, which is either a function or
-a list of shell commands, as strings.  EXT is a file extension, without
-the leading dot, as a string.  After PROCESS has been executed,
-a file with the same basename and directory as SOURCE but with the
-file extension EXT is expected to be produced.
-Failure to produce this file will be interpreted as PROCESS failing.
-
-If PROCESS is a function, it is called with a single argument:
-the SOURCE file.
-
-If PROCESS is a list of commands, each of them is called using
-`shell-command'.  By default, in each command, %b, %f, %F, %o and
-%O are replaced with, respectively, SOURCE base name, name, full
-name, directory and absolute output file name.  It is possible,
-however, to use more place-holders by specifying them in optional
-argument SPEC, as an alist following the pattern
-
-  (CHARACTER . REPLACEMENT-STRING).
-
-Throw an error if PROCESS does not satisfy the described patterns.
-The error string will be appended with ERR-MSG, when it is a string."
-  (let* ((base-name (file-name-base source))
-        (full-name (file-truename source))
-         (relative-name (file-relative-name source))
-        (out-dir (if (file-name-directory source)
-                      ;; Expand "~".  Shell expansion will be disabled
-                      ;; in the shell command call.
-                      (file-name-directory full-name)
-                    "./"))
-        (output (expand-file-name (concat (file-name-base source) "." ext) 
out-dir))
-        (err-msg (if (stringp err-msg) (concat ".  " err-msg) "")))
-    (pcase process
-      ((pred functionp) (list process))
-      ((pred consp)
-       (let ((spec (append spec
-                          `((?b . ,(shell-quote-argument base-name))
-                            (?f . ,(shell-quote-argument relative-name))
-                            (?F . ,(shell-quote-argument full-name))
-                            (?o . ,(shell-quote-argument out-dir))
-                            (?O . ,(shell-quote-argument output))))))
-         (mapcar (lambda (command) (format-spec command spec)) process)))
-      (_ (error "No valid command to process %S%s" source err-msg)))))
-
-
 
 ;;; Indentation
 
@@ -1648,6 +1558,9 @@ Return 0. if S is not recognized as a valid value."
        ((string-match org-ts-regexp0 s) (org-2ft s))
        (t 0.)))))
 
+
+;;; Misc
+
 (defun org-scroll (key &optional additional-keys)
   "Receive KEY and scroll the current window accordingly.
 When ADDITIONAL-KEYS is not nil, also include SPC and DEL in the
@@ -1701,6 +1614,94 @@ When COUNTER is non-nil, return safe hash for (COUNTER . 
OBJ)."
          (puthash hash obj org-sxhash-objects)
          (puthash obj hash org-sxhash-hashes)))))
 
+(defun org-compile-file (source process ext &optional err-msg log-buf spec)
+  "Compile a SOURCE file using PROCESS.
+
+See `org-compile-file-commands' for information on PROCESS, EXT, and SPEC.
+If PROCESS fails, an error will be raised.  The error message can
+then be refined by providing string ERR-MSG, which is appended to
+the standard message.
+
+PROCESS must create a file with the same base name and directory
+as SOURCE, but ending with EXT.  The function then returns its
+filename.  Otherwise, it raises an error.
+
+When PROCESS is a list of commands, optional argument LOG-BUF can
+be set to a buffer or a buffer name.  `shell-command' then uses
+it for output."
+  (let* ((commands (org-compile-file-commands source process ext spec err-msg))
+         (output (expand-file-name (concat (file-name-base source) "." ext)
+                                   (file-name-directory source)))
+         (log-buf (and log-buf (get-buffer-create log-buf)))
+         (time (file-attribute-modification-time (file-attributes output))))
+    (save-window-excursion
+      (dolist (command commands)
+        (cond
+         ((functionp command)
+          (funcall command (shell-quote-argument (file-relative-name source))))
+         ((stringp command) (shell-command command log-buf)))))
+    ;; Check for process failure.  Output file is expected to be
+    ;; located in the same directory as SOURCE.
+    (unless (org-file-newer-than-p output time)
+      (ignore (defvar org-batch-test))
+      ;; Display logs when running tests.
+      (when (bound-and-true-p org-batch-test)
+        (message "org-compile-file log ::\n-----\n%s\n-----\n"
+                 (with-current-buffer log-buf (buffer-string))))
+      (error
+       (format
+        "File %S wasn't produced%s"
+        output
+        (if (org-string-nw-p err-msg)
+            (concat "  " (org-trim err-msg))
+          err-msg))))
+    output))
+
+(defun org-compile-file-commands (source process ext &optional spec err-msg)
+  "Return list of commands used to compile SOURCE file.
+
+The commands are formed from PROCESS, which is either a function or
+a list of shell commands, as strings.  EXT is a file extension, without
+the leading dot, as a string.  After PROCESS has been executed,
+a file with the same basename and directory as SOURCE but with the
+file extension EXT is expected to be produced.
+Failure to produce this file will be interpreted as PROCESS failing.
+
+If PROCESS is a function, it is called with a single argument:
+the SOURCE file.
+
+If PROCESS is a list of commands, each of them is called using
+`shell-command'.  By default, in each command, %b, %f, %F, %o and
+%O are replaced with, respectively, SOURCE base name, name, full
+name, directory and absolute output file name.  It is possible,
+however, to use more place-holders by specifying them in optional
+argument SPEC, as an alist following the pattern
+
+  (CHARACTER . REPLACEMENT-STRING).
+
+Throw an error if PROCESS does not satisfy the described patterns.
+The error string will be appended with ERR-MSG, when it is a string."
+  (let* ((base-name (file-name-base source))
+        (full-name (file-truename source))
+         (relative-name (file-relative-name source))
+        (out-dir (if (file-name-directory source)
+                      ;; Expand "~".  Shell expansion will be disabled
+                      ;; in the shell command call.
+                      (file-name-directory full-name)
+                    "./"))
+        (output (expand-file-name (concat (file-name-base source) "." ext) 
out-dir))
+        (err-msg (if (stringp err-msg) (concat ".  " err-msg) "")))
+    (pcase process
+      ((pred functionp) (list process))
+      ((pred consp)
+       (let ((spec (append spec
+                          `((?b . ,(shell-quote-argument base-name))
+                            (?f . ,(shell-quote-argument relative-name))
+                            (?F . ,(shell-quote-argument full-name))
+                            (?o . ,(shell-quote-argument out-dir))
+                            (?O . ,(shell-quote-argument output))))))
+         (mapcar (lambda (command) (format-spec command spec)) process)))
+      (_ (error "No valid command to process %S%s" source err-msg)))))
 
 (provide 'org-macs)
 



reply via email to

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