diff --git a/layers/+lang/latex/README.org b/layers/+lang/latex/README.org index 0501a677bd49..ce696e0a17d3 100644 --- a/layers/+lang/latex/README.org +++ b/layers/+lang/latex/README.org @@ -1,4 +1,4 @@ -#+TITLE: LaTeX layer +#+TITLE: LaTeX Layer for Spacemacs #+HTML_HEAD_EXTRA: [[file:img/latex.png]] @@ -12,8 +12,11 @@ - [[Previewing][Previewing]] - [[Build command][Build command]] - [[Auto-fill][Auto-fill]] + - [[Magic latex buffer][Magic latex buffer]] - [[Keybindings][Keybindings]] + - [[AucTeX][AucTeX]] - [[RefTeX][RefTeX]] + - [[reftex TOC mode][reftex TOC mode]] * Description This layer adds support for LaTeX files with [[https://savannah.gnu.org/projects/auctex/][AucTeX]]. @@ -23,7 +26,6 @@ This layer adds support for LaTeX files with [[https://savannah.gnu.org/projects - Auto-completion with [[https://github.com/alexeyr/company-auctex][company-auctex]] - Tags navigation on ~%~ with [[https://github.com/redguardtoo/evil-matchit][evil-matchit]] - Labels, references, citations and index entries management with [[http://www.gnu.org/software/emacs/manual/html_node/reftex/index.html][RefTeX]] - * Install ** Layer To use this contribution add it to your =~/.spacemacs= @@ -48,6 +50,10 @@ under =dotspacemacs/user-config=: Then when you open up a compiled PDF, the preview will update automatically when you recompile. +Font-locking for semi-WYSIWYG editing made with magic-latex-buffer can be customized. + + + ** Build command A build command can be specified via the layer variable =latex-build-command=. @@ -74,55 +80,128 @@ The variable =latex-nofill-env= provide the list of environment names where (latex :variables latex-enable-auto-fill t)) #+END_SRC +** Magic latex buffer +Font-locking using magic latex buffer can be customized with the following variables (all toggled by default): + +=magic-latex-enable-block-highlight t= +=magic-latex-enable-suscript t= +=magic-latex-enable-pretty-symbols t= +=magic-latex-enable-block-align t= +=magic-latex-enable-inline-image t= + * Keybindings +** AucTeX + +| Key Binding | Description | +|---------------+--------------------------------------------------| +| ~SPC m %~ | comment or uncomment paragraph | +| ~SPC m ;~ | comment or uncomment region | +| ~SPC m a m~ | set master in multifile documents | +| ~SPC m c :~ | next command on master | +| ~SPC m c b~ | next commmand on buffer | +| ~SPC m c c~ | build/compile/typeset | +| ~SPC m c r~ | next command on region | +| ~SPC m c s b~ | TeX-command-select-buffer | +| ~SPC m c s r~ | TeX-command-select-region | +| ~SPC m c s~ | Tex-command-select-master | +| ~SPC m c v~ | compile document until error or finished | +| ~SPC m d c~ | remove generated intermediate files | +| ~SPC m d e~ | overview errors/warnings | +| ~SPC m d k~ | kill currently running external application | +| ~SPC m d n~ | jump to next error of last LaTeX run | +| ~SPC m d N~ | jump to previous error of last run | +| ~SPC m d o~ | makes bottom line visible of the output buffer | +| ~SPC m d r~ | remove buffer information and reapply style hook | +| ~SPC m g h~ | go to master file | +| ~SPC m h a~ | help aucTeX | +| ~SPC m h d~ | help TeX | +| ~SPC m h p~ | help preview | +| ~SPC m i c~ | complete macro | +| ~SPC m i E~ | close environment | +| ~SPC m i e~ | prompt for environment to insert | +| ~SPC m i i~ | insert item in itemize-like environment | +| ~SPC m i m~ | insert macro | +| ~SPC m m e~ | mark environment | +| ~SPC m m p~ | pin region | +| ~SPC m m s~ | mark section | +| ~SPC m p b~ | preview buffer | +| ~SPC m p c b~ | remove preview from buffer | +| ~SPC m p c d~ | remove preview from document | +| ~SPC m p c p~ | remove preview at point | +| ~SPC m p c r~ | remove preview from region | +| ~SPC m p c s~ | remove preview from section | +| ~SPC m p d~ | generate preview for document | +| ~SPC m p e~ | generate preview for environment | +| ~SPC m p F~ | generate preview cache preamble off | +| ~SPC m p f~ | generate preview cache preamble | +| ~SPC m p p~ | generate preview at point | +| ~SPC m p r~ | generate preview for region | +| ~SPC m p s~ | generate preview for section | +| ~SPC m s~ | save all buffers known to the current document | +| ~SPC m t $~ | toggle math mode | +| ~SPC m v~ | start a viewer without prompting | +| ~SPC m x b~ | font-bold | +| ~SPC m x B~ | font-medium | +| ~SPC m x c~ | font-typewriter | +| ~SPC m x e~ | font-emphasis | +| ~SPC m x f a~ | font-calligraphic | +| ~SPC m x f c~ | font-small-caps | +| ~SPC m x f f~ | font-sans-serif | +| ~SPC m x f n~ | font-normal | +| ~SPC m x f r~ | font-serif | +| ~SPC m x f u~ | font-upright | +| ~SPC m x i~ | font-italic | +| ~SPC m x o~ | font-slanted | +| ~SPC m x r~ | font-delete | + -| Key Binding | Description | -|---------------+-------------------------------------| -| ~SPC m -~ | open output buffer | -| ~SPC m b~ | build | -| ~SPC m c~ | close LaTeX environment | -| ~SPC m C~ | TeX command on master file | -| ~SPC m e~ | insert LaTeX environment | -| ~SPC m i~ | insert =\item= | -| ~SPC m h d~ | TeX documentation, can be very slow | -| ~SPC m p r~ | preview region | -| ~SPC m p b~ | preview buffer | -| ~SPC m p d~ | preview document | -| ~SPC m p e~ | preview environment | -| ~SPC m p s~ | preview section | -| ~SPC m p p~ | preview at point | -| ~SPC m p f~ | cache preamble for preview | -| ~SPC m p c~ | clear previews | -| ~SPC m v~ | view | -| ~SPC m x b~ | make font bold | -| ~SPC m x B~ | make font medium weight | -| ~SPC m x c~ | make font monospaced (for code) | -| ~SPC m x e~ | make font emphasised | -| ~SPC m x i~ | make font italic | -| ~SPC m x o~ | make font oblique | -| ~SPC m x r~ | remove font properties | -| ~SPC m x f a~ | use calligraphic font | -| ~SPC m x f c~ | use small-caps font | -| ~SPC m x f f~ | use sans serif font | -| ~SPC m x f n~ | use normal font | -| ~SPC m x f r~ | use serif font | -| ~SPC m x f u~ | use upright font | ** RefTeX -| Key Binding | Description | -|---------------+---------------------------------------| -| ~SPC m r c~ | reftex-citation | -| ~SPC m r g~ | reftex-grep-document | -| ~SPC m r i~ | reftex-index-selection-or-word | -| ~SPC m r I~ | reftex-display-index | -| ~SPC m r TAB~ | reftex-index | -| ~SPC m r l~ | reftex-label | -| ~SPC m r p~ | reftex-index-phrase-selection-or-word | -| ~SPC m r P~ | reftex-index-visit-phrases-buffer | -| ~SPC m r r~ | reftex-reference | -| ~SPC m r s~ | reftex-search-document | -| ~SPC m r t~ | reftex-toc | -| ~SPC m r T~ | reftex-toc-recenter | -| ~SPC m r v~ | reftex-view-crossref | -| | | +| Key Binding | Description | +|---------------+------------------------------------------------------------------------------------| +| ~SPC m r g b~ | create or go to the index phrases file | +| ~SPC m r g l~ | prompt for a label (with completion) and jump to the location of this label | +| ~SPC m r i a~ | index all index phrases in the current region | +| ~SPC m r i c~ | make a citation using BibTeX database files | +| ~SPC m r i i~ | query for an index macro and insert it along with its arguments | +| ~SPC m r i I~ | put current selection or the word near point into the default index macro | +| ~SPC m r i l~ | insert a unique label | +| ~SPC m r i p~ | add current selection or the word at point to the phrases buffer | +| ~SPC m r i r~ | start a selection process to select a label and insert a reference to it | +| ~SPC m r m t~ | create tags file by running etags on the current document | +| ~SPC m r m b~ | create a new BibTeX database file with all entries referenced in document | +| ~SPC m r n l~ | renumber all simple labels in the document to make them sequentially | +| ~SPC m r p d~ | reparse entire documents | +| ~SPC m r p f~ | parse one file | +| ~SPC m r s a~ | search again | +| ~SPC m r s d~ | produce a list of all duplicate labels in the document | +| ~SPC m r s d~ | regexp search through all files of the current document | +| ~SPC m r s g~ | run grep query through all files related to this document | +| ~SPC m r s q~ | run a query-replace-regexp of FROM with TO over the entire document | +| ~SPC m r v c~ | view cross reference of macro at point | +| ~SPC m r v i~ | display a buffer with an index compiled for the current document | +| ~SPC m r v t~ | display the table of contents for the current document | +| ~SPC m r v T~ | display the table of contents and highlight line corresponding to current position | +| ~SPC m r w~ | save all document buffers | + +*** reftex TOC mode + +| Key Binding | Description | +|---------------+--------------------------------------------------| +| ~SPC m d~ | demote section at point | +| ~SPC m e t~ | replace current buffer with text of visited file | +| ~SPC m g e~ | switch to TOC of external document | +| ~SPC m g l~ | go to doc location in other window. TOC stays | +| ~SPC m g L~ | doc location in other window. TOC is hidden | +| ~SPC m m d~ | regenerate toc buffer parsing entire document | +| ~SPC m m f~ | regenerate toc buffer parsing file | +| ~SPC m p~ | promote section at point | +| ~SPC m r l~ | rename selected label in TOC | +| ~SPC m t b~ | inclusion of boundaries in toc buffer | +| ~SPC m t i~ | inclusion of index in toc buffer | +| ~SPC m t l~ | inclusion of labels in toc buffer | +| ~SPC m q~ | hide TOC and do not move point | +| ~SPC m v c~ | show where =reftex-toc= was called from | +| ~SPC m v i~ | view index like =reftex-display-index= | +| ~SPC m v l~ | view document location in other window | diff --git a/layers/+lang/latex/config.el b/layers/+lang/latex/config.el index e77a9f4029dc..d1f61e8df5d6 100644 --- a/layers/+lang/latex/config.el +++ b/layers/+lang/latex/config.el @@ -16,7 +16,7 @@ (spacemacs|defvar-company-backends LaTeX-mode) (defvar latex-build-command (if (executable-find "latexmk") "LatexMk" "LaTeX") - "The default command to use with `SPC m b'") + "The default command to use with `SPC m c c'") (defvar latex-enable-auto-fill t "Whether to use auto-fill-mode or not in tex files.") @@ -27,13 +27,4 @@ "align*" "tabular" "tikzpicture") - "List of environment names in which `auto-fill-mode' will be inhibited.") - -;; Command prefixes -;; no supported -;; (setq auctex/key-binding-prefixes '()) -;; (push (cons "mp" "LaTeX Preview") auctex/key-binding-prefixes) -;; (push (cons "mr" "RefTeX") auctex/key-binding-prefixes) -;; (mapc (lambda (x) (spacemacs/declare-prefix (car x) (cdr x))) -;; auctex/key-binding-prefixes) - + "List of environment names in which `auto-fill-mode' will be inhibited.") \ No newline at end of file diff --git a/layers/+lang/latex/extensions.el b/layers/+lang/latex/extensions.el index 9919e0a9d3ab..c18e967758ac 100644 --- a/layers/+lang/latex/extensions.el +++ b/layers/+lang/latex/extensions.el @@ -14,21 +14,52 @@ (defun latex/init-emacs-builtin-reftex () "Initialize reftex" - + + (add-hook 'reftex-toc-mode-hook 'turn-on-evil-mode) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-plug-into-AUCTeX '(nil nil t t t)) - (spacemacs/set-leader-keys-for-major-mode 'latex-mode - "rc" 'reftex-citation - "rg" 'reftex-grep-document - "ri" 'reftex-index-selection-or-word - "rI" 'reftex-display-index - "r TAB" 'reftex-index - "rl" 'reftex-label - "rp" 'reftex-index-phrase-selection-or-word - "rP" 'reftex-index-visit-phrases-buffer - "rr" 'reftex-reference - "rs" 'reftex-search-document - "rt" 'reftex-toc - "rT" 'reftex-toc-recenter - "rv" 'reftex-view-crossref)) + "ric" 'reftex-citation + "rsq" 'reftex-query-replace-document + "rsg" 'reftex-grep-document + "riI" 'reftex-index-selection-or-word + "rvi" 'reftex-display-index + "rii" 'reftex-index + "ril" 'reftex-label + "rip" 'reftex-index-phrase-selection-or-word + "rgb" 'reftex-index-visit-phrases-buffer + "rir" 'reftex-reference + "rsd" 'reftex-search-document + "ria" 'reftex-index-phrases-apply-to-region ;; + "rvt" 'reftex-toc + "rvT" 'reftex-toc-recenter + "rsd" 'reftex-find-duplicate-labels + "rit" 'reftex-create-tags-file + "rmb" 'reftex-create-bibtex-file + "rpf" 'reftex-parse-one + "rpd" 'reftex-parse-all + "rsa" 'tags-query-replace + "rw" 'reftex-save-all-document-buffers + "rns" 'reftex-renumber-simple-labels + "rgl" 'reftex-goto-label + "rvc" 'reftex-view-crossref) + ; ======= + ; = TOC = + ; ======= + (spacemacs/set-leader-keys-for-major-mode 'reftex-toc-mode + "vl" 'reftex-toc-view-line + "gl" 'reftex-toc-goto-line + "gL" 'reftex-toc-goto-line-and-hide + "vc" 'reftex-toc-show-calling-point + "q" 'reftex-toc-quit + "p" 'reftex-toc-promote + "d" 'reftex-toc-demote + "rl" 'reftex-toc-rename-label + "vi" 'reftex-toc-display-index + "ge" 'reftex-toc-external + "et" 'revert-buffer + "md" 'reftex-toc-Rescan + "tb" 'reftex-toc-toggle-file-boundary + "tl" 'reftex-toc-toggle-labels + "ti" 'reftex-toc-toggle-index + )) diff --git a/layers/+lang/latex/funcs.el b/layers/+lang/latex/funcs.el index 0abd6b647fbc..1856a699e554 100644 --- a/layers/+lang/latex/funcs.el +++ b/layers/+lang/latex/funcs.el @@ -49,7 +49,7 @@ the automatic filling of the current paragraph." ;; Rebindings for TeX-font (defun latex/font-bold () (interactive) (TeX-font nil ?\C-b)) (defun latex/font-medium () (interactive) (TeX-font nil ?\C-m)) -(defun latex/font-code () (interactive) (TeX-font nil ?\C-t)) +(defun latex/font-typewriter () (interactive) (TeX-font nil ?\C-t)) (defun latex/font-emphasis () (interactive) (TeX-font nil ?\C-e)) (defun latex/font-italic () (interactive) (TeX-font nil ?\C-i)) (defun latex/font-clear () (interactive) (TeX-font nil ?\C-d)) @@ -58,5 +58,5 @@ the automatic filling of the current paragraph." (defun latex/font-sans-serif () (interactive) (TeX-font nil ?\C-f)) (defun latex/font-normal () (interactive) (TeX-font nil ?\C-n)) (defun latex/font-serif () (interactive) (TeX-font nil ?\C-r)) -(defun latex/font-oblique () (interactive) (TeX-font nil ?\C-s)) +(defun latex/font-slanted () (interactive) (TeX-font nil ?\C-s)) (defun latex/font-upright () (interactive) (TeX-font nil ?\C-u)) diff --git a/layers/+lang/latex/packages.el b/layers/+lang/latex/packages.el index c8f730e2eda2..ca6653365f4b 100644 --- a/layers/+lang/latex/packages.el +++ b/layers/+lang/latex/packages.el @@ -19,6 +19,7 @@ evil-matchit flycheck flyspell + magic-latex-buffer smartparens typo yasnippet @@ -49,57 +50,125 @@ (progn ;; Key bindings for plain TeX (spacemacs/set-leader-keys-for-major-mode 'tex-mode - "\\" 'TeX-insert-macro - "b" 'latex/build - "C" 'TeX-command-master - "v" 'TeX-view - - "xb" 'latex/font-bold - "xc" 'latex/font-code - "xe" 'latex/font-emphasis - "xi" 'latex/font-italic - "xr" 'latex/font-clear - "xo" 'latex/font-oblique - "xfc" 'latex/font-small-caps - "xff" 'latex/font-sans-serif - "xfr" 'latex/font-serif) - (spacemacs/declare-prefix-for-mode 'tex-mode "mx" "tex/text") - (spacemacs/declare-prefix-for-mode 'tex-mode "mx" "tex/fonts") - - ;; Key bindings for LaTeX - (spacemacs/set-leader-keys-for-major-mode 'latex-mode - "\\" 'TeX-insert-macro - "-" 'TeX-recenter-output-buffer - "b" 'latex/build - "c" 'LaTeX-close-environment - "C" 'TeX-command-master - "e" 'LaTeX-environment - ;; TeX-doc is a very slow function - "hd" 'TeX-doc - "i" 'LaTeX-insert-item - "pb" 'preview-buffer - "pc" 'preview-clearout - "pd" 'preview-document - "pe" 'preview-environment - "pf" 'preview-cache-preamble - "pp" 'preview-at-point - "pr" 'preview-region - "ps" 'preview-section - "v" 'TeX-view - - "xb" 'latex/font-bold - "xB" 'latex/font-medium - "xc" 'latex/font-code - "xe" 'latex/font-emphasis - "xi" 'latex/font-italic - "xo" 'latex/font-oblique - "xr" 'latex/font-clear - "xfa" 'latex/font-calligraphic - "xfc" 'latex/font-small-caps - "xff" 'latex/font-sans-serif - "xfn" 'latex/font-normal - "xfr" 'latex/font-serif - "xfu" 'latex/font-upright) + ;; build/compile/typeset + "b" 'bq-latex/build ; left for historical reason + "cc" 'bq-latex/build + "c:" 'TeX-command-master + "cr" 'TeX-command-region + "cb" 'TeX-command-buffer + ;;"cs" 'Tex-command-sentinel + "dc" 'TeX-clean + "de" 'TeX-error-overview + "dk" 'TeX-kill-job + "do" 'TeX-recenter-output-buffer + "dn" 'TeX-next-error + "dN" 'TeX-previous-error + "gh" 'TeX-home-buffer + ;; TeX-doc is a very slow function + "hd" 'TeX-doc + "im" 'TeX-insert-macro + "v" 'TeX-view + + "xb" 'latex/font-bold + "xc" 'latex/font-code + "xe" 'latex/font-emphasis + "xi" 'latex/font-italic + "xr" 'latex/font-clear + "xo" 'latex/font-oblique + "xfc" 'latex/font-small-caps + "xff" 'latex/font-sans-serif + "xfr" 'latex/font-serif) + (spacemacs/declare-prefix-for-mode 'tex-mode "mx" "tex/text") + (spacemacs/declare-prefix-for-mode 'tex-mode "mx" "tex/fonts") + + ;; Key bindings for LaTeX + (spacemacs/set-leader-keys-for-major-mode 'latex-mode + ; ============ + ; = comments = + ; ============ + "%" 'TeX-comment-or-uncomment-paragraph + ";" 'TeX-comment-or-uncomment-region + ; ====================== + ; = Controlling the output = + ; ====================== + "dk" 'TeX-kill-job + "do" 'TeX-recenter-output-buffer + "gh" 'TeX-home-buffer + ; ====================== + ; = Starting a command = + ; ====================== + "a" 'TeX-master-file-ask + "cc" 'bq-latex/build + "c:" 'TeX-command-master + "cb" 'TeX-command-buffer + "cr" 'TeX-command-region + "cs:" 'Tex-command-select-master + "csb" 'TeX-command-select-buffer + "csr" 'TeX-command-select-region + "cv" 'TeX-command-run-all + "s" 'TeX-save-document + "v" 'TeX-view + ; ============= + ; = Debugging = + ; ============= + "dc" 'TeX-clean + "de" 'TeX-error-overview + "dn" 'TeX-next-error + "dN" 'TeX-previous-error + "dr" 'TeX-normal-mode + ; ================= + ; = Documentation = + ; ================= + "ha" 'TeX-goto-info-page + "hd" 'TeX-doc + "hp" 'preview-goto-info-page + ; ==================== + ; = Editing document = + ; ==================== + "ic" 'TeX-complete-symbol + "ie" 'LaTeX-environment + "iE" 'LaTeX-close-environment + "ii" 'LaTeX-insert-item + "im" 'TeX-insert-macro + "t$" 'LaTeX-math-mode + ; ========= + ; = Marking = + ; ========= + "ms" 'LaTeX-mark-section + "me" 'LaTeX-mark-environment + "mp" 'TeX-pin-region + ; ============ + ; = Previewing = + ; ============ + "pb" 'preview-buffer + "pcb" 'preview-clearout-buffer + "pcd" 'preview-clearout-document + "pcp" 'preview-clearout-at-point + "pcr" 'preview-clearout + "pcs" 'preview-clearout-section + "pd" 'preview-document + "pe" 'preview-environment + "pf" 'preview-cache-preamble + "pF" 'preview-cache-preamble-off + "pp" 'preview-at-point + "pr" 'preview-region + "ps" 'preview-section + ; =============== + ; = Remap fonts = + ; =============== + "xb" 'latex/font-bold + "xB" 'latex/font-medium + "xc" 'latex/font-typewriter + "xe" 'latex/font-emphasis + "xi" 'latex/font-italic + "xo" 'latex/font-slanted + "xr" 'latex/font-delete + "xfa" 'latex/font-calligraphic + "xfc" 'latex/font-small-caps + "xff" 'latex/font-sans-serif + "xfn" 'latex/font-normal + "xfr" 'latex/font-serif + "xfu" 'latex/font-upright) (spacemacs/declare-prefix-for-mode 'latex-mode "mx" "latex/text") (spacemacs/declare-prefix-for-mode 'latex-mode "mx" "latex/fonts")))) @@ -154,3 +223,16 @@ (defun latex/post-init-which-key () (push '("\\`latex/font-\\(.+\\)\\'" . "\\1") which-key-description-replacement-alist)) + +(defun latex/init-magic-latex-buffer () + (use-package magic-latex-buffer + :defer t + :init + (progn + (setq magic-latex-enable-block-highlight t + magic-latex-enable-suscript t + magic-latex-enable-pretty-symbols t + magic-latex-enable-block-align t + magic-latex-enable-inline-image t))) + (add-hook 'LaTeX-mode-hook 'magic-latex-buffer)) +