From 899461b5fcf51927e6227a6721f78ab03515a295 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 4 Oct 2015 16:09:42 -0400 Subject: [PATCH] Add function to convert tab-seperated values to LaTex tables --- .emacs.d/init.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 601ef64..d298e81 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -137,7 +137,17 @@ (add-hook 'LaTeX-mode-hook (lambda () (local-set-key (kbd "C-z") 'my-tex) (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 :config (global-set-key (kbd "C-x C-S-f") 'fasd-find-file)