Function: bs-buffer-list

bs-buffer-list is a byte-compiled function defined in bs.el.gz.

Signature

(bs-buffer-list &optional LIST SORT-DESCRIPTION)

Documentation

Return a list of buffers to be shown.

LIST is a list of buffers to test for appearance in Buffer Selection Menu. The result list depends on the global variables bs-dont-show-regexp, bs-must-show-regexp, bs-dont-show-function, bs-must-show-function and bs-buffer-sort-function. If SORT-DESCRIPTION isn't nil the list will be sorted by a special function. SORT-DESCRIPTION is an element of bs-sort-functions.

Source Code

;; Defined in /usr/src/emacs/lisp/bs.el.gz
;; ----------------------------------------------------------------------
;; Functions
;; ----------------------------------------------------------------------

(defun bs-buffer-list (&optional list sort-description)
  "Return a list of buffers to be shown.
LIST is a list of buffers to test for appearance in Buffer Selection Menu.
The result list depends on the global variables `bs-dont-show-regexp',
`bs-must-show-regexp', `bs-dont-show-function', `bs-must-show-function'
and `bs-buffer-sort-function'.
If SORT-DESCRIPTION isn't nil the list will be sorted by a special
function.  SORT-DESCRIPTION is an element of `bs-sort-functions'."
  (setq sort-description (or sort-description bs--current-sort-function)
	list (or list (buffer-list)))
  (let ((result nil))
    (dolist (buf list)
      (let* ((buffername (buffer-name buf))
	     (int-show-never (string-match-p bs--intern-show-never buffername))
	     (ext-show-never (and bs-dont-show-regexp
				  (string-match-p bs-dont-show-regexp
						  buffername)))
	     (extern-must-show (or (and bs-must-always-show-regexp
					(string-match-p
					 bs-must-always-show-regexp
					 buffername))
				   (and bs-must-show-regexp
					(string-match-p bs-must-show-regexp
							buffername))))
	     (extern-show-never-from-fun (and bs-dont-show-function
					      (funcall bs-dont-show-function
						       buf)))
	     (extern-must-show-from-fun (and bs-must-show-function
					     (funcall bs-must-show-function
						      buf)))
	     (show-flag (buffer-local-value 'bs-buffer-show-mark buf)))
	(when (or (eq show-flag 'always)
		  (and (or bs--show-all (not (eq show-flag 'never)))
		       (not int-show-never)
		       (or bs--show-all
			   extern-must-show
			   extern-must-show-from-fun
			   (and (not ext-show-never)
				(not extern-show-never-from-fun)))))
	  (setq result (cons buf result)))))
    (setq result (reverse result))
    ;; The current buffer which was the start point of bs should be an element
    ;; of result list, so that we can leave with space and be back in the
    ;; buffer we started bs-show.
    (when (and bs--buffer-coming-from
	       (buffer-live-p bs--buffer-coming-from)
	       (not (memq bs--buffer-coming-from result)))
      (setq result (cons bs--buffer-coming-from result)))
    ;; sorting
    (if (and sort-description
	     (nth 1 sort-description))
	(setq result (sort result (nth 1 sort-description)))
      ;; else standard sorting
      (bs-buffer-sort result))))