comparison lisp/buff-menu.el @ 58276:935277968aef

(list-buffers-noselect): New arg BUFFER-LIST.
author Richard M. Stallman <rms@gnu.org>
date Tue, 16 Nov 2004 17:12:53 +0000
parents 56342493afe3
children 40fc4ca7acc0
comparison
equal deleted inserted replaced
58275:ade229a259cc 58276:935277968aef
630 (save-window-excursion 630 (save-window-excursion
631 (if e (mouse-select-window e)) 631 (if e (mouse-select-window e))
632 (Buffer-menu-sort ,column)))) 632 (Buffer-menu-sort ,column))))
633 map))) 633 map)))
634 634
635 (defun list-buffers-noselect (&optional files-only) 635 (defun list-buffers-noselect (&optional files-only buffer-list)
636 "Create and return a buffer with a list of names of existing buffers. 636 "Create and return a buffer with a list of names of existing buffers.
637 The buffer is named `*Buffer List*'. 637 The buffer is named `*Buffer List*'.
638 Note that buffers with names starting with spaces are omitted. 638 Note that buffers with names starting with spaces are omitted.
639 Non-null optional arg FILES-ONLY means mention only file buffers. 639 Non-null optional arg FILES-ONLY means mention only file buffers.
640
641 If BUFFER-LIST is non-nil, it should be a list of buffers;
642 it means list those buffers and no others.
640 643
641 For more information, see the function `buffer-menu'." 644 For more information, see the function `buffer-menu'."
642 (let* ((old-buffer (current-buffer)) 645 (let* ((old-buffer (current-buffer))
643 (standard-output standard-output) 646 (standard-output standard-output)
644 (mode-end (make-string (- Buffer-menu-mode-width 2) ? )) 647 (mode-end (make-string (- Buffer-menu-mode-width 2) ? ))
668 (insert header (propertize "---" 'face 'fixed-pitch) " ") 671 (insert header (propertize "---" 'face 'fixed-pitch) " ")
669 (insert (Buffer-menu-buffer+size "------" "----")) 672 (insert (Buffer-menu-buffer+size "------" "----"))
670 (insert " ----" mode-end "----\n") 673 (insert " ----" mode-end "----\n")
671 (put-text-property 1 (point) 'intangible t)) 674 (put-text-property 1 (point) 'intangible t))
672 (setq list 675 (setq list
673 (delq t 676 (or buffer-list
674 (mapcar 677 (delq t
675 (lambda (buffer) 678 (mapcar
676 (with-current-buffer buffer 679 (lambda (buffer)
677 (setq name (buffer-name) 680 (with-current-buffer buffer
678 mode (concat (format-mode-line mode-name nil nil buffer) 681 (setq name (buffer-name)
679 (if mode-line-process 682 mode (concat (format-mode-line mode-name nil nil buffer)
680 (format-mode-line mode-line-process nil nil buffer))) 683 (if mode-line-process
681 file (buffer-file-name)) 684 (format-mode-line mode-line-process nil nil buffer)))
682 (cond 685 file (buffer-file-name))
683 ;; Don't mention internal buffers. 686 (cond
684 ((and (string= (substring name 0 1) " ") (null file))) 687 ;; Don't mention internal buffers.
685 ;; Maybe don't mention buffers without files. 688 ((and (string= (substring name 0 1) " ") (null file)))
686 ((and files-only (not file))) 689 ;; Maybe don't mention buffers without files.
687 ((string= name "*Buffer List*")) 690 ((and files-only (not file)))
688 ;; Otherwise output info. 691 ((string= name "*Buffer List*"))
689 (t 692 ;; Otherwise output info.
690 (unless file 693 (t
691 ;; No visited file. Check local value of 694 (unless file
692 ;; list-buffers-directory. 695 ;; No visited file. Check local value of
693 (when (and (boundp 'list-buffers-directory) 696 ;; list-buffers-directory.
694 list-buffers-directory) 697 (when (and (boundp 'list-buffers-directory)
695 (setq file list-buffers-directory))) 698 list-buffers-directory)
696 (list buffer 699 (setq file list-buffers-directory)))
697 (format "%c%c%c " 700 (list buffer
698 (if (eq buffer old-buffer) ?. ? ) 701 (format "%c%c%c "
699 ;; Handle readonly status. The output buffer is special 702 (if (eq buffer old-buffer) ?. ? )
700 ;; cased to appear readonly; it is actually made so at a 703 ;; Handle readonly status. The output buffer is special
701 ;; later date. 704 ;; cased to appear readonly; it is actually made so at a
702 (if (or (eq buffer standard-output) 705 ;; later date.
703 buffer-read-only) 706 (if (or (eq buffer standard-output)
704 ?% ? ) 707 buffer-read-only)
705 ;; Identify modified buffers. 708 ?% ? )
706 (if (buffer-modified-p) ?* ? )) 709 ;; Identify modified buffers.
707 name (buffer-size) mode file))))) 710 (if (buffer-modified-p) ?* ? ))
708 (buffer-list)))) 711 name (buffer-size) mode file)))))
712 (buffer-list)))))
709 (dolist (buffer 713 (dolist (buffer
710 (if Buffer-menu-sort-column 714 (if Buffer-menu-sort-column
711 (sort list 715 (sort list
712 (if (eq Buffer-menu-sort-column 3) 716 (if (eq Buffer-menu-sort-column 3)
713 (lambda (a b) 717 (lambda (a b)