Function: msb--init-file-alist
msb--init-file-alist is a byte-compiled function defined in msb.el.gz.
Signature
(msb--init-file-alist LIST)
Source Code
;; Defined in /usr/src/emacs/lisp/msb.el.gz
;; Create an alist with all buffers from LIST that lies under the same
;; directory will be in the same item as the directory name.
;; ((DIR1 . (BUFFER-1 BUFFER-2 ...)) (DIR2 . (BUFFER-K BUFFER-K+1...)) ...)
(defun msb--init-file-alist (list)
(let ((buffer-alist
;; Make alist that looks like
;; ((DIR-1 BUFFER-1) (DIR-2 BUFFER-2) ...)
;; sorted on DIR-x
(sort
(apply #'nconc
(mapcar
(lambda (buffer)
(let ((file-name (expand-file-name
(buffer-file-name buffer))))
(when file-name
(list (cons (msb--strip-dir file-name) buffer)))))
list))
(lambda (item1 item2)
(string< (car item1) (car item2))))))
;; Now clump buffers together that have the same directory name
;; Make alist that looks like
;; ((DIR1 . (BUFFER-1 BUFFER-2 ...)) (DIR2 . (BUFFER-K)) ...)
(let ((dir nil)
(buffers nil))
(nconc
(apply
#'nconc
(mapcar (lambda (item)
(cond
((equal dir (car item))
;; The same dir as earlier:
;; Add to current list of buffers.
(push (cdr item) buffers)
;; This item should not be added to list
nil)
(t
;; New dir
(let ((result (and dir (cons dir buffers))))
(setq dir (car item))
(setq buffers (list (cdr item)))
;; Add the last result the list.
(and result (list result))))))
buffer-alist))
;; Add the last result to the list
(list (cons dir buffers))))))