Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple fixes for checkdoc and byte compiler #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions quarto-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
;;; Customizable variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defgroup quarto nil
"Settings for the quarto polymode"
"Settings for the quarto polymode."
:group 'polymode)

(defcustom quarto-root-polymode
Expand All @@ -90,11 +90,13 @@
("html" "html" "html document" "html")
("pdf" "pdf" "pdf document" "pdf")
("word" "docx" "word document" "docx")
("revealjs" "html" "revealjs presentation" "revealjs"))) ;; TODO fill this out automatically
("revealjs" "html" "revealjs presentation" "revealjs")))
;; TODO fill this out automatically
"Quarto Markdown exporter.
Please note that with 'AUTO DETECT' export options, output file
names are inferred by quarto from the appropriate metadata.
That is, output file names don't comply with `polymode-exporter-output-file-format'."
That is, output file names do not comply with
`polymode-exporter-output-file-format'."
:group 'polymode-export
:type 'object)

Expand All @@ -107,8 +109,8 @@ That is, output file names don't comply with `polymode-exporter-output-file-form
:type 'boolean)

(defcustom quarto-force-preview t
"When t, all markdown rendering commands go through quarto-preview instead of producing
disk output."
"Non-nil means markdown rendering commands go through `quarto-preview'.
Otherwise generate disk output."
:group 'quarto
:type 'boolean)

Expand Down Expand Up @@ -152,7 +154,8 @@ disk output."
(reverse result)))

(defun quarto-mode--buffer-in-quarto-project-p ()
"Return the full filename of the _quarto.yml project configuration for the present buffer or nil if none is found."
"Return full filename of _quarto.yml project configuration for present buffer.
Otherwise, return nil if none is found."
(locate-dominating-file buffer-file-name "_quarto.yml"))

(defvar quarto-mode--preview-process nil)
Expand All @@ -169,7 +172,8 @@ disk output."
(url-generic-parse-url (match-string 1 line)))))))

(defun quarto-mode--process-filter (proc string)
"Filter the output generated by a `quarto-preview' process. This is a process filter operating on process PROC and input STRING."
"Filter the output generated by a `quarto-preview' process.
This is a process filter operating on process PROC and input STRING."
(with-current-buffer (get-buffer "*quarto-preview*")
(let ((prev-lines (count-lines (point-min) (point-max))))
(comint-output-filter proc string)
Expand All @@ -189,8 +193,7 @@ disk output."
(defconst quarto-mode--quarto-preview-uuid "5E89DF46-0E7B-4604-A76A-58EC4E12A11B")

(defun quarto-preview ()
"Start (or restart) a quarto preview process to automatically
rerender documents.
"Start (or restart) a quarto preview process to rerender documents.

`quarto-preview` checks parent directories for a `_quarto.yml`
file. If one is found, then `quarto-preview` previews that entire
Expand Down Expand Up @@ -234,7 +237,7 @@ To control whether or not to show the display, customize

(easy-menu-define quarto-menu
(list poly-quarto-mode-map)
"Menu for quarto-mode"
"Menu for quarto-mode."
'("Quarto"
["Start Preview" quarto-preview t]))

Expand All @@ -243,14 +246,17 @@ To control whether or not to show the display, customize

(cl-defun quarto-mode--preview-refresh-complete
(&key data response symbol-status error-thrown)
"Refresh quarto-preview when the status code of the rerender request is not 200.
"Refresh `quarto-preview' unless status code of rerender request is 200.

This is an internal function."
This is an internal function. RESPONSE is used to determine status code.
DATA, SYMBOL-STATUS and ERROR-THROWN are ignored."
(unless (= (request-response-status-code response) 200)
(quarto-preview)))

(defun quarto-mode--maybe-preview (name)
"Call `quarto-preview' with filename NAME when needed. In that case, errors intentionally to avoid `markdown-command' from finishing."
"Call `quarto-preview' with filename NAME when needed.
In that case, errors intentionally to avoid `markdown-command'
from finishing."
(with-current-buffer (get-file-buffer name)
(let* ((this-project-directory
(quarto-mode--buffer-in-quarto-project-p)))
Expand Down Expand Up @@ -279,9 +285,11 @@ This is an internal function."
(error "Refreshing %s in quarto-preview" name))))))))

(defun quarto-mode-markdown-command (begin-region end-region buf name)
"Call quarto, typically from inside `markdown`.
"Call quarto, typically from inside `markdown'.

Ensure quarto has rendered NAME (necessary if in a project). If not in a project, render the region given by BEGIN-REGION and END-REGION, and insert the output of `quarto render` in BUF."
Ensure quarto has rendered NAME (necessary if in a project). If
not in a project, render the region given by BEGIN-REGION and
END-REGION, and insert the output of `quarto render` in BUF."

;; This handles previews (it all goes through quarto-preview instead of render)
(quarto-mode--maybe-preview name)
Expand Down