comparison lisp/subr.el @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 68eb53e4b7e5
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
357 function allows you to set the local value. 357 function allows you to set the local value.
358 358
359 NOTE: At some point, this will be moved into C and will be very fast." 359 NOTE: At some point, this will be moved into C and will be very fast."
360 (with-current-buffer buffer 360 (with-current-buffer buffer
361 (set sym val))) 361 (set sym val)))
362 362
363 ;;;; String functions. 363 ;;;; String functions.
364 364
365 ;; XEmacs 365 ;; XEmacs
366 (defun replace-in-string (str regexp newtext &optional literal) 366 (defun replace-in-string (str regexp newtext &optional literal)
367 "Replace all matches in STR for REGEXP with NEWTEXT string, 367 "Replace all matches in STR for REGEXP with NEWTEXT string,
444 See also `with-temp-buffer'." 444 See also `with-temp-buffer'."
445 `(save-current-buffer 445 `(save-current-buffer
446 (set-buffer ,buffer) 446 (set-buffer ,buffer)
447 ,@body)) 447 ,@body))
448 448
449 (defmacro with-temp-file (file &rest forms) 449 (defmacro with-temp-file (filename &rest forms)
450 "Create a new buffer, evaluate FORMS there, and write the buffer to FILE. 450 "Create a new buffer, evaluate FORMS there, and write the buffer to FILENAME.
451 The value of the last form in FORMS is returned, like `progn'. 451 The value of the last form in FORMS is returned, like `progn'.
452 See also `with-temp-buffer'." 452 See also `with-temp-buffer'."
453 (let ((temp-file (make-symbol "temp-file")) 453 (let ((temp-file (make-symbol "temp-file"))
454 (temp-buffer (make-symbol "temp-buffer"))) 454 (temp-buffer (make-symbol "temp-buffer")))
455 `(let ((,temp-file ,file) 455 `(let ((,temp-file ,filename)
456 (,temp-buffer 456 (,temp-buffer
457 (get-buffer-create (generate-new-buffer-name " *temp file*")))) 457 (get-buffer-create (generate-new-buffer-name " *temp file*"))))
458 (unwind-protect 458 (unwind-protect
459 (prog1 459 (prog1
460 (with-current-buffer ,temp-buffer 460 (with-current-buffer ,temp-buffer
569 (setq alist (cdr alist))) 569 (setq alist (cdr alist)))
570 (nreverse plist))) 570 (nreverse plist)))
571 571
572 ;; getf, remf in cl*.el. 572 ;; getf, remf in cl*.el.
573 573
574 (defmacro putf (plist prop val) 574 (defmacro putf (plist property value)
575 "Add property PROP to plist PLIST with value VAL. 575 "Add property PROPERTY to plist PLIST with value VALUE.
576 Analogous to (setq PLIST (plist-put PLIST PROP VAL))." 576 Analogous to (setq PLIST (plist-put PLIST PROPERTY VALUE))."
577 `(setq ,plist (plist-put ,plist ,prop ,val))) 577 `(setq ,plist (plist-put ,plist ,property ,value)))
578 578
579 (defmacro laxputf (lax-plist prop val) 579 (defmacro laxputf (lax-plist property value)
580 "Add property PROP to lax plist LAX-PLIST with value VAL. 580 "Add property PROPERTY to lax plist LAX-PLIST with value VALUE.
581 Analogous to (setq LAX-PLIST (lax-plist-put LAX-PLIST PROP VAL))." 581 Analogous to (setq LAX-PLIST (lax-plist-put LAX-PLIST PROPERTY VALUE))."
582 `(setq ,lax-plist (lax-plist-put ,lax-plist ,prop ,val))) 582 `(setq ,lax-plist (lax-plist-put ,lax-plist ,property ,value)))
583 583
584 (defmacro laxremf (lax-plist prop) 584 (defmacro laxremf (lax-plist property)
585 "Remove property PROP from lax plist LAX-PLIST. 585 "Remove property PROPERTY from lax plist LAX-PLIST.
586 Analogous to (setq LAX-PLIST (lax-plist-remprop LAX-PLIST PROP))." 586 Analogous to (setq LAX-PLIST (lax-plist-remprop LAX-PLIST PROPERTY))."
587 `(setq ,lax-plist (lax-plist-remprop ,lax-plist ,prop))) 587 `(setq ,lax-plist (lax-plist-remprop ,lax-plist ,property)))
588 588
589 ;;; Error functions 589 ;;; Error functions
590 590
591 (defun error (datum &rest args) 591 (defun error (datum &rest args)
592 "Signal a non-continuable error. 592 "Signal a non-continuable error.
744 (and (symbolp sym) (not (null (get sym 'error-conditions))))) 744 (and (symbolp sym) (not (null (get sym 'error-conditions)))))
745 745
746 ;;;; Miscellanea. 746 ;;;; Miscellanea.
747 747
748 ;; This is now in C. 748 ;; This is now in C.
749 ;(defun buffer-substring-no-properties (beg end) 749 ;(defun buffer-substring-no-properties (start end)
750 ; "Return the text from BEG to END, without text properties, as a string." 750 ; "Return the text from START to END, without text properties, as a string."
751 ; (let ((string (buffer-substring beg end))) 751 ; (let ((string (buffer-substring start end)))
752 ; (set-text-properties 0 (length string) nil string) 752 ; (set-text-properties 0 (length string) nil string)
753 ; string)) 753 ; string))
754 754
755 (defun get-buffer-window-list (&optional buffer minibuf frame) 755 (defun get-buffer-window-list (&optional buffer minibuf frame)
756 "Return windows currently displaying BUFFER, or nil if none. 756 "Return windows currently displaying BUFFER, or nil if none.