From 67b7eb0ab782cb93ccc4e242451fd697878ffe6e Mon Sep 17 00:00:00 2001 From: Curt Spark Date: Thu, 16 Apr 2020 03:06:53 +0100 Subject: [PATCH] Org Mode LaTeX Live Preview Major Improvements --- config.org | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/config.org b/config.org index 0813134..413f568 100644 --- a/config.org +++ b/config.org @@ -7,19 +7,25 @@ Welcome to my Emacs configuration! [[./dashboard.png]] This configuration is inspired by : -https://github.com/munen/emacs.d + +`https://github.com/munen/emacs.d` And also loosely inspired by : -https://github.com/daedreth/UncleDavesEmacs/blob/master/config.org +`https://github.com/daedreth/UncleDavesEmacs/blob/master/config.org` With help from his fantastic Emacs tutorial series : -https://www.youtube.com/playlist?list=PLX2044Ew-UVVv31a0-Qn3dA6Sd_-NyA1n +`https://www.youtube.com/playlist?list=PLX2044Ew-UVVv31a0-Qn3dA6Sd_-NyA1n` -This configuration is much more barebones and suited for someone just doing some writing or editing, which is exactly my use case. It does however copy over the useful functionalities (In my personal preference) -As this is a simple literate configuration, not a large actively maintained distribution like Spacemacs or Doom Emacs, feel free to do whatever you want with the configuration. -I've tried to document what every package does, what the code does briefly for beginners to Emacs or literate configurations. +This configuration is much more barebones and suited for someone just +doing some writing or editing, which is exactly my use case. It does +however copy over the useful functionalities (In my personal +preference) As this is a simple literate configuration, not a large +actively maintained distribution like Spacemacs or Doom Emacs, feel +free to do whatever you want with the configuration. I've tried to +document what every package does, what the code does briefly for +beginners to Emacs or literate configurations. * Config ** Appearance @@ -255,29 +261,42 @@ Set Minor Mode as Global : #+END_SRC ** Org Mode *** Simple Org Mode Preview -These are a simple set of functions that will automatically refresh the other buffer, which presumably has the Org Mode PDF open. -This workflow expects you to have 2 window panes open, which can be in any orientation. The Org Mode File you are editing, and the PDF Document to view the changes you are making. -Define functions and set keybindings: +These are a simple set of functions that will automatically refresh +the other buffer, which presumably has the Org Mode PDF open. Once +using the keybindings to quickly export the file, another window will +pop up as a live preview (Which is just an automatically opened +preview of the exported PDF). Define functions and set keybindings: #+BEGIN_SRC emacs-lisp + (defun open-pdf () + (split-window-right) + (other-window 1) + (find-file (concat "/" (substring buffer-file-name 1 (- (length buffer-file-name) 4)) ".pdf")) + (revert-buffer nil t) + (other-window -1)) + (defun update-other-buffer () (interactive) (other-window 1) (revert-buffer nil t) (other-window -1)) + (defun check-if-pdf-is-open () + (setq openwindows (length (delete-dups (mapcar #'window-buffer (window-list))))) + (if (>= openwindows 2) (update-other-buffer) (open-pdf))) + (defun org-compile-beamer-and-update-other-buffer () "Has as a premise that it's run from an org-mode buffer and the other buffer already has the PDF open" (interactive) (org-beamer-export-to-pdf) - (update-other-buffer)) + (check-if-pdf-is-open)) (defun org-compile-latex-and-update-other-buffer () "Has as a premise that it's run from an org-mode buffer and the other buffer already has the PDF open" (interactive) (org-latex-export-to-pdf) - (update-other-buffer)) + (check-if-pdf-is-open)) (define-key org-mode-map (kbd "C-c rl") 'org-compile-latex-and-update-other-buffer) (define-key org-mode-map (kbd "C-c rb") 'org-compile-beamer-and-update-other-buffer) @@ -398,7 +417,7 @@ Install the package, enable it and ensure that it always is installed, and then (use-package company :ensure t :init - (company-mode)) + (global-company-mode)) #+END_SRC ***** Configuration