comparison lisp/subr.el @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c5d627a313b1
children 70ad99077275
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
303 (while (string-match pattern string start) 303 (while (string-match pattern string start)
304 (setq parts (cons (substring string start (match-beginning 0)) parts) 304 (setq parts (cons (substring string start (match-beginning 0)) parts)
305 start (match-end 0))) 305 start (match-end 0)))
306 (nreverse (cons (substring string start) parts)))) 306 (nreverse (cons (substring string start) parts))))
307 307
308 ;; #### #### #### AAaargh! Must be in C, because it is used insanely
309 ;; early in the bootstrap process.
310 ;(defun split-path (path)
311 ; "Explode a search path into a list of strings.
312 ;The path components are separated with the characters specified
313 ;with `path-separator'."
314 ; (while (or (not stringp path-separator)
315 ; (/= (length path-separator) 1))
316 ; (setq path-separator (signal 'error (list "\
317 ;`path-separator' should be set to a single-character string"
318 ; path-separator))))
319 ; (split-string-by-char path (aref separator 0)))
320
308 (defmacro with-output-to-string (&rest forms) 321 (defmacro with-output-to-string (&rest forms)
309 "Collect output to `standard-output' while evaluating FORMS and return 322 "Collect output to `standard-output' while evaluating FORMS and return
310 it as a string." 323 it as a string."
311 ;; by "William G. Dubuque" <wgd@zurich.ai.mit.edu> w/ mods from Stig 324 ;; by "William G. Dubuque" <wgd@zurich.ai.mit.edu> w/ mods from Stig
312 `(with-current-buffer (get-buffer-create " *string-output*") 325 `(with-current-buffer (get-buffer-create " *string-output*")
531 "Return the text from BEG to END, without text properties, as a string." 544 "Return the text from BEG to END, without text properties, as a string."
532 (let ((string (buffer-substring beg end))) 545 (let ((string (buffer-substring beg end)))
533 (set-text-properties 0 (length string) nil string) 546 (set-text-properties 0 (length string) nil string)
534 string)) 547 string))
535 548
536 ;; This should probably be written in C (i.e., without using `walk-windows'). 549 (defun get-buffer-window-list (&optional buffer minibuf frame)
537 (defun get-buffer-window-list (buffer &optional minibuf frame)
538 "Return windows currently displaying BUFFER, or nil if none. 550 "Return windows currently displaying BUFFER, or nil if none.
551 BUFFER defaults to the current buffer.
539 See `walk-windows' for the meaning of MINIBUF and FRAME." 552 See `walk-windows' for the meaning of MINIBUF and FRAME."
540 (let ((buffer (if (bufferp buffer) buffer (get-buffer buffer))) windows) 553 (cond ((null buffer)
541 (walk-windows (function (lambda (window) 554 (setq buffer (current-buffer)))
542 (if (eq (window-buffer window) buffer) 555 ((not (bufferp buffer))
543 (setq windows (cons window windows))))) 556 (setq buffer (get-buffer buffer))))
557 (let (windows)
558 (walk-windows (lambda (window)
559 (if (eq (window-buffer window) buffer)
560 (push window windows)))
544 minibuf frame) 561 minibuf frame)
545 windows)) 562 windows))
546 563
547 (defun ignore (&rest ignore) 564 (defun ignore (&rest ignore)
548 "Do nothing and return nil. 565 "Do nothing and return nil.