Como fazer esse arquivo de configuração funcionar use-package
com relação a AucTeX
, RefTeX
e LaTeX
. Eu costumo escrever látex em vez de documentos puramente tex.
Configuração atual do Emacs de trabalho
(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)))
Minha avaliação com use-package (não está funcionando corretamente)
(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)
)
Problemas
Quando abro qualquer .tex
arquivo, ele não é mais reconhecido pelo AucTeX e não há bloqueio de fonte.
Após algumas pesquisas, encontrei várias configurações de arquivos de pontos do Emacs, mas a variedade de configurações me deixou sem noção do que fazer para obter minha configuração de LaTeX ajustada após o use-package
verso, dada a complexidade dos diferentes componentes e casos de uso (tex, latex , auctex, reftex, etc.).
Então, dada a minha configuração atual de trabalho acima, como ela deve ser ajustada para se ajustar ao use-package
versículo?
Nota
- Outros pacotes estavam funcionando conforme o esperado
use-package
, problemas até agora apenas com o látex - GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK + versão 3.18.9) de 06-05-2017
use-package
versão: 20170710.1234
progn
seria necessário usar? Notei que você já o removeu. Outra pergunta: qual seria a diferença se a(defun...)
macro fosse colocada no:init
bloco ou no:preface
bloco? Como alguém pode dizer qual palavra-chave levar aqui?