GNU bug report logs -
#5351
Rectangles of type `beer bellied'
Previous Next
Reported by: MON KEY <monkey <at> sandpframing.com>
Date: Mon, 11 Jan 2010 03:23:02 UTC
Severity: normal
Tags: wontfix
Merged with 1184
Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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://debbugs.gnu.org/cgi/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\
This bug report was last modified 14 years and 7 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.