diff lisp/subr.el @ 883:1e9272790fe0

[xemacs-hg @ 2002-06-26 00:11:15 by youngs] 2002-06-24 John Paul Wallington <jpw@shootybangbang.com> * obsolete.el (frame-parameter): New compatibility function. (makehash): Ditto. (buffer-local-value): Ditto. (line-beginning-position): New compatibility alias for `point-at-bol'. (line-end-position): New compatibility alias for `point-at-eol'. * subr.el (with-temp-message): New function; sync with GNU Emacs 21. (bound-and-true-p): Ditto. (propertize): New function. (delete-and-extract-region): Ditto. 2002-06-24 Jerry James <james@xemacs.org> * code-files.el (load): Look for a binary module if no Lisp file with the correct name is found.
author youngs
date Wed, 26 Jun 2002 00:11:16 +0000
parents 64f38afaab2d
children 1b114504fa80
line wrap: on
line diff
--- a/lisp/subr.el	Tue Jun 25 21:20:47 2002 +0000
+++ b/lisp/subr.el	Wed Jun 26 00:11:16 2002 +0000
@@ -486,6 +486,23 @@
 	 (and (buffer-name ,temp-buffer)
 	      (kill-buffer ,temp-buffer))))))
 
+(defmacro with-temp-message (message &rest body)
+  "Display MESSAGE temporarily while BODY is evaluated.
+The original message is restored to the echo area after BODY has finished.
+The value returned is the value of the last form in BODY."
+  (let ((current-message (make-symbol "current-message"))
+	(temp-message (make-symbol "with-temp-message")))
+    `(let ((,temp-message ,message)
+	   (,current-message))
+       (unwind-protect
+	   (progn
+	     (when ,temp-message
+	       (setq ,current-message (current-message))
+	       (message "%s" ,temp-message))
+	     ,@body)
+	 (and ,temp-message ,current-message
+	      (message "%s" ,current-message))))))
+
 (defmacro with-temp-buffer (&rest forms)
   "Create a temporary buffer, and evaluate FORMS there like `progn'.
 See also `with-temp-file' and `with-output-to-string'."
@@ -1108,6 +1125,30 @@
   (interactive)
   nil)
 
+;; defined in lisp/bindings.el in GNU Emacs.
+(defmacro bound-and-true-p (var)
+  "Return the value of symbol VAR if it is bound, else nil."
+  `(and (boundp (quote ,var)) ,var))
+
+;; `propertize' is a builtin in GNU Emacs 21.
+(defun propertize (string &rest properties)
+  "Return a copy of STRING with text properties added.
+First argument is the string to copy.
+Remaining arguments form a sequence of PROPERTY VALUE pairs for text
+properties to add to the result."
+  (let ((str (copy-sequence string)))
+    (add-text-properties 0 (length str)
+			 properties
+			 str)
+    str))
+
+;; `delete-and-extract-region' is a builtin in GNU Emacs 21.
+(defun delete-and-extract-region (start end)
+  "Delete the text between START and END and return it."
+  (let ((region (buffer-substring start end)))
+    (delete-region start end)
+    region))
+
 (define-function 'eval-in-buffer 'with-current-buffer)
 (make-obsolete 'eval-in-buffer 'with-current-buffer)
 
@@ -1132,8 +1173,6 @@
 ;;      (compiled-function-p object)
 ;;      (eq (car-safe object) 'lambda)))
 
-
-
 (defun function-interactive (function)
   "Return the interactive specification of FUNCTION.
 FUNCTION can be any funcallable object.