From 9c771d6796aa6c1a693ca8f9f0b4101da6999111 Mon Sep 17 00:00:00 2001 From: Louis Lacoste Date: Tue, 17 Jan 2023 10:15:21 +0100 Subject: [PATCH] Added the org-fragtog package to do inline latex edit/preview --- .emacs.d/init.el | 24 +++++++++++++++++++++--- .emacs.d/init.org | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index a1563c2..b1c73d3 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -87,8 +87,13 @@ (dired-directory dired-directory "%b")))) (global-font-lock-mode t) - (custom-set-faces - '(flyspell-incorrect ((t (:inverse-video t))))) + +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(flyspell-incorrect ((t (:inverse-video t))))) (line-number-mode 1) (column-number-mode 1) @@ -321,7 +326,8 @@ A->B (let* ((wanted-packages '(flycheck company - org-appear)) + org-appear + org-fragtog)) (missing-wanted-packages (remove-if #'package-installed-p wanted-packages))) (when missing-wanted-packages (message "Missing wanted packages: %s" missing-wanted-packages) @@ -339,4 +345,16 @@ A->B (global-visual-line-mode 1) ; 1 for on & 0 for off +(add-hook 'org-mode-hook 'org-fragtog-mode) + (load-theme 'leuven t) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(org-format-latex-options + '(:foreground default :background default :scale 1.5 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers + ("begin" "$1" "$" "$$" "\\(" "\\["))) + '(package-selected-packages + '(org-fragtog org-appear magit htmlize flycheck ess company auctex))) diff --git a/.emacs.d/init.org b/.emacs.d/init.org index 952576b..6850a1b 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -513,7 +513,8 @@ This often fails, yielding an ugly warning, and isn't of any use in Org-mode any (let* ((wanted-packages '(flycheck company - org-appear)) + org-appear + org-fragtog)) (missing-wanted-packages (remove-if #'package-installed-p wanted-packages))) (when missing-wanted-packages (message "Missing wanted packages: %s" missing-wanted-packages) @@ -541,6 +542,36 @@ This mode makes the emphasis markers appear when the cursor is on it #+begin_src emacs-lisp :tangle init.el (global-visual-line-mode 1) ; 1 for on & 0 for off #+end_src +** Auto toggle the preview of LaTeX fragments +#+begin_src emacs-lisp :tangle init.el +(add-hook 'org-mode-hook 'org-fragtog-mode) +#+end_src +** Remote image display +This code was taken from https://emacs.stackexchange.com/questions/42281/org-mode-is-it-possible-to-display-online-images and makes use of the =org-yt= package. + +#+begin_src emacs-lisp +(require 'org-yt) + +(defun org-image-link (protocol link _description) + "Interpret LINK as base64-encoded image data." + (cl-assert (string-match "\\`img" protocol) nil + "Expected protocol type starting with img") + (let ((buf (url-retrieve-synchronously (concat (substring protocol 3) ":" link)))) + (cl-assert buf nil + "Download of image \"%s\" failed." link) + (with-current-buffer buf + (goto-char (point-min)) + (re-search-forward "\r?\n\r?\n") + (buffer-substring-no-properties (point) (point-max))))) + +(org-link-set-parameters + "imghttp" + :image-data-fun #'org-image-link) + +(org-link-set-parameters + "imghttps" + :image-data-fun #'org-image-link) +#+end_src * Theme ** Activation du thème #+begin_src emacs-lisp :tangle init.el