@@ -547,7 +547,7 @@ After showing it, its window is selected. The buffer is named
547547BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if
548548DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed."
549549 (interactive )
550- (let (format-table column-sizes window-start)
550+ (let (format-table column-sizes window-start room-session-vectors )
551551 (cl-labels (; ; (heading-face
552552 ; ; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth))))
553553 (format-item (item) (gethash item format-table))
@@ -615,69 +615,71 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed."
615615 ; ; (kill-buffer buffer-name))
616616 (unless ement-sessions
617617 (error " Ement: Not connected. Use `ement-connect' to connect " ))
618+ (setf room-session-vectors
619+ (cl-loop for (_id . session) in ement-sessions
620+ append (cl-loop for room in (ement-session-rooms session)
621+ collect (vector room session))))
618622 (with-current-buffer (get-buffer-create buffer-name)
619623 (ement-room-list-mode)
620- (let* ((room-session-vectors
621- (cl-loop for (_id . session) in ement-sessions
622- append (cl-loop for room in (ement-session-rooms session)
623- collect (vector room session))))
624- (taxy (cl-macrolet ((first-item
625- (pred) `(lambda (taxy)
626- (when (taxy-items taxy)
627- (, pred (car (taxy-items taxy))))))
628- (name= (name) `(lambda (taxy)
629- (equal , name (taxy-name taxy)))))
630- (thread-last
631- (make-fn
632- :name " Ement Rooms"
633- :take (taxy-make-take-function keys ement-room-list-keys))
634- (taxy-fill room-session-vectors)
635- (taxy-sort #'> #'item-latest-ts )
636- (taxy-sort #'t<nil #'item-invited-p )
637- (taxy-sort #'t<nil #'item-favourite-p )
638- (taxy-sort #'t>nil #'item-low-priority-p )
639- (taxy-sort #'t<nil #'item-unread-p )
640- (taxy-sort #'t<nil #'item-space-p )
641- ; ; Within each taxy, left rooms should be sorted last so that one
642- ; ; can never be the first room in the taxy (unless it's the taxy
643- ; ; of left rooms), which would cause the taxy to be incorrectly
644- ; ; sorted last.
645- (taxy-sort #'t>nil #'item-left-p )
646- (taxy-sort* #'string< #'taxy-name )
647- (taxy-sort* #'> #'taxy-latest-ts )
648- (taxy-sort* #'t<nil (name= " Buffers" ))
649- (taxy-sort* #'t<nil (first-item item-unread-p))
650- (taxy-sort* #'t<nil (first-item item-favourite-p))
651- (taxy-sort* #'t<nil (first-item item-invited-p))
652- (taxy-sort* #'t>nil (first-item item-space-p))
653- (taxy-sort* #'t>nil (name= " Low-priority" ))
654- (taxy-sort* #'t>nil (first-item item-left-p)))))
655- (taxy-magit-section-insert-indent-items nil )
656- (inhibit-read-only t )
657- (format-cons (taxy-magit-section-format-items
658- ement-room-list-columns ement-room-list-column-formatters taxy))
659- (pos (point ))
660- (section-ident (when (magit-current-section)
661- (magit-section-ident (magit-current-section)))))
662- (setf format-table (car format-cons)
663- column-sizes (cdr format-cons)
664- header-line-format (taxy-magit-section-format-header
665- column-sizes ement-room-list-column-formatters)
666- window-start (if (get-buffer-window buffer-name)
667- (window-start (get-buffer-window buffer-name))
668- 0 ))
669- (when ement-room-list-visibility-cache
670- (setf magit-section-visibility-cache ement-room-list-visibility-cache))
671- (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local )
672- (delete-all-overlays )
673- (erase-buffer )
674- (save-excursion
675- (taxy-magit-section-insert taxy :items 'first
676- ; ; :blank-between-depth bufler-taxy-blank-between-depth
677- :initial-depth 0 ))
678- (goto-char pos)
679- (when (and section-ident (magit-get-section section-ident))
680- (goto-char (oref (magit-get-section section-ident) start)))))
624+ (delete-all-overlays )
625+ (erase-buffer )
626+ (if (not room-session-vectors)
627+ (insert " No joined rooms. Use command `ement-join-room' to join a room, or `ement-directory' or `ement-directory-search' to find rooms." )
628+ (let* ((taxy (cl-macrolet ((first-item
629+ (pred) `(lambda (taxy)
630+ (when (taxy-items taxy)
631+ (, pred (car (taxy-items taxy))))))
632+ (name= (name) `(lambda (taxy)
633+ (equal , name (taxy-name taxy)))))
634+ (thread-last
635+ (make-fn
636+ :name " Ement Rooms"
637+ :take (taxy-make-take-function keys ement-room-list-keys))
638+ (taxy-fill room-session-vectors)
639+ (taxy-sort #'> #'item-latest-ts )
640+ (taxy-sort #'t<nil #'item-invited-p )
641+ (taxy-sort #'t<nil #'item-favourite-p )
642+ (taxy-sort #'t>nil #'item-low-priority-p )
643+ (taxy-sort #'t<nil #'item-unread-p )
644+ (taxy-sort #'t<nil #'item-space-p )
645+ ; ; Within each taxy, left rooms should be sorted last so that one
646+ ; ; can never be the first room in the taxy (unless it's the taxy
647+ ; ; of left rooms), which would cause the taxy to be incorrectly
648+ ; ; sorted last.
649+ (taxy-sort #'t>nil #'item-left-p )
650+ (taxy-sort* #'string< #'taxy-name )
651+ (taxy-sort* #'> #'taxy-latest-ts )
652+ (taxy-sort* #'t<nil (name= " Buffers" ))
653+ (taxy-sort* #'t<nil (first-item item-unread-p))
654+ (taxy-sort* #'t<nil (first-item item-favourite-p))
655+ (taxy-sort* #'t<nil (first-item item-invited-p))
656+ (taxy-sort* #'t>nil (first-item item-space-p))
657+ (taxy-sort* #'t>nil (name= " Low-priority" ))
658+ (taxy-sort* #'t>nil (first-item item-left-p)))))
659+ (taxy-magit-section-insert-indent-items nil )
660+ (inhibit-read-only t )
661+ (format-cons (taxy-magit-section-format-items
662+ ement-room-list-columns ement-room-list-column-formatters taxy))
663+ (pos (point ))
664+ (section-ident (when (magit-current-section)
665+ (magit-section-ident (magit-current-section)))))
666+ (setf format-table (car format-cons)
667+ column-sizes (cdr format-cons)
668+ header-line-format (taxy-magit-section-format-header
669+ column-sizes ement-room-list-column-formatters)
670+ window-start (if (get-buffer-window buffer-name)
671+ (window-start (get-buffer-window buffer-name))
672+ 0 ))
673+ (when ement-room-list-visibility-cache
674+ (setf magit-section-visibility-cache ement-room-list-visibility-cache))
675+ (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local )
676+ (save-excursion
677+ (taxy-magit-section-insert taxy :items 'first
678+ ; ; :blank-between-depth bufler-taxy-blank-between-depth
679+ :initial-depth 0 ))
680+ (goto-char pos)
681+ (when (and section-ident (magit-get-section section-ident))
682+ (goto-char (oref (magit-get-section section-ident) start))))))
681683 (when display-buffer-action
682684 (when-let ((window (display-buffer buffer-name display-buffer-action)))
683685 (select-window window)))
0 commit comments