diff lisp/prim/subr.el @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents 28f395d8dc7a
children 5a88923fcbfe
line wrap: on
line diff
--- a/lisp/prim/subr.el	Mon Aug 13 09:42:28 2007 +0200
+++ b/lisp/prim/subr.el	Mon Aug 13 09:43:35 2007 +0200
@@ -238,21 +238,6 @@
 (define-function 'rplaca 'setcar)
 (define-function 'rplacd 'setcdr)
 
-;; XEmacs
-(defun mapvector (__function __seq)
-  "Apply FUNCTION to each element of SEQ, making a vector of the results.
-The result is a vector of the same length as SEQ.
-SEQ may be a list, a vector or a string."
-  (let* ((len (length __seq))
-	 (vec (make-vector len 'nil))
-	 (i 0))
-    (while (< i len)
-      (aset vec i (funcall __function (cond ((listp __seq)
-					     (nth i __seq))
-					    (t (aref __seq i)))))
-      (setq i (+ i 1)))
-    vec))
-
 ;;;; String functions.
 
 ;; XEmacs
@@ -322,8 +307,7 @@
   "Collect output to `standard-output' while evaluating FORMS and return
 it as a string."
   ;; by "William G. Dubuque" <wgd@zurich.ai.mit.edu> w/ mods from Stig
-  (` (save-excursion
-       (set-buffer (get-buffer-create " *string-output*"))
+  (` (with-current-buffer (get-buffer-create " *string-output*")
        (setq buffer-read-only nil)
        (buffer-disable-undo (current-buffer))
        (erase-buffer)
@@ -366,8 +350,7 @@
     `(let ((,temp-buffer
 	    (get-buffer-create (generate-new-buffer-name " *temp*"))))
        (unwind-protect
-	   (save-excursion
-	     (set-buffer ,temp-buffer)
+	   (with-current-buffer ,temp-buffer
 	     ,@forms)
 	 (and (buffer-name ,temp-buffer)
 	      (kill-buffer ,temp-buffer))))))
@@ -377,18 +360,16 @@
   "With the contents of the current buffer being STR, run BODY.
 Returns the new contents of the buffer, as modified by BODY.
 The original current buffer is restored afterwards."
-  `(let ((curbuf (current-buffer))
-         (tempbuf (get-buffer-create " *string-as-buffer-contents*")))
-     (unwind-protect
-         (progn
-           (set-buffer tempbuf)
-           (buffer-disable-undo (current-buffer))
-           (erase-buffer)
-           (insert ,str)
-           ,@body
-           (buffer-string))
-       (erase-buffer tempbuf)
-       (set-buffer curbuf))))
+  `(let ((tempbuf (get-buffer-create " *string-as-buffer-contents*")))
+     (with-current-buffer tempbuf
+       (unwind-protect
+	   (progn
+	     (buffer-disable-undo (current-buffer))
+	     (erase-buffer)
+	     (insert ,str)
+	     ,@body
+	     (buffer-string))
+	 (erase-buffer tempbuf)))))
 
 (defun insert-face (string face)
   "Insert STRING and highlight with FACE.  Returns the extent created."