Skip to content

Commit

Permalink
sort-lines becomes case-insensitive; updated ess-rmd-render/ess-rmd-b…
Browse files Browse the repository at this point in the history
…ookdown to include output = NULL.
  • Loading branch information
basille committed Mar 29, 2022
1 parent 29ea6eb commit acefb3c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
61 changes: 32 additions & 29 deletions functions/ess-rmd-library.el
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@
(ess-force-buffer-current)
(save-excursion
(let* ((output-format-table (make-hash-table :test 'equal)))
(puthash "HTML" "html_document" output-format-table)
(puthash "PDF" "pdf_document" output-format-table)
(puthash "ODT" "odt_document" output-format-table)
(puthash "Word" "word_document" output-format-table)
(puthash "reveal.js" "revealjs_presentation" output-format-table)
(puthash "All" "all" output-format-table)
(let* ((sprocess (ess-get-process ess-current-process-name))
(sbuffer (process-buffer sprocess))
(buf-filename (buffer-file-name))
(output-format-user (completing-read "Output format: " '("HTML" "PDF" "ODT" "Word" "reveal.js" "All")))
(output-format (gethash output-format-user output-format-table))
(render-cmd
(format "rmarkdown::render(\"%s\", encoding = \"UTF-8\", output_format = \"%s\")" buf-filename output-format)))
(message "Running Render on %s" buf-filename)
(ess-execute render-cmd 'buffer nil nil)
(switch-to-buffer rmd-buf)
(ess-show-buffer (buffer-name sbuffer) nil))))))
(puthash "Guess" "NULL" output-format-table)
(puthash "HTML" "\"html_document\"" output-format-table)
(puthash "PDF" "\"pdf_document\"" output-format-table)
(puthash "ODT" "\"odt_document\"" output-format-table)
(puthash "Word" "\"word_document\"" output-format-table)
(puthash "reveal.js" "\"revealjs_presentation\"" output-format-table)
(puthash "All" "all" output-format-table)
(let* ((sprocess (ess-get-process ess-current-process-name))
(sbuffer (process-buffer sprocess))
(buf-filename (buffer-file-name))
(output-format-user (completing-read "Output format: " '("Guess" "HTML" "PDF" "ODT" "Word" "reveal.js" "All")))
(output-format (gethash output-format-user output-format-table))
(render-cmd
(format "rmarkdown::render(\"%s\", encoding = \"UTF-8\", output_format = %s)" buf-filename output-format)))
(message "Running Render on %s" buf-filename)
(ess-execute render-cmd 'buffer nil nil)
(switch-to-buffer rmd-buf)
(ess-show-buffer (buffer-name sbuffer) nil))))))


;; Function rmd-bookdown to use bookdown::render_book on index.Rmd
Expand All @@ -91,18 +92,20 @@
(save-excursion
(save-some-buffers)
(let* ((output-format-table (make-hash-table :test 'equal)))
(puthash "HTML" "bookdown::gitbook" output-format-table)
(puthash "PDF" "bookdown::pdf_book" output-format-table)
(puthash "All" "all" output-format-table)
(let* ((sprocess (ess-get-process ess-current-process-name))
(sbuffer (process-buffer sprocess))
(output-format-user (completing-read "Output format: " '("HTML" "PDF" "All")))
(output-format (gethash output-format-user output-format-table))
(bkdwn-cmd (concat "bookdown::render_book(\"index.Rmd\", output_format =\"" output-format "\")")))
(message "Running Bookdown on index.Rmd")
(ess-execute bkdwn-cmd 'buffer nil nil)
(switch-to-buffer rmd-buf)
(ess-show-buffer (buffer-name sbuffer) nil))))))
(puthash "Guess" "NULL" output-format-table)
(puthash "HTML" "bookdown::gitbook" output-format-table)
(puthash "PDF" "bookdown::pdf_book" output-format-table)
(puthash "All" "all" output-format-table)
(let* ((sprocess (ess-get-process ess-current-process-name))
(sbuffer (process-buffer sprocess))
(output-format-user (completing-read "Output format: " '("Guess" "HTML" "PDF" "All")))
(output-format (gethash output-format-user output-format-table))
(bkdwn-cmd
(format "bookdown::render(\"index.Rmd\", encoding = \"UTF-8\", output_format = %s)" output-format)))
(message "Running Bookdown on index.Rmd")
(ess-execute bkdwn-cmd 'buffer nil nil)
(switch-to-buffer rmd-buf)
(ess-show-buffer (buffer-name sbuffer) nil))))))


;; Functions rmd-fenced-r-code-block and rmd-inline-r-code to insert R
Expand Down
10 changes: 10 additions & 0 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,16 @@ Move line(s) up and down with ~M-S-up~/~M-S-down~:
(global-set-key (kbd "C-c C-d") 'sudden-death)
#+END_SRC

=sort-lines= is case sensitive by default, which I don't like. This makes it
case insensitive (to get the default behavior back: ~M-x set-variable [RETURN]
sort-fold-case [RETURN] nil [RETURN]~):

#+BEGIN_SRC emacs-lisp
(custom-set-variables
'(sort-fold-case t t)
)
#+END_SRC


** Spell check and syntax check

Expand Down

0 comments on commit acefb3c

Please sign in to comment.