Emacs: Fix latex positions in skels + insertion "&" for tables/matrices

master
Pierre Neidhardt 2014-03-11 16:59:57 +01:00
parent 88f8d8884b
commit c7f7624b16
1 changed files with 11 additions and 5 deletions

View File

@ -49,6 +49,8 @@
'("aux" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy")) '("aux" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy"))
(set (make-local-variable 'tex-command) "pdflatex") (set (make-local-variable 'tex-command) "pdflatex")
(tex-set-compiler) (tex-set-compiler)
;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
(local-set-key (kbd "C-c C-a") 'latex-article) (local-set-key (kbd "C-c C-a") 'latex-article)
(local-set-key (kbd "C-c C-c") 'latex-smallcaps) (local-set-key (kbd "C-c C-c") 'latex-smallcaps)
(local-set-key (kbd "C-c C-e") 'latex-emph) (local-set-key (kbd "C-c C-e") 'latex-emph)
@ -90,16 +92,20 @@ This skel is different from `latex-insert-block' in the way that
@ _ \n @ _ \n
"\\end{lstlisting}" > \n @) "\\end{lstlisting}" > \n @)
;; If tabular, center. ;; TODO: If tabular, center.
;; '(tabular, align, "pmatrix" "bmatrix" "Bmatrix" "vmatrix" "Vmatrix" "smallmatrix"))}} ;; TODO: complete with '(tabular, align, "pmatrix" "bmatrix" "Bmatrix" "vmatrix" "Vmatrix" "smallmatrix"))}}
(define-skeleton latex-matrix (define-skeleton latex-matrix
"Insert matrix/align." "Insert matrix/align."
nil nil
'(require 'functions)
> "\\begin{" > "\\begin{"
'(setq str (skeleton-read "Type: " "align")) '(setq str (skeleton-read "Type: " "align"))
str "}{" (skeleton-read "Format: " "ll") "}" \n str "}{"
;; TODO: count number of letter in format and add number of & accodingly. '(setq str (skeleton-read "Format: " "ll"))
@ _ "\\" \n str "}" \n
'(setq v1 (count-occurences "[a-z]" str))
@ (mapconcat 'identity (split-string (make-string v1 ?&) "" t) " ") " \\\\" \n
@ _ "\\\\" \n
"\\end{" str "}" > \n @) "\\end{" str "}" > \n @)
(define-skeleton latex-orgtbl (define-skeleton latex-orgtbl