APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1504772179 -3600
#      Thu Sep 07 09:16:19 2017 +0100
# Node ID 97ece44f19cfad8a1892d2a542dcceea679ae93c
# Parent  97140cfdeca785747a13192343cf357ea21a3dc1
Remove #'spaces-string, rect.el, call #'format instead.
lisp/ChangeLog addition:
2017-09-07  Aidan Kehoe  <kehoea(a)parhasard.net>
	* rect.el (delete-extract-rectangle-line):
	Use (format "%*s" N "") instead of (spaces-string N) in this
	function.
	* rect.el (extract-rectangle-line): Ditto.
	* rect.el (spaces-strings): Removed.
	* rect.el (spaces-string): Removed.
	These aren't needed, (format "*s" N "") does the same job.
diff -r 97140cfdeca7 -r 97ece44f19cf lisp/ChangeLog
--- a/lisp/ChangeLog	Wed Jun 28 22:41:35 2017 +0100
+++ b/lisp/ChangeLog	Thu Sep 07 09:16:19 2017 +0100
@@ -1,3 +1,13 @@
+2017-09-07  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* rect.el (delete-extract-rectangle-line):
+	Use (format "%*s" N "") instead of (spaces-string N) in this
+	function.
+	* rect.el (extract-rectangle-line): Ditto.
+	* rect.el (spaces-strings): Removed.
+	* rect.el (spaces-string): Removed.
+	These aren't needed, (format "*s" N "") does the same job.
+
 2017-06-28  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* subr.el (char-width): Move this to C, necessary as part of the
diff -r 97140cfdeca7 -r 97ece44f19cf lisp/rect.el
--- a/lisp/rect.el	Wed Jun 28 22:41:35 2017 +0100
+++ b/lisp/rect.el	Thu Sep 07 09:16:19 2017 +0100
@@ -133,39 +133,16 @@
   (interactive "*r\nP")
   (apply-on-rectangle 'delete-rectangle-line start end fill))
 
-
-;; I love ascii art ;-)
-(defconst spaces-strings '[""
-			   " "
-			   "  "
-			   "   "
-			   "    "
-			   "     "
-			   "      "
-			   "       "
-			   "        "])
-
-;; This function is untouched --dv
-(defun spaces-string (n)
-  (if (<= n 8) (aref spaces-strings n)
-    (let ((val ""))
-      (while (> n 8)
-	(setq val (concat "        " val)
-	      n (- n 8)))
-      (concat val (aref spaces-strings n)))))
-
-
 (defun delete-extract-rectangle-line (startcol endcol lines fill)
   (let ((pt (point-at-eol)))
     (if (< (move-to-column startcol (or fill 'coerce)) startcol)
-	(setcdr lines (cons (spaces-string (- endcol startcol))
+	(setcdr lines (cons (format "%*s" (- endcol startcol) "")
 			    (cdr lines)))
       ;; else
       (setq pt (point))
       (move-to-column endcol t)
       (setcdr lines (cons (buffer-substring pt (point)) (cdr lines)))
-      (delete-region pt (point)))
-    ))
+      (delete-region pt (point)))))
 
 ;;;###autoload
 (defun delete-extract-rectangle (start end &optional fill)
@@ -201,14 +178,12 @@
       (let ((width (- (current-column)
 		      (save-excursion (backward-char 1)
 				      (current-column)))))
-	(setq line (concat (substring line 0 (- (point) end 1))
-			   (spaces-string width)
-			   (substring line (+ (length line)
-					      (- (point) end)))))))
+	(setq line (format "%.*s%*s%s"
+			   (- (point) end 1) line
+			   width ""
+			   (subseq line (+ (length line) (- (point) end)))))))
     (if (or (> begextra 0) (> endextra 0))
-	(setq line (concat (spaces-string begextra)
-			   line
-			   (spaces-string endextra))))
+	(setq line (format "%*s%s%*s" begextra "" line endextra
"")))
     (setcdr lines (cons line (cdr lines)))))
 
 ;;;###autoload
-- 
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
    
    
    
 
                    
                    
                        
                        Show replies by date