- (let ((inhibit-quit t)
- (last (point-min))
- (min (point-min)) (max (point-max)))
- ;; Make sure insertions done for reordering
- ;; do not go after any markers at the end of the sorted region,
- ;; by inserting a space to separate them.
- (goto-char (point-max))
- (insert-before-markers " ")
- (narrow-to-region min (1- (point-max)))
- (while sort-lists
- (goto-char (point-max))
- (insert-buffer-substring (current-buffer)
- last
- (nth 1 (car old)))
+ (let ((last (point-min))
+ (min (point-min)) (max (point-max))
+ (old-buffer (current-buffer))
+ temp-buffer)
+ (with-temp-buffer
+ ;; Record the temporary buffer.
+ (setq temp-buffer (current-buffer))
+
+ ;; Copy the sorted text into the temporary buffer.
+ (while sort-lists
+ (goto-char (point-max))
+ (insert-buffer-substring old-buffer
+ last
+ (nth 1 (car old)))
+ (goto-char (point-max))
+ (insert-buffer-substring old-buffer
+ (nth 1 (car sort-lists))
+ (cdr (cdr (car sort-lists))))
+ (setq last (cdr (cdr (car old)))
+ sort-lists (cdr sort-lists)
+ old (cdr old)))