Add function to convert tab-seperated values to LaTex tables

This commit is contained in:
Adam Goldsmith 2015-10-04 16:09:42 -04:00
parent c490c1920e
commit 899461b5fc

View File

@ -137,7 +137,17 @@
(add-hook 'LaTeX-mode-hook (add-hook 'LaTeX-mode-hook
(lambda () (local-set-key (kbd "C-z") 'my-tex) (lambda () (local-set-key (kbd "C-z") 'my-tex)
(local-set-key (kbd "C-c e") 'tex-close-latex-block) (local-set-key (kbd "C-c e") 'tex-close-latex-block)
(TeX-source-correlate-mode)))) (TeX-source-correlate-mode)))
(defun latex-tsv-to-table ()
"Converts tab-seperated-values to a LaTeX table."
(interactive)
(let ((beg (region-beginning)) (lines (count-lines (region-beginning) (region-end))))
(save-excursion
(goto-char beg)
(indent-region beg (point))
(replace-regexp "\t" " & " nil beg (point))
(replace-regexp "$" " \\\\\\\\" nil beg (point))
(align beg (point)))))
(use-package fasd (use-package fasd
:config :config
(global-set-key (kbd "C-x C-S-f") 'fasd-find-file) (global-set-key (kbd "C-x C-S-f") 'fasd-find-file)