Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun sort-rectangle (prefix)
- "Sort the text of a rectangle.
- Has the effect of sorting in place."
- (interactive "p")
- (when-let ((_ (region-active-p))
- (anchor (region-beginning)))
- (kill-rectangle anchor (region-end))
- (with-temp-buffer
- (yank-rectangle)
- (let ((start (point-min))
- (stop (point-max)))
- (sort-lines (= prefix 4) start stop)
- (kill-rectangle start stop)))
- (goto-char anchor)
- (yank-rectangle)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement