Emacs: latex-math-preview mode

The preview feature is not the most important imo. However the symbol insertion
is awesome!
master
Pierre Neidhardt 2013-09-30 19:11:22 +02:00
parent d1ba9f507b
commit c6ad6a455b
5 changed files with 105 additions and 75 deletions

View File

@ -49,6 +49,7 @@
(setq kill-whole-line t)
;; Alternative scrolling
;; TODO: add support for DocView
(define-key my-keys-minor-mode-map [next]
(lambda () (interactive)
(condition-case nil (scroll-up)
@ -106,7 +107,7 @@
(setq-default fill-column 80)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; Set man pages to display on a 80 character wide window.
;; Set man pages to display on a 80 character wide window.
(setenv "MANWIDTH" "80")
;; Windmove mode: easy window switching with Shift+arrows.

View File

@ -2,67 +2,66 @@
;; MediaWiki
;;==============================================================================
(if (require 'mediawiki nil t)
(progn
(when (require 'mediawiki nil t)
(setq mediawiki-site-alist
'(
("Wikipedia" "http://en.wikipedia.org/w/" "Ambrevar" "" "Main Page")
("Wikibooks" "http://en.wikibooks.org/w/" "Ambrevar" "" "LaTeX")
("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Mutt")
("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page")
))
(setq mediawiki-site-alist
'(
("Wikipedia" "http://en.wikipedia.org/w/" "Ambrevar" "" "Main Page")
("Wikibooks" "http://en.wikibooks.org/w/" "Ambrevar" "" "LaTeX")
("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Mutt")
("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page")
))
;; Macros.
;; Use C-( stuff C-) to record a macro.
;; Use 'name-last-kbd-macro' to give it a name.
;; Use 'insert-kbd-macro' in your init file to insert the code.
;; You can assign a key: (local-set-key (kbd "C-c a") 'my-macro)
(fset 'ltx-template-source-to-ltx
"\C-@\C-s>\C-m\C-w\C-@\C-s</source\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<source\C-m\C-[Od\C-[[D")
;; Macros.
;; Use C-( stuff C-) to record a macro.
;; Use 'name-last-kbd-macro' to give it a name.
;; Use 'insert-kbd-macro' in your init file to insert the code.
;; You can assign a key: (local-set-key (kbd "C-c a") 'my-macro)
(fset 'ltx-template-source-to-ltx
"\C-@\C-s>\C-m\C-w\C-@\C-s</source\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<source\C-m\C-[Od\C-[[D")
(fset 'ltx-template-source-to-ltxu
"\C-@\C-s>\C-w\C-?\C-m\C-w\C-d\C-@\C-s</source\C-m\C-[Od\C-[[D\C-[[D\C-[[D\C-wltxu\C-i\C-y\C-i\C-k\C-k\C-s<source\C-m\C-[Od\C-[[D")
(fset 'ltx-template-source-to-ltxu
"\C-@\C-s>\C-w\C-?\C-m\C-w\C-d\C-@\C-s</source\C-m\C-[Od\C-[[D\C-[[D\C-[[D\C-wltxu\C-i\C-y\C-i\C-k\C-k\C-s<source\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-ltx
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-ltx
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-env
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxenv\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-env
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxenv\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-pkg
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxpkg\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-pkg
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxpkg\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-par
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxpar\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-tt-to-par
"\C-s<tt\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</tt\C-m\C-[Od\C-[[D\C-[[D\C-wltxpar\C-i\C-y\C-i\C-[d\C-d\C-s<tt\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-ltx
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-ltx
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltx\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-pkg
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxpkg\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-pkg
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxpkg\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-par
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxpar\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-par
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxpar\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-env
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxenv\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
(fset 'ltx-template-code-to-env
"\C-s<code\C-m\C-[Od\C-[[D\C-@\C-[Oc\C-[[C\C-w\C-@\C-s</code\C-m\C-[Od\C-[[D\C-[[D\C-wltxenv\C-i\C-y\C-i\C-[d\C-d\C-s<code\C-m\C-[Od\C-[[D")
;; The url-cookie timer is set to a high value because it seems that once the
;; cookie has been saved, MediaWiki fails to upload files correctly. Is
;; 'url-do-setup' needed to make sure the url-cookie-save-interval variable is
;; taken into account? TODO: does not work.
(setq url-cookie-save-interval 86400)
;; The url-cookie timer is set to a high value because it seems that once the
;; cookie has been saved, MediaWiki fails to upload files correctly. Is
;; 'url-do-setup' needed to make sure the url-cookie-save-interval variable is
;; taken into account? TODO: does not work.
(setq url-cookie-save-interval 86400)
(setq mediawiki-mode-hook
(lambda ()
(visual-line-mode 1)
(turn-off-auto-fill)
(define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)
(local-unset-key (kbd "M-g"))
(local-set-key (kbd "C-c C-d") 'duplicate-line)
;; TODO: Bindings do not work???
;; (local-set-key (kbd "C-c l L") 'ltx-template-source-to-latex)
;; (local-set-key (kbd "C-c l U") 'ltx-template-source-to-usage)
)) ))
(setq mediawiki-mode-hook
(lambda ()
(visual-line-mode 1)
(turn-off-auto-fill)
(define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)
(local-unset-key (kbd "M-g"))
(local-set-key (kbd "C-c C-d") 'duplicate-line)
;; TODO: Bindings do not work???
;; (local-set-key (kbd "C-c l L") 'ltx-template-source-to-latex)
;; (local-set-key (kbd "C-c l U") 'ltx-template-source-to-usage)
)) )

View File

@ -1,10 +1,19 @@
;;==============================================================================
;; TeX and LaTeX
;;==============================================================================
;; The default tex-mode and AucTeX may seem quite disappointing. Let's use
;; custom KISS functions for everything.
;; The magnificent latex-math-preview mode!
(autoload 'latex-math-preview-expression "latex-math-preview" nil t)
(autoload 'latex-math-preview-insert-symbol "latex-math-preview" nil t)
(autoload 'latex-math-preview-save-image-file "latex-math-preview" nil t)
(autoload 'latex-math-preview-beamer-frame "latex-math-preview" nil t)
(autoload 'latex-math-preview-text-symbol-datasets "latex-math-preview" nil t)
(setq latex-math-preview-cache-directory-for-insertion
(concat emacs-cache-folder "latex-math-preview-cache"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CUSTOM
(defcustom tex-compiler nil
@ -221,29 +230,28 @@ properly escaped with double-quotes in case it has spaces."
environment. If bound to M-RET, you can then easily apply this
command on the paragraph at point with M-h M-RET."
(interactive)
(save-excursion
(let (min max case-fold-search)
(if (not (region-active-p))
(let (min max case-fold-search)
(if (not (region-active-p))
(if (string-match "\\item" (buffer-substring (line-beginning-position) (line-end-position)))
(progn
(goto-char (line-end-position))
(newline)
(insert "\\item "))
(goto-char (line-beginning-position))
(insert "\\item")
(just-one-space))
(if (string-match "\\item" (buffer-substring (line-beginning-position) (line-end-position)))
(progn
(goto-char (line-end-position))
(newline)
(insert "\\item "))
(goto-char (line-beginning-position))
(insert "\\item")
(just-one-space))
(replace-regexp "^ *\\([^
(replace-regexp "^ *\\([^
]\\)" "\\\\item \\1" nil (region-beginning) (region-end))
(goto-char (region-end))
(goto-char (line-end-position))
(newline)
(insert "\\end{itemize}")
(goto-char (region-beginning))
(goto-char (line-beginning-position))
(insert "\\begin{itemize}")
(newline)))))
(goto-char (region-end))
(goto-char (line-end-position))
(newline)
(insert "\\end{itemize}")
(goto-char (region-beginning))
(goto-char (line-beginning-position))
(insert "\\begin{itemize}")
(newline))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOKS
@ -257,7 +265,25 @@ properly escaped with double-quotes in case it has spaces."
(set (make-local-variable 'compilation-hide-window) t)
(set (make-local-variable 'use-hard-newlines) t)
(local-set-key (kbd "<f9>") 'tex-pdf-view)
;; (local-set-key (kbd "C-c p") 'latex-math-preview-expression)
;; (local-set-key (kbd "C-c C-p") 'latex-math-preview-save-image-file)
(local-set-key (kbd "C-c j") 'latex-math-preview-insert-symbol)
(local-set-key (kbd "C-c C-j") 'latex-math-preview-last-symbol-again)
;; (local-set-key (kbd "C-c C-b") 'latex-math-preview-beamer-frame)
(tex-set-compiler)))
(add-hook 'latex-mode-hook (lambda () (local-set-key (kbd "M-RET") 'latex-itemize)))
(add-hook 'latex-mode-hook 'turn-on-orgtbl)
;; Extra for latex-math-preview-mode.
;; TODO: latex-math-preview-mode extra does not work.
(require 'latex-math-preview-extra-data nil t)
(add-hook 'latex-mode-hook
(lambda ()
(add-to-list 'latex-math-preview-text-symbol-datasets
latex-math-preview-textcomp-symbol-data)
(add-to-list 'latex-math-preview-text-symbol-datasets
latex-math-preview-pifont-zapf-dingbats-symbol-data)
(add-to-list 'latex-math-preview-text-symbol-datasets
latex-math-preview-pifont-symbol-fonts-symbol-data)))

View File

@ -2,7 +2,7 @@
;; THEME
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; I tried to group colors with some consistency:
;; I've tried to group colors with some consistency:
;; * doc, here-doc, comments, strings
;; * variables, types, constants
;; * preprocessor, functions, keywords, builtins
@ -34,6 +34,10 @@
(set-face-foreground 'error "red")
(set-face-bold-p 'error t))
;; Blinking cursor is on only when Emacs is not daemonized.
(when (not (boundp 'server-running-p))
(blink-cursor-mode -1))
;; Line numbers. Graphic version has a gray bar separating text from line
;; numbers, so we can leave the background black.
(if (display-graphic-p)

2
README
View File

@ -266,6 +266,7 @@ comm
cppcheck
cut
dash
dcraw
diff
dosbox
doxygen
@ -394,4 +395,3 @@ yasm
youtube-dl
zathura
zsh