* bug#5351: Rectangles of type `beer bellied'
@ 2010-01-11 3:22 MON KEY
0 siblings, 0 replies; only message in thread
From: MON KEY @ 2010-01-11 3:22 UTC (permalink / raw)
To: bug-gnu-emacs
This bug report is apropos Emacs bug - #1184
of Thu, 16 Oct 2008 19:45:02 UTC
"document how to deal with beer belly rectangles"
Bug #1184 is Tagged: wontfix
As that bug report log contains one legit message and 44 bogus messages rather
than add to the fray I am starting a new bug report.
FWIW the following function handles the problem.
;;; ==============================
;;; :BUG #1184 of Thu, 16 Oct 2008 19:45:02 UTC
;;; "document how to deal with beer belly rectangles"
;;; :SEE (URL `http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1184')
;;; :CREATED <Timestamp: #{2010-01-10T21:26:28-05:00Z}#{10017} - by MON>
(defun kill-rectangle-w-beer-belly (belly-start belly-end)
"Like kill-rectangle but adds trailing whitespace when column at mark is less
than the longest line in rectangle."
(interactive "r\n")
(let ((max-len 0)
(fatter-belly))
(unwind-protect
(narrow-to-region belly-start belly-end)
(goto-char (point-min))
(while (eq (forward-line) 0)
(end-of-line)
(when (> (current-column) max-len)
(setq max-len (current-column))))
(when (= (current-column) max-len)
(setq fatter-belly t)
(kill-rectangle belly-start belly-end))
(unless fatter-belly
(setq fatter-belly (buffer-substring-no-properties belly-start
belly-end))
(goto-char belly-start)
(kill-line)
(while (eq (forward-line) 0) (kill-line))
(when (stringp fatter-belly)
(with-temp-buffer
(insert fatter-belly)
(goto-char (point-min))
(while (eq (forward-line) 0)
(let ((lebp `(,(line-beginning-position) . ,(line-end-position))))
(unless (= (- (car lebp) (cdr lebp)) max-len)
(end-of-line)
(insert (make-string (- max-len (- (cdr lebp) (car
lebp))) 32)))))
(kill-rectangle (buffer-end 0) (buffer-end 1)))))
(widen))))
/s_P\
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-01-11 3:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 3:22 bug#5351: Rectangles of type `beer bellied' MON KEY
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).