Skip to content

Commit 0dfb26d

Browse files
committed
Fix pandoc retrieving which actually checks if file already exists
1 parent cf44c4f commit 0dfb26d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

speed-type.el

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ Adding the idle timer again, and pushing the newest time to stack."
432432
433433
The list of times is used to calculate the overall active typing time."
434434
(interactive)
435-
(message "Speed-type session is paused. Resume will be triggered on buffer-change.")
435+
(message "Speed-type: session is paused. Resume will be triggered on buffer-change.")
436436
(when speed-type--idle-pause-timer
437437
(setq speed-type--idle-pause-timer nil
438438
speed-type--time-register (append speed-type--time-register (list (float-time))))))
@@ -848,17 +848,19 @@ string \"no-hash\" is used as a prefix instead of a real hash."
848848
849849
If the file is already retrieved, will return file-location."
850850
(unless (executable-find "pandoc") (error "Executable: pandoc not installed"))
851-
(let* ((default-directory speed-type-directory)
852-
(fn (expand-file-name (format "%s.txt" (speed-type--url-to-filename url)) speed-type-directory))
853-
(cmd "pandoc")
854-
(url-opts (format "-s -r html \"%s\"" url))
855-
(request-header (format "--request-header %s" speed-type-pandoc-request-header))
856-
(text-opts "-t plain")
857-
(output (format "-o %s" fn))
858-
(full-pandoc-cmd (mapconcat #'identity (list cmd url-opts request-header text-opts output) " ")))
859-
(when (or (> (shell-command full-pandoc-cmd) 0) (not (file-readable-p fn)))
860-
(message "Check executed pandoc command: %s" full-pandoc-cmd)
861-
(error "Error while retrieving url with pandoc see *Messages* for details"))
851+
(let ((fn (expand-file-name (format "%s.txt" (speed-type--url-to-filename url)) speed-type-directory)))
852+
(unless (file-readable-p fn)
853+
(let* ((default-directory speed-type-directory)
854+
(cmd "pandoc")
855+
(url-opts (format "-s -r html \"%s\"" url))
856+
(request-header (format "--request-header %s" speed-type-pandoc-request-header))
857+
(text-opts "-t plain")
858+
(output (format "-o %s" fn))
859+
(full-pandoc-cmd (mapconcat #'identity (list cmd url-opts request-header text-opts output) " ")))
860+
(message "Speed-type: Retrieving content with pandoc...")
861+
(when (or (> (call-process-shell-command full-pandoc-cmd) 0) (not (file-readable-p fn)))
862+
(error "Speed-type: Retrieving content with pandoc...FAILED, command was %s" full-pandoc-cmd))
863+
(message "Speed-type: Retrieving content with pandoc...DONE")))
862864
(find-file-noselect fn t)))
863865

864866
(defun speed-type-retrieve-pandoc-top-retrieve (url)

0 commit comments

Comments
 (0)