forked from mirrors/org-mode
org-e-texinfo: Update compile function
* contrib/lisp/org-e-texinfo.el (org-e-texinfo-compile): Mirror recent changes about base filename and default-directory made to `org-e-latex-compile'.
This commit is contained in:
parent
ec40ba021a
commit
c712d65397
|
@ -1740,58 +1740,58 @@ Return INFO file's name."
|
||||||
(org-e-texinfo-export-to-texinfo
|
(org-e-texinfo-export-to-texinfo
|
||||||
subtreep visible-only body-only ext-plist pub-dir)))
|
subtreep visible-only body-only ext-plist pub-dir)))
|
||||||
|
|
||||||
(defun org-e-texinfo-compile (texifile)
|
(defun org-e-texinfo-compile (file)
|
||||||
"Compile a texinfo file.
|
"Compile a texinfo file.
|
||||||
|
|
||||||
TEXIFILE is the name of the file being compiled. Processing is
|
FILE is the name of the file being compiled. Processing is
|
||||||
done through the command specified in `org-e-texinfo-info-process'.
|
done through the command specified in `org-e-texinfo-info-process'.
|
||||||
|
|
||||||
Return INFO file name or an error if it couldn't be produced."
|
Return INFO file name or an error if it couldn't be produced."
|
||||||
(let* ((wconfig (current-window-configuration))
|
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
|
||||||
(texifile (file-truename texifile))
|
(full-name (file-truename file))
|
||||||
(base (file-name-sans-extension texifile))
|
(out-dir (file-name-directory file))
|
||||||
|
;; Make sure `default-directory' is set to FILE directory,
|
||||||
|
;; not to whatever value the current buffer may have.
|
||||||
|
(default-directory (file-name-directory full-name))
|
||||||
errors)
|
errors)
|
||||||
(message (format "Processing Texinfo file %s ..." texifile))
|
(message (format "Processing Texinfo file %s ..." file))
|
||||||
(unwind-protect
|
(save-window-excursion
|
||||||
(progn
|
(cond
|
||||||
(cond
|
;; A function is provided: Apply it.
|
||||||
;; A function is provided: Apply it.
|
((functionp org-e-texinfo-info-process)
|
||||||
((functionp org-e-texinfo-info-process)
|
(funcall org-e-texinfo-info-process (shell-quote-argument file)))
|
||||||
(funcall org-e-texinfo-info-process (shell-quote-argument texifile)))
|
;; A list is provided: Replace %b, %f and %o with appropriate
|
||||||
;; A list is provided: Replace %b, %f and %o with appropriate
|
;; values in each command before applying it. Output is
|
||||||
;; values in each command before applying it. Output is
|
;; redirected to "*Org INFO Texinfo Output*" buffer.
|
||||||
;; redirected to "*Org INFO Texinfo Output*" buffer.
|
((consp org-e-texinfo-info-process)
|
||||||
((consp org-e-texinfo-info-process)
|
(let ((outbuf (get-buffer-create "*Org INFO Texinfo Output*")))
|
||||||
(let* ((out-dir (or (file-name-directory texifile) "./"))
|
(mapc
|
||||||
(outbuf (get-buffer-create "*Org Info Texinfo Output*")))
|
(lambda (command)
|
||||||
(mapc
|
(shell-command
|
||||||
(lambda (command)
|
(replace-regexp-in-string
|
||||||
(shell-command
|
"%b" (shell-quote-argument base-name)
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"%b" (shell-quote-argument base)
|
"%f" (shell-quote-argument full-name)
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"%f" (shell-quote-argument texifile)
|
"%o" (shell-quote-argument out-dir) command t t) t t) t t)
|
||||||
(replace-regexp-in-string
|
outbuf))
|
||||||
"%o" (shell-quote-argument out-dir) command t t) t t) t t)
|
org-e-texinfo-info-process)
|
||||||
outbuf))
|
;; Collect standard errors from output buffer.
|
||||||
org-e-texinfo-info-process)
|
(setq errors (org-e-texinfo-collect-errors outbuf))))
|
||||||
;; Collect standard errors from output buffer.
|
(t (error "No valid command to process to Info")))
|
||||||
(setq errors (org-e-texinfo-collect-errors outbuf))))
|
(let ((infofile (concat out-dir base-name ".info")))
|
||||||
(t (error "No valid command to process to Info")))
|
;; Check for process failure. Provide collected errors if
|
||||||
(let ((infofile (concat base ".info")))
|
;; possible.
|
||||||
;; Check for process failure. Provide collected errors if
|
(if (not (file-exists-p infofile))
|
||||||
;; possible.
|
(error (concat (format "INFO file %s wasn't produced" infofile)
|
||||||
(if (not (file-exists-p infofile))
|
(when errors (concat ": " errors))))
|
||||||
(error (concat (format "INFO file %s wasn't produced" infofile)
|
;; Else remove log files, when specified, and signal end of
|
||||||
(when errors (concat ": " errors))))
|
;; process to user, along with any error encountered.
|
||||||
;; Else remove log files, when specified, and signal end of
|
(message (concat "Process completed"
|
||||||
;; process to user, along with any error encountered.
|
(if (not errors) "."
|
||||||
(message (concat "Process completed"
|
(concat " with errors: " errors)))))
|
||||||
(if (not errors) "."
|
;; Return output file name.
|
||||||
(concat " with errors: " errors)))))
|
infofile))))
|
||||||
;; Return output file name.
|
|
||||||
infofile))
|
|
||||||
(set-window-configuration wconfig))))
|
|
||||||
|
|
||||||
(defun org-e-texinfo-collect-errors (buffer)
|
(defun org-e-texinfo-collect-errors (buffer)
|
||||||
"Collect some kind of errors from \"makeinfo\" command output.
|
"Collect some kind of errors from \"makeinfo\" command output.
|
||||||
|
|
Loading…
Reference in a new issue