bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5351: Rectangles of type `beer bellied'


From: MON KEY
Subject: bug#5351: Rectangles of type `beer bellied'
Date: Sun, 10 Jan 2010 22:22:09 -0500

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\







reply via email to

[Prev in Thread] Current Thread [Next in Thread]