emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement f8e3fa5f3a: Add: (ement-view-space)


From: ELPA Syncer
Subject: [elpa] externals/ement f8e3fa5f3a: Add: (ement-view-space)
Date: Sun, 8 Jan 2023 11:57:43 -0500 (EST)

branch: externals/ement
commit f8e3fa5f3ad3e126ebbbbfb572e1279154b6d3e1
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: (ement-view-space)
    
    Still needs polishing, but this is functional.
    
    Thanks to @chasecaleb for pointing out that this functionality was
    still missing.
---
 README.org         |  3 +++
 ement-directory.el | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/README.org b/README.org
index 29c3ad3c99..240ac362d7 100644
--- a/README.org
+++ b/README.org
@@ -289,6 +289,9 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 
 ** 0.6-pre
 
+*Additions*
++ Command ~ement-view-space~ to view a space's rooms in a directory buffer.
+
 *Changes*
 + Improve ~ement-describe-room~ command (formatting, bindings).
 
diff --git a/ement-directory.el b/ement-directory.el
index 57c17a262f..938aef8c23 100644
--- a/ement-directory.el
+++ b/ement-directory.el
@@ -368,6 +368,47 @@ contents.  To be called by `ement-directory-search'."
       ;; must be set as the current buffer, so we have to do this explicitly 
here.
       (set-buffer buffer-name))))
 
+;;;; Spaces
+
+;; Viewing spaces and the rooms in them.
+
+(defun ement-view-space (space session)
+  ;; TODO: Use this for spaces instead of `ement-view-room' (or something like 
that).
+  ;; TODO: Display space's topic in the header or something.
+  "View child rooms in SPACE on SESSION.
+SPACE may be a room ID or an `ement-room' struct."
+  ;; TODO: "from" query parameter.
+  (interactive (ement-complete-room :predicate #'ement--room-space-p
+                 :prompt "Space: "))
+  (pcase-let* ((id (cl-typecase space
+                     (string space)
+                     (ement-room (ement-room-id space))))
+               (endpoint (format "rooms/%s/hierarchy" id))
+               (revert-function (lambda (&rest _ignore)
+                                  (interactive)
+                                  (ement-view-space space session))))
+    (ement-api session endpoint :version "v1"
+      :then (lambda (results)
+              (pcase-let (((map rooms ('next_batch next-batch))
+                           results))
+                (ement-directory--view rooms ;; :append-p since
+                  ;; TODO: Use space's alias where possible.
+                  :buffer-name (format "*Ement Directory: space \"%s\"" id)
+                  :root-section-name (format "*Ement Directory: space \"%s\"" 
id)
+                  :init-fn (lambda ()
+                             (setf (alist-get 'session ement-directory-etc) 
session
+                                   (alist-get 'next-batch ement-directory-etc) 
next-batch
+                                   ;; (alist-get 'limit ement-directory-etc) 
limit
+                                   (alist-get 'space ement-directory-etc) 
space)
+                             (setq-local revert-buffer-function 
revert-function)
+                             ;; TODO: Handle next batches.
+                             ;; (when remaining
+                             ;;   (message
+                             ;;    (substitute-command-keys
+                             ;;     "%s rooms remaining (use 
\\[ement-directory-next] to fetch more)")
+                             ;;    remaining))
+                             )))))))
+
 ;;;; Footer
 
 (provide 'ement-directory)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]