-
-
Save stefano-meschiari/9217695 to your computer and use it in GitHub Desktop.
;; AucTeX | |
(setq TeX-auto-save t) | |
(setq TeX-parse-self t) | |
(setq-default TeX-master nil) | |
(add-hook 'LaTeX-mode-hook 'visual-line-mode) | |
(add-hook 'LaTeX-mode-hook 'flyspell-mode) | |
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) | |
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) | |
(setq reftex-plug-into-AUCTeX t) | |
(setq TeX-PDF-mode t) | |
;; Use Skim as viewer, enable source <-> PDF sync | |
;; make latexmk available via C-c C-c | |
;; Note: SyncTeX is setup via ~/.latexmkrc (see below) | |
(add-hook 'LaTeX-mode-hook (lambda () | |
(push | |
'("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t | |
:help "Run latexmk on file") | |
TeX-command-list))) | |
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk"))) | |
;; use Skim as default pdf viewer | |
;; Skim's displayline is used for forward search (from .tex to .pdf) | |
;; option -b highlights the current line; option -g opens Skim in the background | |
(setq TeX-view-program-selection '((output-pdf "PDF Viewer"))) | |
(setq TeX-view-program-list | |
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b"))) |
i.e. what does the add-hook do? I think it reads, "When LaTeX mode is entered (e.g. by switching to a .tex buffer), push onto the TeX-command-list, the command "latexmk -pdf %s" where %s is the output of TeX-run-TeX."
Is that about right?
Hooks are a mechanism used all around Emacs in order to modify its behavior in a more granular way.
A hook is a Elisp variable holding a list of functions, to be called on some well-defined occasion. In this case, LaTeX-mode-hook
holds functions that are loaded when the LaTeX mode is loaded.
The second says to add the "setq TeX-command-default "latexmk"" whenever TeX-mode-hook is entered. Is there a good reason not to just do the setq globally?
Sometimes such commands need to be issued every time a file is entered. Emacs does not set it globally as expected.
I'm an emacs noob, would you mind explaining a bit what this does?
i.e. what does the add-hook do? I think it reads, "When LaTeX mode is entered (e.g. by switching to a .tex buffer), push onto the TeX-command-list, the command "latexmk -pdf %s" where %s is the output of TeX-run-TeX."
Is that about right?
The second says to add the "setq TeX-command-default "latexmk"" whenever TeX-mode-hook is entered. Is there a good reason not to just do the setq globally?