GNU bug report logs -
#65380
[PATCH] Add command to copy contents in a diff-mode buffer
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Sat, 19 Aug 2023 09:55:01 UTC
Severity: normal
Tags: patch
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>> Yeah, the question then is: should it be new kill/copy commands or a
>> new yank command?
>
> I would do something else: a command to move the killed rectangle to the
> kill-ring. And perhaps a command to do the opposite: transform the last
> item of the kill-ring into a killed rectangle.
>
And here are the two commands I had in mind:
(defun move-killed-rectangle-to-kill-ring ()
"Move the killed rectangle to the `kill-ring'."
(interactive)
(if killed-rectangle
(with-temp-buffer
(while killed-rectangle
(insert-for-yank (car killed-rectangle))
(insert "\n")
(setq killed-rectangle (cdr killed-rectangle)))
(kill-ring-save (point-min) (point-max)))
(user-error "No killed rectangle")))
(defun copy-last-kill-to-killed-rectangle ()
"Transform the current item of `kill-ring' into a killed rectangle"
(interactive)
(with-temp-buffer
(let ((max -1))
(insert-for-yank (current-kill 0 t))
(goto-char (point-min))
(while (not (eobp))
(move-end-of-line nil)
(let ((col (current-column)))
(when (> col max)
(setq max col)))
(forward-line 1))
(let ((col (current-column)))
(when (< col max)
(insert (make-string (- max col) ? ))))
(kill-rectangle (point-min) (point-max)))))
WDYT?
This bug report was last modified 273 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.