Open emin63 opened 3 years ago
Am looking into this, too. It seems the cl- functions used here are designed for interactive use first and foremost. @yuya373 would you be interested in adding programmatic variants under the hood that the interactive version falls back to, or introduce optional parameters that would replace interactive use?
you can make a room object like this:
(make-instance 'slack-room :id "ABCDEFG")
but for whatever reason its not displaying the room
ok here's a hacky way to do it:
define this function
(defun slack-room-display-by-name (room team)
(cl-labels
((open (buf)
(slack-buffer-display buf)))
(progn
(slack-room-clear-messages room)
(slack-conversations-view
room team
:after-success #'(lambda (messages cursor)
(slack-room-set-messages room messages team)
(open (slack-create-message-buffer room cursor team)))))))
assuming you know the room id's you can call it like this
(slack-room-display (make-instance 'slack-room :id "ROOM_ID_HERE") (slack-team-select))
or to do a list of id's
(let ((team (slack-team-select)))
(mapcar
(lambda (room-id)
(slack-room-display (make-instance 'slack-room :id room-id) team)
)
(list "id-1-string" "id-2-string" ...) )
)
there might be a function to lookup room name from id, but this working for me now, so sticking with it, looking up the room id's is a one time task
I've run into issue with the previous approach, this is how I'm doing it now
(defun slack-auto-connect ()
(interactive)
(let* ((team (slack-team-select))
(channels (slack-team-channels team))
(rooms (remove-if-not
(lambda (channel)
(seq-contains (list "SLACK" "ROOM" "IDS" "HERE")
(slot-value channel 'id)))
channels)))
(mapcar
(lambda (room)
(slack-room-display room team))
rooms)))
I would like to do something like
and get the same effect as if I had called
slack-room-display
interactively and selected "some-team" for the team and "some-room-name" for the room.The use case is basically to create a macro or key binding for frequently used rooms. Ultimately, something like this might also be able to serve as the basis for creating org links to certain slack rooms.
The trouble is that it looks like
slack-room-display
is expecting some object not a string for its arguments. How can I start with strings and get the desired objects to pass toslack-room-display
?Thanks.