0

I have tried the following function

(defun test3 (size column cnt) 
  (interactive "p") 
  (if (eq cnt 0)
      (progn 
        (setq start (point))
        (forward-line (- (/ size column) 1))
        (end-of-line)
        (kill-rectangle start (point))    
        (forward-line 1))
    (progn 
      (setq tmp (point))
      (yank-rectangle)
      (end-of-line)
      (kill-rectangle tmp (point))
      (forward-char 1)))
      (if (eq column 1)        
          (return (yank-rectangle)))
      (test3 size (- column 1) (+ cnt 1)))

I provide some close answer to a column of 40 a's to be split into 4 columns of 10 rows. Can you suggest any improvements? The idea is to generalize the operation to lines with more than 1 character

To be concise

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

Example of desired output (from 20x1 to 4 x 5)

aaaaa
aaaaa
aaaaa
aaaaa
  • SE is not really the place for questions such as "Can you improve my code?" Try Reddit or some other site for that. emacs.SE is more for specific Q&A. – Drew Jul 5 '18 at 20:25
  • Next time, please indent your code properly. It will help others help you. – Drew Jul 5 '18 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.