All pastes #74391 Raw Edit

Something

public text v1 · immutable
#74391 ·published 2006-06-28 23:25 UTC
rendered paste body
(defun append-increment-from (beginning end n)
  "Append a number to the end of each line in the region, incrementing
it from the number supplied. So first line gets n, second n + 1, ..."
  (interactive "r
sEnter the number to increment from: ")
  (if (string-match "[0-9]*" n)
      (save-excursion
	(goto-char end)
	(let ((start-line 0)
	      (end-line 0)
	      (n (string-to-number n)))

	  (setq start-line (count-lines 1 (progn
					    (goto-char beginning)
					    (end-of-line)
					    (point))))
	  (progn
	    (goto-char end)
	    (setq end-line (count-lines 1 (progn 
					    (goto-char end)
					    (point)))))
	  (while ( <= start-line end-line)
	    (progn
	      (goto-line start-line)
	      (end-of-line)
	      (insert (number-to-string n))
	      (setq start-line (1+ start-line))
	      (setq n (1+ n))))))))