I just found this post with vim (https://stackoverflow.com/questions/704130/can-i-transpose-a-file-in-vim) and i just wanted to do the same thing with elisp by creating a little script to reordenate all the characters from a buffer text into a vertical position.
As the post said, the original buffer might be:
THE DAY WAS LONG THE WAY WAS FAST
and it would become:
TT HH EE DW AA YY WW AA SS LF OA NS GT
I write this little emacs script to first read each buffer lines in a list (removing spaces), and after using a zip function to transpose each characters between lists, and at the end iterate my list to print it in x columns.
(require 'subr-x) (defun read-buffer-lines (buf) (let ((lines '())) (with-current-buffer buf (save-excursion (goto-char (point-min)) (while (not (eobp)) (if (not (string-equal "" (buffer-substring (point) (point-at-eol)))) (push (delete " " (delete "" (split-string (string-trim (buffer-substring (point) (point-at-eol))) ""))) lines) ) (beginning-of-line 2)) (erase-buffer) ;; clean buffer (nreverse lines) )))) (defun zip_list (lst) (let ((res)) (while (-none? 'null lst) (setq res (cons (mapcar 'car lst) res)) (setq lst (mapcar 'cdr lst))) (nreverse res) )) (let* ((buf "*scratch*") (a (zip_list (read-buffer-lines buf)))) (with-current-buffer buf (while a (progn (insert (mapconcat 'identity (car a) "")) (newline) (setq a (cdr a))))))