branch: externals/doc-toc commit 102e14199c973f0b832880a33247794902003304 Author: Daniel Nicolai <dalanico...@gmail.com> Commit: Daniel Nicolai <dalanico...@gmail.com>
pdf.tocgen replace original pdf, and show message on fail --- toc-mode.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/toc-mode.el b/toc-mode.el index bf8cfa3c4c..c7d9f979d6 100644 --- a/toc-mode.el +++ b/toc-mode.el @@ -312,8 +312,15 @@ named output.pdf and opened in a new buffer. Don't forget to rename this new file." (interactive) (write-file default-directory) - (shell-command (format "pdftocio -o output.pdf '%s' < toc" pdf-filename)) - (find-file "output.pdf")) + (let* ((message (shell-command-to-string (format "pdftocio '%s' < toc" pdf-filename)))) + (kill-buffer-if-not-modified (find-file pdf-filename)) + (when (file-exists-p (concat (file-name-base pdf-filename) "_out.pdf")) + (delete-file pdf-filename) + (rename-file (concat (file-name-base pdf-filename) "_out.pdf") pdf-filename)) + (find-file pdf-filename) + (unless (string= message "") + (message (concat "The pdftocio command returned the following message: \n\n" message))))) + (defvar toc-pdftocgen-mode-map (let ((map (make-sparse-keymap)))