[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)
- [elpa] externals/org dfd36d1969 049/101: org-up-heading-safe: Use element API, (continued)
- [elpa] externals/org dfd36d1969 049/101: org-up-heading-safe: Use element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org fefaadc2d5 050/101: org-element: Optimize working with match data and Emacs regexps, ELPA Syncer, 2023/07/01
- [elpa] externals/org 6266197bbd 051/101: org-at-item-p: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 6938857369 052/101: org-goto-first-child: Switch to org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 7c549f4841 060/101: org-babel-tangle-collect-blocks: Switch to org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org b2482d9cc4 070/101: * testing/lisp/test-org-element.el: Add new tests, ELPA Syncer, 2023/07/01
- [elpa] externals/org b0a2deaec6 073/101: org-element--current-element: Faster property drawer check, ELPA Syncer, 2023/07/01
- [elpa] externals/org 110601ce74 074/101: org-element--current-element: Add FIXME, ELPA Syncer, 2023/07/01
- [elpa] externals/org 48e4a76b99 079/101: org-element: Avoid computing static regexps dynamically, ELPA Syncer, 2023/07/01
- [elpa] externals/org f895be1ad9 086/101: org-element--properties-mapc: Small refactoring, ELPA Syncer, 2023/07/01
- [elpa] externals/org a04e16bd11 082/101: lisp/org-macs.el: Restructure file outline, fixing compiler warning,
ELPA Syncer <=
- [elpa] externals/org 5a3224a325 085/101: etc/ORG-NEWS: Document Org API changes, ELPA Syncer, 2023/07/01
- [elpa] externals/org 9249275738 089/101: fixup! etc/ORG-NEWS: Document Org API changes, ELPA Syncer, 2023/07/01
- [elpa] externals/org f97aeaa243 099/101: org-fold-core--isearch-setup: Use `add-function', ELPA Syncer, 2023/07/01
- [elpa] externals/org 55ba9f05a7 018/101: org-element-map: Refactor using `org-element-ast-map', ELPA Syncer, 2023/07/01
- [elpa] externals/org 29cb0b370b 022/101: org-element-headline-parser: Defer property drawer values, ELPA Syncer, 2023/07/01
- [elpa] externals/org 44baf8f2b8 030/101: org-element-parse-buffer: New optional argument to not force undefer, ELPA Syncer, 2023/07/01
- [elpa] externals/org 13ae9b95f8 045/101: org-narrow-to-subtree: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 3024e933c0 053/101: org-get-buffer-tags: Switch to org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org def4bfa9c1 055/101: org-scan-tag: Switch to pure use of `org-element-cache-map', ELPA Syncer, 2023/07/01
- [elpa] externals/org 2efc7fcfdc 058/101: org-agenda-get-scheduled: Switch to org-element API, ELPA Syncer, 2023/07/01