I currently have an Emacs/AucTeX setup where emacs --debug-init
doesn't throw any errors, but things still don't work as expected. This being the case, I don't really know how to debug my .emacs file without endlessly shuffling lines around, etc.
Two examples of things that don't work as expected:
Although I have activated
reftex-isearch-minor-mode
(C-h v
says it'st
, although the status bar doesn't show it's activated), it only works if after emacs has started, I deactivate, and then activate the mode again viaM-x
.I have activated
electric-pair-mode
, and in a multifile-document the following happens: Typing(
,[
or{
in the main file results in emacs inserting a pair as expected, but typing[
in a non-main file (?) only inserts a single[
, while(
and{
are still inserted as pairs.
So, my question is: How can I get my setup to work correctly, or can someone point me at a resource that tells me how and in what order I have to put in the various setq
, require
, and whatnot lines, so that everything is loaded and hooked
correctly.
Disclaimer №1: I have practically no Lisp knowledge (and I fear it shows…).
Disclaimer №2: I first asked this question on tex.se, but was told it's more appropriate to post it here.
My .emacs
(that is probably a bit messed up) for reference:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq-default TeX-master nil)
(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t) ; Enable parse on save.
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
;; Enable RefTeX automatically in AUCTeX buffers.
(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
(add-hook 'TeX-mode-hook
(lambda ()
(turn-on-reftex)))
(setq reftex-plug-into-AUCTeX t)
;; AUCTeX-related settings.
(add-hook 'LaTeX-mode-hook
(lambda ()
(LaTeX-add-environments
'("satz" LaTeX-env-label)
'("lem" LaTeX-env-label)
'("Bem" LaTeX-env-label)
'("Bsp" LaTeX-env-label)
'("Def" LaTeX-env-label))
(add-to-list 'LaTeX-label-alist '("satz". "thm:"))
(add-to-list 'LaTeX-label-alist '("lem" . "thm:"))
(add-to-list 'LaTeX-label-alist '("Bem" . "rem:"))
(add-to-list 'LaTeX-label-alist '("Bsp" . "exp:"))
(add-to-list 'LaTeX-label-alist '("Def" . "def:"))))
;; RefTeX-related settings.
(setq reftex-label-alist
'(
("satz" ?T "thm:" "~\\ref{%s}" nil ("theorem" "thm."))
("lem" ?T "thm:" "~\\ref{%s}" nil ("lemma" "lem."))
("Bem" ?R "rem:" "~\\ref{%s}" t ("remark" "rmk."))
("Bsp" ?E "exp:" "~\\ref{%s}" t ("example" "exp."))
("Def" ?D "def:" "~\\ref{%s}" t ("definition" "def.")))
reftex-insert-label-flags '("s" "sftTRED"))
(require 'org-table)
;; auctex-latexmk
(require 'auctex-latexmk)
(auctex-latexmk-setup)
(setq auctex-latexmk-inherit-TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq reftex-isearch-minor-mode t)
(add-hook 'LaTeX-mode-hook (lambda ()
(TeX-fold-mode 1)))
;; Markdown-Major-Mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Pandoc-Minor-Mode
(autoload 'pandoc-mode "pandoc-mode" "Minor mode for using Pandoc" t)
(add-hook 'markdown-mode-hook 'pandoc-mode)
;; turn on automatic bracket insertion by pairs. New in emacs 24
(electric-pair-mode 1)
(setq TeX-electric-math t)
(add-hook 'plain-TeX-mode-hook
(lambda () (set (make-variable-buffer-local 'TeX-electric-math)
(cons "$" "$"))))
(add-hook 'LaTeX-mode-hook
(lambda () (set (make-variable-buffer-local 'TeX-electric-math)
(cons "\\(" "\\)"))))
;; turn on highlight matching brackets when cursor is on one
(show-paren-mode 1)
;; (setq show-paren-style 'parenthesis) ; highlight brackets
;; (setq show-paren-style 'expression) ; highlight entire expression
(setq show-paren-style 'mixed) ; highlight brackets if visible, else entire expression
;; The library uniquify overrides Emacs’ default mechanism for making buffer names unique
(require 'uniquify)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-PDF-mode t)
'(ansi-color-names-vector
["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
'(custom-enabled-themes (quote (zenburn)))
'(custom-safe-themes
(quote
("67e998c3c23fe24ed0fb92b9de75011b92f35d3e89344157ae0d544d50a63a72" default)))
'(ispell-dictionary "british")
'(package-selected-packages
(quote
(zenburn-theme auctex-latexmk cdlatex org popup pandoc-mode markdown-mode csharp-mode)))
'(reb-re-syntax (quote string)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
reftex-search-minor-mode
by calling the function of that name, not viasetq
. It would make most sense to put that call in the appropriate major mode hook. (b) for latex you should probably be setting the variableLaTeX-electric-left-right-brace
rather than usingelectric-pair-mode
. – Andrew Swann Jun 23 '17 at 6:55