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 vsays 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-modeby 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-bracerather than usingelectric-pair-mode. – Andrew Swann Jun 23 '17 at 06:55reftex-isearch-minor-modeinto a hook (specifially thereftex-mode-hook, because that's what I thought it would belong in), but it didn't work (I tried(add-hook 'reftex-mode-hook 'reftex-isearch-minor-mode)). Thankfully I found this comment here, and now it works. Now I'm just wondering whether I just lacked thelambda, or whether the mode I tried to hook this minor-mode into was wrong… And the thing aboutLaTeX-electric-left-right-bracevs.electric-pair-mode: – Lustique Jun 25 '17 at 15:17LaTeX-electric-left-right-brace? I just tried to put(electric-pair-mode 1)more or less at the top (before any (La)TeX-related lines), and now it seems to work. – Lustique Jun 25 '17 at 15:19.emacsfor Dummies’ that explains how certain modes are supposed to be turned on, when to use hooks, etc.? – Lustique Jun 25 '17 at 15:21LaTeX-electric-customization is the one mentioned in the AuCtex documentation, it is the one I use and it works for me. I have not triedelectric-pair-mode– Andrew Swann Jun 26 '17 at 08:07smartparens, mostly for the movement-commands,slurpingandbarfing. These are pretty nice for math-editing. Now I've got another, this time more concrete question though: Did I do something wrong with myreftex-insert-label-flags? Reftex now asks for equation labels, instead of inserting a simple one (the default behaviour, which I like, because I can't think of proper, descriptive labels for all equations I use). Is this optioncase-insensitive(see myEfor example, for which I want this behaviour)? – Lustique Jun 27 '17 at 15:39string-match, see the functionreftex-typekey-check, whose behaviour depends on the value ofcase-fold-search. What happens if you setcase-fold-searchtonil? – Andrew Swann Jun 27 '17 at 17:01equation(ekey) I get the default behaviour again, and for myBspenvironment (which uses theEkey) Reftex asks for a label. Should I setcase-fold-searchtonilin my.emacsnow, should I use a different key or is this a bug in Reftex? As there are then(footnote) andN(endnote) labels (as per the documentation), this doesn't seem like the expected behaviour… – Lustique Jun 27 '17 at 18:35case-fold-search- I would not have expected that as behaviour - they ought to locally switch offcase-fold-searchwhen matching the keys. – Andrew Swann Jun 28 '17 at 07:32