From 0d666eab0a36789c5c98fa7d37b928a9f39acaa5 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 4 Jan 2016 21:55:26 -0500 Subject: lisp/init-text.el: Delete --- lisp/init-external.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lisp/init-external.el') diff --git a/lisp/init-external.el b/lisp/init-external.el index 9063402..24725da 100644 --- a/lisp/init-external.el +++ b/lisp/init-external.el @@ -298,4 +298,31 @@ This affects only sites in the `simple-query' format." (define-key km/external-map "j" 'km/webjump) + +;;; Other + +(defun km/columnify-file (delim) + "Separate current file on DELIM using column program. + +By default, DELIM is set to \",\". With a single prefix argument, +use whitespace as the delimiter. With two prefix arguments, +prompt for a delimiter. + +If a columnified buffer already exists, just switch to it." + (interactive (list (cond ((not current-prefix-arg) ",") + ((> (prefix-numeric-value current-prefix-arg) 4) + (read-string "Delimiter: ")) + (t nil)))) + (unless buffer-file-name + (user-error "Buffer not visiting a file")) + (let* ((output-buffer-name (concat "*cols: " (buffer-name) "*")) + (output-buffer (get-buffer output-buffer-name)) + (fname (file-relative-name buffer-file-name)) + (args (cons "--table" + (and delim (list "--separator" delim))))) + (unless output-buffer + (setq output-buffer (get-buffer-create output-buffer-name)) + (apply #'call-process "column" fname output-buffer nil args)) + (switch-to-buffer output-buffer))) + (provide 'init-external) -- cgit v1.2.3