From e8827048b87d1f2587b1363601b692629e28c863 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 16:59:24 +0200 Subject: [PATCH 01/43] sp already sets up latex-specific features --- modules/lang/latex/config.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 642ceac8b..3bc7858e0 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -14,9 +14,6 @@ ;; Plugins ;; -;; sp's default rules are obnoxious, so disable them -(provide 'smartparens-latex) - (after! tex ;; Set some varibles to fontify common LaTeX commands. (load! "+fontification") From 0dc2feec466be3279c86f1a25529c8985e6dfbfe Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 17:07:34 +0200 Subject: [PATCH 02/43] Remove redundant package! declaration --- modules/lang/latex/packages.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lang/latex/packages.el b/modules/lang/latex/packages.el index 9939c2366..71cb34f57 100644 --- a/modules/lang/latex/packages.el +++ b/modules/lang/latex/packages.el @@ -2,7 +2,6 @@ ;;; lang/latex/packages.el (package! auctex) -(package! flyspell) (package! adaptive-wrap) ;; Optional module features: From 00af6e66a719fd5c41e29a0009e38c2f4ec5424d Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 18:32:23 +0200 Subject: [PATCH 03/43] Auctex already supports pdf tools --- modules/lang/latex/config.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 3bc7858e0..9eafb0de0 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -97,7 +97,6 @@ ;; Or PDF-tools, but only if the module is also loaded (when (and (featurep! :tools pdf) (featurep! +pdf-tools)) - (add-to-list 'TeX-view-program-list '("PDF Tools" "TeX-pdf-tools-sync-view")) (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) ;; Enable auto reverting the PDF document with PDF Tools (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))) From 968fb60bcee898d9023adc4a9b6c555c54748df8 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 18:34:13 +0200 Subject: [PATCH 04/43] This is the default in auctex anyway --- modules/lang/latex/config.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 9eafb0de0..2e4321c64 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -64,7 +64,6 @@ (add-hook! 'LaTeX-mode-hook #'(LaTeX-math-mode TeX-source-correlate-mode - TeX-global-PDF-mode TeX-PDF-mode visual-line-mode)) ;; Enable rainbow mode after applying styles to the buffer From 0edd4015392264202cde793a416136659e02e4ee Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 18:35:26 +0200 Subject: [PATCH 05/43] This is redundant given global pdf mode --- modules/lang/latex/config.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 2e4321c64..7db547e92 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -64,7 +64,6 @@ (add-hook! 'LaTeX-mode-hook #'(LaTeX-math-mode TeX-source-correlate-mode - TeX-PDF-mode visual-line-mode)) ;; Enable rainbow mode after applying styles to the buffer (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) From b06fe0dde2f61ac76794e4403cbf96725de602f8 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 18:44:18 +0200 Subject: [PATCH 06/43] Made company-auctex more concise --- modules/lang/latex/config.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 7db547e92..be9f8041a 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -198,15 +198,8 @@ (def-package! company-auctex :when (featurep! :completion company) - :commands (company-auctex-init) - :init - ;; We can't use the `set-company-backend!' because Auctex reports its - ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is - ;; not something `set-company-backend!' anticipates (and shouldn't have to!) - (add-hook! LaTeX-mode - (make-local-variable 'company-backends) - (company-auctex-init))) - + :hook (LaTeX-mode . ((make-local-variable 'company-backends) + (company-auctex-init)))) ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap From c93c595ba31f9ed7a6b17ee38b7552a9149520ee Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 18:46:54 +0200 Subject: [PATCH 07/43] reformat --- modules/lang/latex/config.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index be9f8041a..6953b6e3b 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -179,14 +179,12 @@ (def-package! ivy-bibtex :when (featurep! :completion ivy) - :commands ivy-bibtex - ) + :commands ivy-bibtex) (def-package! helm-bibtex :when (featurep! :completion helm) - :commands helm-bibtex - ) + :commands helm-bibtex) (after! bibtex-completion (unless (string-empty-p +latex-bibtex-file) From 9eccdd5c1b614ff1c115d14bf6ad0449d03eccec Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 12 Jul 2018 19:52:54 +0200 Subject: [PATCH 08/43] fixed broken hook --- modules/lang/latex/config.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 6953b6e3b..37fa4d3f3 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -196,8 +196,11 @@ (def-package! company-auctex :when (featurep! :completion company) - :hook (LaTeX-mode . ((make-local-variable 'company-backends) - (company-auctex-init)))) + :after latex + :config + (add-hook! LaTeX-mode + (make-local-variable 'company-backends) + (company-auctex-init))) ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap From 821d1937b80e2cca76789b1822280c7ab7737e00 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 10:07:02 +0200 Subject: [PATCH 09/43] Revert sp change. --- modules/lang/latex/config.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 37fa4d3f3..c5d0479b4 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -14,6 +14,9 @@ ;; Plugins ;; +;; sp's default rules are obnoxious, so disable them +(provide 'smartparens-latex) + (after! tex ;; Set some varibles to fontify common LaTeX commands. (load! "+fontification") From a64a2e88482414e5d01811015bca020c144f2f91 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 10:14:10 +0200 Subject: [PATCH 10/43] Added company reftex support. --- modules/lang/latex/config.el | 5 +++++ modules/lang/latex/packages.el | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index c5d0479b4..c96c7fcbf 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -205,6 +205,11 @@ (make-local-variable 'company-backends) (company-auctex-init))) +(def-package! company-reftex + :after reftex + :config + (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) + ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap :hook (LaTeX-mode . adaptive-wrap-prefix-mode) diff --git a/modules/lang/latex/packages.el b/modules/lang/latex/packages.el index 71cb34f57..42900a7a5 100644 --- a/modules/lang/latex/packages.el +++ b/modules/lang/latex/packages.el @@ -15,7 +15,8 @@ ;; Features according to other user selected options (when (featurep! :completion company) - (package! company-auctex)) + (package! company-auctex) + (package! company-reftex)) (when (featurep! :completion ivy) (package! ivy-bibtex)) (when (featurep! :completion helm) From 8a4e61f0b2d13aa342bf87f14872facdb335ec8f Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 12:51:11 +0200 Subject: [PATCH 11/43] company-reftex takes over citation completion --- modules/lang/latex/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index c96c7fcbf..dddff976d 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -196,14 +196,14 @@ (setq bibtex-completion-library-path (list +latex-bibtex-dir) bibtex-completion-notes-path (expand-file-name "notes.org" +latex-bibtex-dir)))) - (def-package! company-auctex :when (featurep! :completion company) :after latex :config (add-hook! LaTeX-mode (make-local-variable 'company-backends) - (company-auctex-init))) + (add-to-list 'company-backends + '(company-auctex-macros company-auctex-symbols company-auctex-environments)))) (def-package! company-reftex :after reftex From babb7821a0021d35c5d665dec182ea276dcf1225 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 18:01:22 +0200 Subject: [PATCH 12/43] Improved math completion via company-math --- modules/lang/latex/config.el | 13 +++++++++---- modules/lang/latex/packages.el | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index dddff976d..5cc9083a1 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -200,10 +200,15 @@ :when (featurep! :completion company) :after latex :config - (add-hook! LaTeX-mode - (make-local-variable 'company-backends) - (add-to-list 'company-backends - '(company-auctex-macros company-auctex-symbols company-auctex-environments)))) + (def-package! company-math + :defer t + :init + (add-hook! LaTeX-mode + (setq-local company-backends + (append '((company-math-symbols-latex + company-auctex-macros + company-auctex-environments)) + company-backends))))) (def-package! company-reftex :after reftex diff --git a/modules/lang/latex/packages.el b/modules/lang/latex/packages.el index 42900a7a5..ade453d7e 100644 --- a/modules/lang/latex/packages.el +++ b/modules/lang/latex/packages.el @@ -16,7 +16,8 @@ (when (featurep! :completion company) (package! company-auctex) - (package! company-reftex)) + (package! company-reftex) + (package! company-math)) (when (featurep! :completion ivy) (package! ivy-bibtex)) (when (featurep! :completion helm) From 6ba4982bfb8ea136316dbe9929422173d635508a Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 18:45:59 +0200 Subject: [PATCH 13/43] LaTeX-math-mode is redundant with completion --- modules/lang/latex/config.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 5cc9083a1..40089ecaf 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -65,8 +65,7 @@ 'local)) ;; Adding useful things for latex (add-hook! 'LaTeX-mode-hook - #'(LaTeX-math-mode - TeX-source-correlate-mode + #'(TeX-source-correlate-mode visual-line-mode)) ;; Enable rainbow mode after applying styles to the buffer (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) From 00322883d7cd5101b514d8254fee02211f1325e3 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Fri, 13 Jul 2018 18:50:10 +0200 Subject: [PATCH 14/43] Company-reftex should be conditional on company --- modules/lang/latex/config.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 40089ecaf..0b169fc21 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -165,7 +165,6 @@ bibtex-text-indentation 20) (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) - (def-package! auctex-latexmk :when (featurep! +latexmk) :after-call (latex-mode-hook LaTeX-mode-hook) @@ -178,12 +177,10 @@ ;; Add latexmk as a TeX target (auctex-latexmk-setup)) - (def-package! ivy-bibtex :when (featurep! :completion ivy) :commands ivy-bibtex) - (def-package! helm-bibtex :when (featurep! :completion helm) :commands helm-bibtex) @@ -210,6 +207,7 @@ company-backends))))) (def-package! company-reftex + :when (featurep! :completion company) :after reftex :config (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) From ed4f7301bad0d0bdc6d37ef6de3c6f004e11dca0 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 09:16:23 +0200 Subject: [PATCH 15/43] Removed bibtex dir variable --- modules/lang/latex/config.el | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 0b169fc21..212101c28 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -3,9 +3,6 @@ (defvar +latex-bibtex-file "" "File AUCTeX (specifically RefTeX) uses to search for citations.") -(defvar +latex-bibtex-dir "" - "Where bibtex files are kept.") - (defvar +latex-indent-level-item-continuation 4 "Custom indentation level for items in enumeration-type environments") @@ -187,10 +184,7 @@ (after! bibtex-completion (unless (string-empty-p +latex-bibtex-file) - (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file)))) - (unless (string-empty-p +latex-bibtex-dir) - (setq bibtex-completion-library-path (list +latex-bibtex-dir) - bibtex-completion-notes-path (expand-file-name "notes.org" +latex-bibtex-dir)))) + (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file))))) (def-package! company-auctex :when (featurep! :completion company) From a09799d73dfebb42f26273170627fa9829cdf68f Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 09:35:32 +0200 Subject: [PATCH 16/43] Skim already configured upstream --- modules/lang/latex/config.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 212101c28..c50c9a15c 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -6,7 +6,6 @@ (defvar +latex-indent-level-item-continuation 4 "Custom indentation level for items in enumeration-type environments") - ;; ;; Plugins ;; @@ -84,7 +83,6 @@ ;; Or Skim (when (featurep! +skim) - (add-to-list 'TeX-view-program-list '("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")) (add-to-list 'TeX-view-program-selection 'output-pdf '("Skim"))) ;; Or Zathura From a5f3c03c35fe13204fe0c9131b118871da1c1a0c Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 11:10:55 +0200 Subject: [PATCH 17/43] Added warning back in --- modules/lang/latex/config.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index c50c9a15c..51714f8dc 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -190,6 +190,9 @@ :config (def-package! company-math :defer t + ;; We can't use the `set-company-backend!' because Auctex reports its + ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is + ;; not something `set-company-backend!' anticipates (and shouldn't have to!) :init (add-hook! LaTeX-mode (setq-local company-backends From 944a7dbb4e20bada0711e378f6e8c12b97280e17 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 11:41:12 +0200 Subject: [PATCH 18/43] This no longer applies. --- modules/lang/latex/config.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 51714f8dc..44fca3063 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -97,9 +97,6 @@ (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))) -;; The preview package is currently broken with the latest AUCTeX version -;; ("11.90.2.2017-07-25) ... and Ghostscript 9.22. It's now fixed in AUCTeX -;; master, so we just have to wait. (def-package! preview :hook (LaTeX-mode . LaTeX-preview-setup) :config From af7450cd0e5c09eb381f5b6a8ee48c85ba907ecb Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:10:58 +0200 Subject: [PATCH 19/43] Move latexmk setup into seperate file --- modules/lang/latex/+latexmk.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 modules/lang/latex/+latexmk.el diff --git a/modules/lang/latex/+latexmk.el b/modules/lang/latex/+latexmk.el new file mode 100644 index 000000000..760236453 --- /dev/null +++ b/modules/lang/latex/+latexmk.el @@ -0,0 +1,13 @@ +;;; lang/latex/+latexmk.el -*- lexical-binding: t; -*- +;;;###if (featurep! +latexmk) + +(def-package! auctex-latexmk + :after-call (latex-mode-hook LaTeX-mode-hook) + :init + ;; Pass the -pdf flag when TeX-PDF-mode is active + (setq auctex-latexmk-inherit-TeX-PDF-mode t) + ;; Set LatexMk as the default + (setq-hook! LaTeX-mode TeX-command-default "LatexMk") + :config + ;; Add latexmk as a TeX target + (auctex-latexmk-setup)) From b6c3d5309f83b5c7d3d7e9898d2b1b4049f2e451 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:11:20 +0200 Subject: [PATCH 20/43] Move preview-pane setup into seperate file --- modules/lang/latex/+preview-pane.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/lang/latex/+preview-pane.el diff --git a/modules/lang/latex/+preview-pane.el b/modules/lang/latex/+preview-pane.el new file mode 100644 index 000000000..b4bfb342b --- /dev/null +++ b/modules/lang/latex/+preview-pane.el @@ -0,0 +1,16 @@ +;;; lang/latex/+preview-pane.el -*- lexical-binding: t; -*- +;;;###if (featurep! +preview-pane) + +(def-package! latex-preview-pane + :when (featurep! +preview-pane) + :hook ((latex-mode LaTeX-mode) . latex-preview-pane-enable) + :commands latex-preview-pane-mode + :init + (setq latex-preview-pane-multifile-mode 'auctex) + :config + (add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode)) + (add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane")) + (define-key! doc-view-mode-map + (kbd "ESC") #'delete-window + "q" #'delete-window + "k" (λ! (quit-window) (delete-window)))) From dc40fa36d3205d2c463661b8c808fae4daaf873c Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:11:53 +0200 Subject: [PATCH 21/43] Move referencing setup into different file --- modules/lang/latex/+ref.el | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 modules/lang/latex/+ref.el diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el new file mode 100644 index 000000000..ce47b7f9d --- /dev/null +++ b/modules/lang/latex/+ref.el @@ -0,0 +1,60 @@ +;;; lang/latex/+ref.el -*- lexical-binding: t; -*- + +(defvar +latex-bibtex-file "" + "File AUCTeX (specifically RefTeX) uses to search for citations.") + +(def-package! reftex + :hook ((latex-mode LaTeX-mode) . turn-on-reftex) + :init + (setq reftex-plug-into-AUCTeX t + reftex-toc-split-windows-fraction 0.3) + :config + ;; Get ReTeX working with biblatex + ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 + (setq reftex-cite-format + '((?t . "\\textcite[]{%l}") + (?a . "\\autocite[]{%l}") + (?c . "\\cite[]{%l}") + (?s . "\\smartcite[]{%l}") + (?f . "\\footcite[]{%l}") + (?n . "\\nocite{%l}") + (?b . "\\blockcquote[]{%l}{}"))) + (unless (string-empty-p +latex-bibtex-file) + (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file)))) + (map! :map reftex-mode-map + :localleader :n ";" 'reftex-toc) + (add-hook! 'reftex-toc-mode-hook + (reftex-toc-rescan) + (map! :local + :e "j" #'next-line + :e "k" #'previous-line + :e "q" #'kill-buffer-and-window + :e "ESC" #'kill-buffer-and-window))) + +(def-package! company-reftex + :when (featurep! :completion company) + :after reftex + :config + (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) + +(def-package! bibtex + :defer t + :config + (setq bibtex-dialect 'biblatex + bibtex-align-at-equal-sign t + bibtex-text-indentation 20) + (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) + +(def-package! ivy-bibtex + :when (featurep! :completion ivy) + :commands ivy-bibtex) + +(def-package! helm-bibtex + :when (featurep! :completion helm) + :commands helm-bibtex) + +(after! bibtex-completion + (unless (string-empty-p +latex-bibtex-file) + (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file))))) + + From 39e03f4cf1671dca0c80aedfdfd160cc8e44be2f Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:12:04 +0200 Subject: [PATCH 22/43] Move viewer setup into different file --- modules/lang/latex/+viewers.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 modules/lang/latex/+viewers.el diff --git a/modules/lang/latex/+viewers.el b/modules/lang/latex/+viewers.el new file mode 100644 index 000000000..1e102767a --- /dev/null +++ b/modules/lang/latex/+viewers.el @@ -0,0 +1,22 @@ +;;; lang/latex/+viewers.el -*- lexical-binding: t; -*- + +(when (featurep! +okular) + ;; Configure Okular as viewer. Including a bug fix + ;; (https://bugs.kde.org/show_bug.cgi?id=373855) + (add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a")))) + (add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))) + +;; Or Skim +(when (featurep! +skim) + (add-to-list 'TeX-view-program-selection 'output-pdf '("Skim"))) + +;; Or Zathura +(when (featurep! +zathura) + (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))) + +;; Or PDF-tools, but only if the module is also loaded +(when (and (featurep! :tools pdf) + (featurep! +pdf-tools)) + (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) + ;; Enable auto reverting the PDF document with PDF Tools + (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)) From 5f14efbc203a40763ec4adb298fc022e1cb41865 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:12:15 +0200 Subject: [PATCH 23/43] Spring-cleaning --- modules/lang/latex/config.el | 129 ++++------------------------------- 1 file changed, 12 insertions(+), 117 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 44fca3063..7f65f3c5b 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -1,15 +1,8 @@ ;;; lang/latex/config.el -*- lexical-binding: t; -*- -(defvar +latex-bibtex-file "" - "File AUCTeX (specifically RefTeX) uses to search for citations.") - (defvar +latex-indent-level-item-continuation 4 "Custom indentation level for items in enumeration-type environments") -;; -;; Plugins -;; - ;; sp's default rules are obnoxious, so disable them (provide 'smartparens-latex) @@ -33,14 +26,9 @@ (setq-default TeX-master nil) ;; Display the output of the latex commands in a popup. (set-popup-rule! " output\\*$" :size 15) - - ;; TeX Font Styling - ;; (def-package! tex-style :defer t) - ;; TeX Folding (add-hook 'TeX-mode-hook #'TeX-fold-mode)) - (after! latex (setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks. '(LaTeX-section-heading @@ -73,28 +61,8 @@ (dolist (env '("itemize" "enumerate" "description")) (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))) - ;; - ;; Use Okular if the user says so. - (when (featurep! +okular) - ;; Configure Okular as viewer. Including a bug fix - ;; (https://bugs.kde.org/show_bug.cgi?id=373855) - (add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a")))) - (add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))) - - ;; Or Skim - (when (featurep! +skim) - (add-to-list 'TeX-view-program-selection 'output-pdf '("Skim"))) - - ;; Or Zathura - (when (featurep! +zathura) - (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))) - - ;; Or PDF-tools, but only if the module is also loaded - (when (and (featurep! :tools pdf) - (featurep! +pdf-tools)) - (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) - ;; Enable auto reverting the PDF document with PDF Tools - (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))) + ;; Set-up viewers + (load! "+viewers")) (def-package! preview @@ -104,83 +72,6 @@ preview-scale-function (lambda () (* (/ 10.0 (preview-document-pt)) preview-scale)))) - -(def-package! latex-preview-pane - :when (featurep! +preview-pane) - :hook ((latex-mode LaTeX-mode) . latex-preview-pane-enable) - :commands latex-preview-pane-mode - :init - (setq latex-preview-pane-multifile-mode 'auctex) - :config - (add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode)) - (add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane")) - (define-key! doc-view-mode-map - (kbd "ESC") #'delete-window - "q" #'delete-window - "k" (λ! (quit-window) (delete-window)))) - - -(def-package! reftex - :hook ((latex-mode LaTeX-mode) . turn-on-reftex) - :init - (setq reftex-plug-into-AUCTeX t - reftex-toc-split-windows-fraction 0.3) - :config - ;; Get ReTeX working with biblatex - ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 - (setq reftex-cite-format - '((?t . "\\textcite[]{%l}") - (?a . "\\autocite[]{%l}") - (?c . "\\cite[]{%l}") - (?s . "\\smartcite[]{%l}") - (?f . "\\footcite[]{%l}") - (?n . "\\nocite{%l}") - (?b . "\\blockcquote[]{%l}{}"))) - (unless (string-empty-p +latex-bibtex-file) - (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file)))) - (map! :map reftex-mode-map - :localleader :n ";" 'reftex-toc) - (add-hook! 'reftex-toc-mode-hook - (reftex-toc-rescan) - (map! :local - :e "j" #'next-line - :e "k" #'previous-line - :e "q" #'kill-buffer-and-window - :e "ESC" #'kill-buffer-and-window))) - - -(def-package! bibtex - :defer t - :config - (setq bibtex-dialect 'biblatex - bibtex-align-at-equal-sign t - bibtex-text-indentation 20) - (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) - -(def-package! auctex-latexmk - :when (featurep! +latexmk) - :after-call (latex-mode-hook LaTeX-mode-hook) - :init - ;; Pass the -pdf flag when TeX-PDF-mode is active - (setq auctex-latexmk-inherit-TeX-PDF-mode t) - ;; Set LatexMk as the default - (setq-hook! LaTeX-mode TeX-command-default "LatexMk") - :config - ;; Add latexmk as a TeX target - (auctex-latexmk-setup)) - -(def-package! ivy-bibtex - :when (featurep! :completion ivy) - :commands ivy-bibtex) - -(def-package! helm-bibtex - :when (featurep! :completion helm) - :commands helm-bibtex) - -(after! bibtex-completion - (unless (string-empty-p +latex-bibtex-file) - (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file))))) - (def-package! company-auctex :when (featurep! :completion company) :after latex @@ -198,13 +89,17 @@ company-auctex-environments)) company-backends))))) -(def-package! company-reftex - :when (featurep! :completion company) - :after reftex - :config - (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) - ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap :hook (LaTeX-mode . adaptive-wrap-prefix-mode) :init (setq-default adaptive-wrap-extra-indent 0)) + +;; referencing + bibtex setup +(load! "+ref") + +;; +;; Sub-modules +;; + +(if (featurep! +latexmk) (load! "+latexmk")) +(if (featurep! +preview-pane) (load! "+preview-pane")) From 9fc5d9472eb906e8b6a92632b853a4aeba94bede Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:15:55 +0200 Subject: [PATCH 24/43] Viewers should be loaded after tex --- modules/lang/latex/config.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 7f65f3c5b..c82f555e9 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -9,6 +9,8 @@ (after! tex ;; Set some varibles to fontify common LaTeX commands. (load! "+fontification") +;; Set-up viewers + (load! "+viewers") (setq TeX-parse-self t ; Enable parse on load. TeX-save-query nil ; just save, don't ask @@ -59,10 +61,7 @@ (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s") ;; Set a custom item indentation (dolist (env '("itemize" "enumerate" "description")) - (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))) - - ;; Set-up viewers - (load! "+viewers")) + (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item)))) (def-package! preview From 3120636a2393b61f6321b6be066c95f59fe057db Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:22:22 +0200 Subject: [PATCH 25/43] This is (probably) no longer necessary --- modules/lang/latex/config.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index c82f555e9..78d9ade38 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -41,8 +41,6 @@ LaTeX-fill-break-at-separators nil LaTeX-item-indent 0) ; item indentation. - (define-key LaTeX-mode-map "\C-j" nil) - ;; Do not prompt for Master files, this allows auto-insert to add templates to ;; .tex files (add-hook! '(LaTeX-mode-hook TeX-mode-hook) From 96bcff1c0289d6982bf053caa08fc70142ed06a1 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 13:37:49 +0200 Subject: [PATCH 26/43] Simplify latexmk setup --- modules/lang/latex/+latexmk.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/lang/latex/+latexmk.el b/modules/lang/latex/+latexmk.el index 760236453..ded53f27f 100644 --- a/modules/lang/latex/+latexmk.el +++ b/modules/lang/latex/+latexmk.el @@ -2,7 +2,8 @@ ;;;###if (featurep! +latexmk) (def-package! auctex-latexmk - :after-call (latex-mode-hook LaTeX-mode-hook) + :defer t + :after latex :init ;; Pass the -pdf flag when TeX-PDF-mode is active (setq auctex-latexmk-inherit-TeX-PDF-mode t) From fae43bea518c96213c9e04cc7c9d809feffcd84c Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 13:38:02 +0200 Subject: [PATCH 27/43] Large refactor using def-package! --- modules/lang/latex/config.el | 82 ++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 78d9ade38..69d691168 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -3,35 +3,58 @@ (defvar +latex-indent-level-item-continuation 4 "Custom indentation level for items in enumeration-type environments") +(defvar +latex-bibtex-file "" + "File AUCTeX (specifically RefTeX) uses to search for citations.") + +;; +;; Plugins +;; + ;; sp's default rules are obnoxious, so disable them (provide 'smartparens-latex) -(after! tex - ;; Set some varibles to fontify common LaTeX commands. +(def-package! tex + :mode ("\\.tex\\'" . TeX-latex-mode) + :hook (TeX-mode . visual-line-mode) + :config + ;; fontify common latex commands (load! "+fontification") -;; Set-up viewers + ;; select viewer (load! "+viewers") - - (setq TeX-parse-self t ; Enable parse on load. - TeX-save-query nil ; just save, don't ask - TeX-auto-save t ; Enable parse on save. - ;; Use hidden directories for AUCTeX files. + (setq TeX-parse-self t ;; parse on load + TeX-auto-save t ;; parse on save + ;; use hidden dirs for auctex files TeX-auto-local ".auctex-auto" TeX-style-local ".auctex-style" - ;; When correlating sources to rendered PDFs, don't start the emacs - ;; server - TeX-source-correlate-start-server nil TeX-source-correlate-mode t TeX-source-correlate-method 'synctex - ;; Fonts for section, subsection, etc - font-latex-fontify-sectioning 1.15) + ;; don't start the emacs server when correlating sources + TeX-source-correlate-start-server nil + ;; automatically insert braces after sub/superscript in math mode + TeX-electric-sub-and-superscript t) + ;; prompt for master (setq-default TeX-master nil) - ;; Display the output of the latex commands in a popup. + ;; set-up chktex + (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s") + ;; display output of latex commands in popup (set-popup-rule! " output\\*$" :size 15) - ;; TeX Folding - (add-hook 'TeX-mode-hook #'TeX-fold-mode)) + ;; Do not prompt for Master files, this allows auto-insert to add templates to + ;; .tex files + (add-hook! 'TeX-mode-hook (remove-hook 'find-file-hook + (cl-find-if #'byte-code-function-p find-file-hook) + 'local)) + ;; Enable rainbow mode after applying styles to the buffer + (add-hook! 'TeX-update-style-hook #'rainbow-delimiters-mode) + (when (featurep! :feature spellcheck) + (add-hook 'TeX-mode-hook #'flyspell-mode :append))) -(after! latex +; Fold TeX macros +(def-package! tex-fold + :hook (TeX-mode . TeX-fold-mode)) + +(def-package! latex + :defer t + :config (setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks. '(LaTeX-section-heading LaTeX-section-title @@ -39,36 +62,21 @@ LaTeX-section-section LaTeX-section-label) LaTeX-fill-break-at-separators nil - LaTeX-item-indent 0) ; item indentation. - - ;; Do not prompt for Master files, this allows auto-insert to add templates to - ;; .tex files - (add-hook! '(LaTeX-mode-hook TeX-mode-hook) - (remove-hook 'find-file-hook - (cl-find-if #'byte-code-function-p find-file-hook) - 'local)) - ;; Adding useful things for latex - (add-hook! 'LaTeX-mode-hook - #'(TeX-source-correlate-mode - visual-line-mode)) - ;; Enable rainbow mode after applying styles to the buffer - (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) - (when (featurep! :feature spellcheck) - (add-hook 'LaTeX-mode-hook #'flyspell-mode :append)) - ;; Use chktex to search for errors in a latex file. - (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s") - ;; Set a custom item indentation + LaTeX-item-indent 0) + ;; Set custom item indentation (dolist (env '("itemize" "enumerate" "description")) (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item)))) - +;; set-up preview package (def-package! preview + :defer t :hook (LaTeX-mode . LaTeX-preview-setup) :config (setq-default preview-scale 1.4 preview-scale-function (lambda () (* (/ 10.0 (preview-document-pt)) preview-scale)))) +;; set-up company-auctex, but with company-math supplying the math symbols backend (def-package! company-auctex :when (featurep! :completion company) :after latex From e7465018fcd6fd11c095df0a835ae4fa4c101271 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 13:38:48 +0200 Subject: [PATCH 28/43] This shouldn't be tied to pdf-tools --- modules/lang/latex/+viewers.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/lang/latex/+viewers.el b/modules/lang/latex/+viewers.el index 1e102767a..2f0519a0e 100644 --- a/modules/lang/latex/+viewers.el +++ b/modules/lang/latex/+viewers.el @@ -1,5 +1,8 @@ ;;; lang/latex/+viewers.el -*- lexical-binding: t; -*- +;; Update PDF buffers after successful LaTeX runs +(add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer) + (when (featurep! +okular) ;; Configure Okular as viewer. Including a bug fix ;; (https://bugs.kde.org/show_bug.cgi?id=373855) @@ -17,6 +20,4 @@ ;; Or PDF-tools, but only if the module is also loaded (when (and (featurep! :tools pdf) (featurep! +pdf-tools)) - (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) - ;; Enable auto reverting the PDF document with PDF Tools - (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)) + (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))) From 6e67e5b3e4c8adbb15c36039b8f7550ed843b53b Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 13:39:15 +0200 Subject: [PATCH 29/43] simplify reftex declaration --- modules/lang/latex/+ref.el | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index ce47b7f9d..8c4b552be 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -1,13 +1,8 @@ ;;; lang/latex/+ref.el -*- lexical-binding: t; -*- -(defvar +latex-bibtex-file "" - "File AUCTeX (specifically RefTeX) uses to search for citations.") - (def-package! reftex - :hook ((latex-mode LaTeX-mode) . turn-on-reftex) - :init - (setq reftex-plug-into-AUCTeX t - reftex-toc-split-windows-fraction 0.3) + :defer t + :hook (LaTeX-mode . reftex-mode) :config ;; Get ReTeX working with biblatex ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 @@ -18,7 +13,9 @@ (?s . "\\smartcite[]{%l}") (?f . "\\footcite[]{%l}") (?n . "\\nocite{%l}") - (?b . "\\blockcquote[]{%l}{}"))) + (?b . "\\blockcquote[]{%l}{}")) + reftex-plug-into-AUCTeX t + reftex-toc-split-windows-fraction 0.3) (unless (string-empty-p +latex-bibtex-file) (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file)))) (map! :map reftex-mode-map @@ -31,14 +28,15 @@ :e "q" #'kill-buffer-and-window :e "ESC" #'kill-buffer-and-window))) +;; set up completion for citations and references (def-package! company-reftex :when (featurep! :completion company) :after reftex :config (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) +;; set up mode for bib files (def-package! bibtex - :defer t :config (setq bibtex-dialect 'biblatex bibtex-align-at-equal-sign t From 0aa15c162251d5382f39f5176cd00eba5e0cb9b0 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 13:39:30 +0200 Subject: [PATCH 30/43] simplify hook --- modules/lang/latex/+preview-pane.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/latex/+preview-pane.el b/modules/lang/latex/+preview-pane.el index b4bfb342b..734c6494e 100644 --- a/modules/lang/latex/+preview-pane.el +++ b/modules/lang/latex/+preview-pane.el @@ -3,7 +3,7 @@ (def-package! latex-preview-pane :when (featurep! +preview-pane) - :hook ((latex-mode LaTeX-mode) . latex-preview-pane-enable) + :hook (LaTeX-mode . latex-preview-pane-enable) :commands latex-preview-pane-mode :init (setq latex-preview-pane-multifile-mode 'auctex) From 9174b6c0e44c9e591bf2ea92dea159ef42bd40bd Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 14:03:31 +0200 Subject: [PATCH 31/43] Stop chktex from producing garbage --- modules/lang/latex/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 69d691168..f967e77c5 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -35,7 +35,7 @@ ;; prompt for master (setq-default TeX-master nil) ;; set-up chktex - (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s") + (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s") ;; display output of latex commands in popup (set-popup-rule! " output\\*$" :size 15) ;; Do not prompt for Master files, this allows auto-insert to add templates to From 581536396f9d3a5623fcd27bd226d612c6a1c7b6 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 14:04:23 +0200 Subject: [PATCH 32/43] Tell emacs how to parse tex files --- modules/lang/latex/config.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index f967e77c5..783c7731e 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -36,6 +36,9 @@ (setq-default TeX-master nil) ;; set-up chktex (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s") + ;; tell emacs how to parse tex files + (add-hook! 'tex-mode-hook + (lambda () (setq ispell-parser 'tex))) ;; display output of latex commands in popup (set-popup-rule! " output\\*$" :size 15) ;; Do not prompt for Master files, this allows auto-insert to add templates to From c5fd541773161b2ced23d3e3f0e97d285759b2c6 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 15:31:35 +0200 Subject: [PATCH 33/43] Implement @hlissner's suggestions --- modules/lang/latex/+latexmk.el | 1 - modules/lang/latex/+ref.el | 4 +--- modules/lang/latex/config.el | 11 ++++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/lang/latex/+latexmk.el b/modules/lang/latex/+latexmk.el index ded53f27f..3e6c52d7a 100644 --- a/modules/lang/latex/+latexmk.el +++ b/modules/lang/latex/+latexmk.el @@ -2,7 +2,6 @@ ;;;###if (featurep! +latexmk) (def-package! auctex-latexmk - :defer t :after latex :init ;; Pass the -pdf flag when TeX-PDF-mode is active diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index 8c4b552be..7c7d53a6c 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -1,7 +1,6 @@ ;;; lang/latex/+ref.el -*- lexical-binding: t; -*- (def-package! reftex - :defer t :hook (LaTeX-mode . reftex-mode) :config ;; Get ReTeX working with biblatex @@ -36,8 +35,7 @@ (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) ;; set up mode for bib files -(def-package! bibtex - :config +(after! bibtex (setq bibtex-dialect 'biblatex bibtex-align-at-equal-sign t bibtex-text-indentation 20) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 783c7731e..478c8b974 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -37,8 +37,7 @@ ;; set-up chktex (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s") ;; tell emacs how to parse tex files - (add-hook! 'tex-mode-hook - (lambda () (setq ispell-parser 'tex))) + (add-hook! 'tex-mode-hook (setq ispell-parser 'tex)) ;; display output of latex commands in popup (set-popup-rule! " output\\*$" :size 15) ;; Do not prompt for Master files, this allows auto-insert to add templates to @@ -47,7 +46,8 @@ (cl-find-if #'byte-code-function-p find-file-hook) 'local)) ;; Enable rainbow mode after applying styles to the buffer - (add-hook! 'TeX-update-style-hook #'rainbow-delimiters-mode) + (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) + (add-hook 'TeX-mode-hook #'visual-line-mode) (when (featurep! :feature spellcheck) (add-hook 'TeX-mode-hook #'flyspell-mode :append))) @@ -55,9 +55,7 @@ (def-package! tex-fold :hook (TeX-mode . TeX-fold-mode)) -(def-package! latex - :defer t - :config +(after! latex (setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks. '(LaTeX-section-heading LaTeX-section-title @@ -72,7 +70,6 @@ ;; set-up preview package (def-package! preview - :defer t :hook (LaTeX-mode . LaTeX-preview-setup) :config (setq-default preview-scale 1.4 From 03e7d1a66ca6a08ba52c1a837256ab0fd7ef48db Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 15:38:32 +0200 Subject: [PATCH 34/43] Sort entries and add `parencite` Co-authored by: @UndeadKernel --- modules/lang/latex/+ref.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index 7c7d53a6c..048b9048c 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -6,13 +6,14 @@ ;; Get ReTeX working with biblatex ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 (setq reftex-cite-format - '((?t . "\\textcite[]{%l}") - (?a . "\\autocite[]{%l}") + '((?a . "\\autocite[]{%l}") + (?b . "\\blockcquote[]{%l}{}") (?c . "\\cite[]{%l}") - (?s . "\\smartcite[]{%l}") (?f . "\\footcite[]{%l}") (?n . "\\nocite{%l}") - (?b . "\\blockcquote[]{%l}{}")) + (?p . "\\parencite[]{%l}") + (?s . "\\smartcite[]{%l}") + (?t . "\\textcite[]{%l}")) reftex-plug-into-AUCTeX t reftex-toc-split-windows-fraction 0.3) (unless (string-empty-p +latex-bibtex-file) From 6b58c8d4512c811e65458ff88e141117c8f4949b Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 16:22:47 +0200 Subject: [PATCH 35/43] De-tangle company-auctex and company-math Co-authored-by: Henrik Lissner --- modules/lang/latex/config.el | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 478c8b974..031dca7e4 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -76,23 +76,28 @@ preview-scale-function (lambda () (* (/ 10.0 (preview-document-pt)) preview-scale)))) -;; set-up company-auctex, but with company-math supplying the math symbols backend +(defvar +latex--company-backends nil) + (def-package! company-auctex :when (featurep! :completion company) - :after latex - :config - (def-package! company-math - :defer t - ;; We can't use the `set-company-backend!' because Auctex reports its - ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is - ;; not something `set-company-backend!' anticipates (and shouldn't have to!) - :init - (add-hook! LaTeX-mode - (setq-local company-backends - (append '((company-math-symbols-latex - company-auctex-macros - company-auctex-environments)) - company-backends))))) + :defer t + :init + (add-to-list '+latex--company-backends 'company-auctex-environments nil #'eq) + (add-to-list '+latex--company-backends 'company-auctex-macros nil #'eq)) + +(def-package! company-math + :when (featurep! :completion company) + :defer t + :init + (add-to-list '+latex--company-backends 'company-math-symbols-latex nil #'eq)) + +(when +latex--company-backends + ;; We can't use the `set-company-backend!' because Auctex reports its + ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is + ;; not something `set-company-backend!' anticipates (and shouldn't have to!) + (add-hook! 'LaTeX-mode-hook + (add-to-list (make-local-variable 'company-backends) + +latex--company-backends))) ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap From c1381d7747637ecf2ad9c3c8157db95027545b03 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 16:58:26 +0200 Subject: [PATCH 36/43] Defer company-reftex --- modules/lang/latex/+ref.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index 048b9048c..02f5e6904 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -31,8 +31,8 @@ ;; set up completion for citations and references (def-package! company-reftex :when (featurep! :completion company) - :after reftex - :config + :defer t + :init (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) ;; set up mode for bib files From f497d1bf0d2e57a6661aea8075ecadb3a4fcd729 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 16:59:15 +0200 Subject: [PATCH 37/43] Fix regression --- modules/lang/latex/+viewers.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/latex/+viewers.el b/modules/lang/latex/+viewers.el index 2f0519a0e..a4522be30 100644 --- a/modules/lang/latex/+viewers.el +++ b/modules/lang/latex/+viewers.el @@ -1,7 +1,6 @@ ;;; lang/latex/+viewers.el -*- lexical-binding: t; -*- ;; Update PDF buffers after successful LaTeX runs -(add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer) (when (featurep! +okular) ;; Configure Okular as viewer. Including a bug fix @@ -20,4 +19,5 @@ ;; Or PDF-tools, but only if the module is also loaded (when (and (featurep! :tools pdf) (featurep! +pdf-tools)) - (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))) + (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) + (add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer)) From c502fe6328ec3940c13879db4abff2cb079eae14 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 17:20:52 +0200 Subject: [PATCH 38/43] Added +unicode-math flag --- modules/lang/latex/config.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 031dca7e4..052422ebf 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -89,13 +89,18 @@ :when (featurep! :completion company) :defer t :init - (add-to-list '+latex--company-backends 'company-math-symbols-latex nil #'eq)) + (if (featurep! +unicode-math) + (add-to-list '+latex--company-backends 'company-math-symbols-unicode nil #'eq) + (add-to-list '+latex--company-backends 'company-math-symbols-latex nil #'eq))) (when +latex--company-backends ;; We can't use the `set-company-backend!' because Auctex reports its ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is ;; not something `set-company-backend!' anticipates (and shouldn't have to!) (add-hook! 'LaTeX-mode-hook + (when (featurep! +unicode-math) + (setq-local company-math-allow-unicode-symbols-in-faces (quote (tex-math font-latex-math-face))) + (setq-local company-math-disallow-unicode-symbols-in-faces nil)) (add-to-list (make-local-variable 'company-backends) +latex--company-backends))) From eeb10ae6cdc32b9f67a6fab10350d372ff506c6f Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 17:25:27 +0200 Subject: [PATCH 39/43] Put comment in right place --- modules/lang/latex/+viewers.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/lang/latex/+viewers.el b/modules/lang/latex/+viewers.el index a4522be30..46a4a1b2c 100644 --- a/modules/lang/latex/+viewers.el +++ b/modules/lang/latex/+viewers.el @@ -1,7 +1,5 @@ ;;; lang/latex/+viewers.el -*- lexical-binding: t; -*- -;; Update PDF buffers after successful LaTeX runs - (when (featurep! +okular) ;; Configure Okular as viewer. Including a bug fix ;; (https://bugs.kde.org/show_bug.cgi?id=373855) @@ -20,4 +18,5 @@ (when (and (featurep! :tools pdf) (featurep! +pdf-tools)) (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) + ;; Update PDF buffers after successful LaTeX runs (add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer)) From 037f872a023e2ad8b3b9197c795366205dc51ce1 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Thu, 19 Jul 2018 12:10:41 +0200 Subject: [PATCH 40/43] Fix final regression (hopefully!) --- modules/lang/latex/config.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 052422ebf..0801e3adb 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -93,16 +93,19 @@ (add-to-list '+latex--company-backends 'company-math-symbols-unicode nil #'eq) (add-to-list '+latex--company-backends 'company-math-symbols-latex nil #'eq))) +(if (featurep! +unicode-math) +(defun math-setup () + (setq-local company-math-allow-unicode-symbols-in-faces (quote (tex-math font-latex-math-face))) + (setq-local company-math-disallow-unicode-symbols-in-faces nil) + (add-to-list (make-local-variable 'company-backends) +latex--company-backends)) +(defun math-setup () + (add-to-list (make-local-variable 'company-backends) +latex--company-backends))) + (when +latex--company-backends ;; We can't use the `set-company-backend!' because Auctex reports its ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is ;; not something `set-company-backend!' anticipates (and shouldn't have to!) - (add-hook! 'LaTeX-mode-hook - (when (featurep! +unicode-math) - (setq-local company-math-allow-unicode-symbols-in-faces (quote (tex-math font-latex-math-face))) - (setq-local company-math-disallow-unicode-symbols-in-faces nil)) - (add-to-list (make-local-variable 'company-backends) - +latex--company-backends))) + (add-hook! 'LaTeX-mode-hook 'math-setup)) ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap From 5d361534ce97085113fab6794f9e693794020704 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 19 Jul 2018 15:43:30 +0200 Subject: [PATCH 41/43] Move set-company-backend! into reftex config Since the company-reftex config doesn't do anything else, and set-company-backend! is an autodef function, it will no-op if :completion company isn't enabled. --- modules/lang/latex/+ref.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index 02f5e6904..6235fec06 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -3,6 +3,8 @@ (def-package! reftex :hook (LaTeX-mode . reftex-mode) :config + ;; set up completion for citations and references + (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations) ;; Get ReTeX working with biblatex ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 (setq reftex-cite-format @@ -28,13 +30,6 @@ :e "q" #'kill-buffer-and-window :e "ESC" #'kill-buffer-and-window))) -;; set up completion for citations and references -(def-package! company-reftex - :when (featurep! :completion company) - :defer t - :init - (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) - ;; set up mode for bib files (after! bibtex (setq bibtex-dialect 'biblatex From 66679d2f7b27038d85de131d0b23fe88e9ec0552 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 19 Jul 2018 15:44:23 +0200 Subject: [PATCH 42/43] Remove (ivy|helm)-bibtex def-package's ivy-bibtex and helm-bibtex are autoloaded by their respective packages' autoloads files, so their def-package! blocks are unnecessary. --- modules/lang/latex/+ref.el | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el index 6235fec06..52ec92937 100644 --- a/modules/lang/latex/+ref.el +++ b/modules/lang/latex/+ref.el @@ -37,14 +37,6 @@ bibtex-text-indentation 20) (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) -(def-package! ivy-bibtex - :when (featurep! :completion ivy) - :commands ivy-bibtex) - -(def-package! helm-bibtex - :when (featurep! :completion helm) - :commands helm-bibtex) - (after! bibtex-completion (unless (string-empty-p +latex-bibtex-file) (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file))))) From 9a23492888f09d1414431b465916ed23cc2a9ffa Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 23 Jul 2018 15:47:40 +0200 Subject: [PATCH 43/43] Removed unicode-math setup --- modules/lang/latex/config.el | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 0801e3adb..0109a2cb8 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -89,23 +89,13 @@ :when (featurep! :completion company) :defer t :init - (if (featurep! +unicode-math) - (add-to-list '+latex--company-backends 'company-math-symbols-unicode nil #'eq) - (add-to-list '+latex--company-backends 'company-math-symbols-latex nil #'eq))) - -(if (featurep! +unicode-math) -(defun math-setup () - (setq-local company-math-allow-unicode-symbols-in-faces (quote (tex-math font-latex-math-face))) - (setq-local company-math-disallow-unicode-symbols-in-faces nil) - (add-to-list (make-local-variable 'company-backends) +latex--company-backends)) -(defun math-setup () - (add-to-list (make-local-variable 'company-backends) +latex--company-backends))) + (add-to-list '+latex--company-backends '+latex-symbols-company-backend nil #'eq)) (when +latex--company-backends ;; We can't use the `set-company-backend!' because Auctex reports its ;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is ;; not something `set-company-backend!' anticipates (and shouldn't have to!) - (add-hook! 'LaTeX-mode-hook 'math-setup)) + (add-hook! 'LaTeX-mode-hook (add-to-list (make-local-variable 'company-backends) +latex--company-backends))) ;; Nicely indent lines that have wrapped when visual line mode is activated (def-package! adaptive-wrap