Wie diese Konfigurationsdatei Arbeit zu machen mit use-package
Bezug auf AucTeX
, RefTeX
und LaTeX
. Normalerweise schreibe ich Latex rahter als reine Tex-Dokumente.
Aktuelle Emacs-Konfiguration
(load "auctex.el" nil t t)
(setq-default TeX-master nil) ; by each new fie AUCTEX will ask for a master fie.
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-PDF-mode t)
(setq TeX-show-compilation nil) ; if `t`, automatically shows compilation log
;; (setq-default TeX-engine 'xetex) ; optional
(setq TeX-save-query nil) ; don't prompt for saving the .tex file
;; add makeglossaries to TeX-run-command-list
(eval-after-load "tex" '(add-to-list 'TeX-command-list
'("Makeglossaries" "makeglossaries %s" TeX-run-command nil
(latex-mode)
:help "Run makeglossaries script, which will choose xindy or makeindex") t))
;; Font-lock for AUCTeX
;; Note: '«' and '»' is by pressing 'C-x 8 <' and 'C-x 8 >', respectively
(font-lock-add-keywords 'latex-mode (list (list "\\(«\\(.+?\\|\n\\)\\)\\(+?\\)\\(»\\)" '(1 'font-latex-string-face t) '(2 'font-latex-string-face t) '(3 'font-latex-string-face t))))
;; Add standard Sweave file extensions to the list of files recognized by AUCTeX.
(setq TeX-file-extensions
'("Rnw" "rnw" "Snw" "snw" "tex" "sty" "cls" "ltx" "texi" "texinfo" "dtx"))
(setq LaTeX-babel-hyphen nil) ; Disable language-specific hyphen insertion.
;; `"` expands into csquotes macros (for this to work babel must be loaded after csquotes).
(setq LaTeX-csquotes-close-quote "}"
LaTeX-csquotes-open-quote "\\enquote{")
;; RefTeX
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'LaTeX-mode-hook (function (lambda() (bind-key "C-c C-r" 'reftex-query-replace-document))))
(add-hook 'LaTeX-mode-hook (function (lambda() (bind-key "C-c C-g" 'reftex-grep-document))))
(add-hook 'TeX-mode-hook (lambda () (reftex-isearch-minor-mode))) ; for AUCTeX
;; A user-defined function to delete the current macro in AUCTeX.
;; Note: keybinds won't be added to TeX-mode-hook if not kept at the end of the AUCTeX setup!
(defun TeX-remove-macro ()
"Remove current macro and return `t'. If no macro at point,
return 'nil'."
(interactive)
(when (TeX-current-macro)
(let ((bounds (TeX-find-macro-boundaries))
(brace (save-excursion
(goto-char (1- (TeX-find-macro-end)))
(TeX-find-opening-brace))))
(delete-region (1- (cdr bounds)) (cdr bounds))
(delete-region (car bounds) (1+ brace)))
t))
(add-hook 'LaTeX-mode-hook (lambda () (bind-key "M-DEL" 'TeX-remove-macro)))
Meine Testversion mit Use-Package (funktioniert nicht richtig)
(use-package reftex
:commands turn-on-reftex
:config (setq reftex-plug-into-AUCTeX t))
(use-package tex
:ensure auctex
:init
(progn
;; A function to delete the current macro in AUCTeX.
;; Note: keybinds won't be added to TeX-mode-hook if not kept at the end of the AUCTeX setup!
(defun TeX-remove-macro ()
"Remove current macro and return TRUE, If no macro at point, return Nil."
(interactive)
(when (TeX-current-macro)
(let ((bounds (TeX-find-macro-boundaries))
(brace (save-excursion
(goto-char (1- (TeX-find-macro-end)))
(TeX-find-opening-brace))))
(delete-region (1- (cdr bounds)) (cdr bounds))
(delete-region (car bounds) (1+ brace)))
t))
)
:bind (:map LaTeX-mode-map
("M-<delete>" . TeX-remove-macro)
("C-c C-r" . reftex-query-replace-document)
("C-c C-g" . reftex-grep-document))
:config
(progn
(add-to-list 'TeX-command-list
'("Makeglossaries" "makeglossaries %s" TeX-run-command nil
(latex-mode)
:help "Run makeglossaries script, which will choose xindy or makeindex") t)
(setq-default TeX-master nil) ; by each new fie AUCTEX will ask for a master fie.
(setq TeX-auto-save t)
(setq TeX-save-query nil) ; don't prompt for saving the .tex file
(setq TeX-parse-self t)
(setq-default TeX-PDF-mode t)
(setq TeX-show-compilation nil) ; if `t`, automatically shows compilation log
(setq-default TeX-engine 'xetex) ; optional
(setq LaTeX-babel-hyphen nil) ; Disable language-specific hyphen insertion.
;; `"` expands into csquotes macros (for this to work, babel pkg must be loaded after csquotes pkg).
(setq LaTeX-csquotes-close-quote "}"
LaTeX-csquotes-open-quote "\\enquote{")
;; Font-lock for AUCTeX
;; Note: '«' and '»' is by pressing 'C-x 8 <' and 'C-x 8 >', respectively
(font-lock-add-keywords 'latex-mode (list (list "\\(«\\(.+?\\|\n\\)\\)\\(+?\\)\\(»\\)" '(1 'font-latex-string-face t) '(2 'font-latex-string-face t) '(3 'font-latex-string-face t))))
;; Add standard Sweave file extensions to the list of files recognized by AUCTeX.
(setq TeX-file-extensions
'("Rnw" "rnw" "Snw" "snw" "tex" "sty" "cls" "ltx" "texi" "texinfo" "dtx"))
(add-hook 'TeX-mode-hook (lambda () (reftex-isearch-minor-mode))) ; for AUCTeX
)
:mode ("\\.tex\\'" . latex-mode)
)
Probleme
Wenn ich eine .tex
Datei öffne, wird sie von AucTeX nicht mehr erkannt und es ist keine Schriftsperrung vorhanden.
Nach einigem googeln fand ich eine Handvoll Emacs-Dot-File-Setups, aber die Vielzahl der Setups ließ mich keine Ahnung, was ich tun sollte, um meine LaTeX-Konfiguration nach use-package
Versen anzupassen, da die verschiedenen Komponenten und Anwendungsfälle (Tex, Latex) komplex sind , auctex, reftex usw.).
Wie sollte meine aktuelle aktuelle Konfiguration an den use-package
Vers angepasst werden ?
Hinweis
- Andere Pakete funktionierten wie erwartet
use-package
, Probleme bisher nur mit Latex - GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK + Version 3.18.9) vom 06.05.2017
use-package
Version: 20170710.1234
progn
erforderlich wäre? Mir ist aufgefallen, dass Sie es bereits entfernt haben. Eine andere Frage ist, welcher Unterschied wäre, wenn ein(defun...)
Makro in den:init
Block oder den:preface
Block eingefügt würde. Wie kann jemand sagen, welches Keyword hier verwendet werden soll?