mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 09:21:37 -05:00
Add: (ement-view-room-display-buffer-action) etc.
i.e. (ement-auto-view-room-display-buffer-action), and use in (ement-room-view).
This commit is contained in:
parent
c402ee4931
commit
f361abebc1
2 changed files with 21 additions and 7 deletions
|
@ -194,6 +194,7 @@ In that case, sender names are aligned to the margin edge.")
|
|||
(defvar ement-users)
|
||||
(defvar ement-images-queue)
|
||||
(defvar ement-notify-limit-room-name-width)
|
||||
(defvar ement-view-room-display-buffer-action)
|
||||
|
||||
;; Defined in Emacs 28.1: silence byte-compilation warning in earlier versions.
|
||||
(defvar browse-url-handlers)
|
||||
|
@ -1761,17 +1762,16 @@ reaction string, e.g. \"👍\"."
|
|||
|
||||
(defun ement-room-view (room session)
|
||||
"Switch to a buffer showing ROOM on SESSION.
|
||||
Calls `pop-to-buffer-same-window'. Interactively, with prefix,
|
||||
call `pop-to-buffer'."
|
||||
Uses action `ement-view-room-display-buffer-action', which see."
|
||||
(interactive (ement-complete-room :session (ement-complete-session) :suggest nil))
|
||||
(pcase-let* (((cl-struct ement-room (local (map buffer))) room))
|
||||
(unless (buffer-live-p buffer)
|
||||
(setf buffer (ement-room--buffer session room (ement-room--buffer-name room))
|
||||
(alist-get 'buffer (ement-room-local room)) buffer))
|
||||
;; FIXME: There must be a better way to handle this.
|
||||
(funcall (if current-prefix-arg
|
||||
#'pop-to-buffer #'pop-to-buffer-same-window)
|
||||
buffer)))
|
||||
;; FIXME: This doesn't seem to work as desired, e.g. when
|
||||
;; `ement-view-room-display-buffer-action' is set to `display-buffer-no-window'; I
|
||||
;; guess because `pop-to-buffer' selects a window.
|
||||
(pop-to-buffer buffer ement-view-room-display-buffer-action)))
|
||||
(defalias 'ement-view-room #'ement-room-view)
|
||||
|
||||
(defun ement-room--buffer-name (room)
|
||||
|
|
16
ement.el
16
ement.el
|
@ -156,6 +156,19 @@ That is, when calling command `ement-disconnect'. Functions are
|
|||
called with no arguments."
|
||||
:type 'hook)
|
||||
|
||||
(defcustom ement-view-room-display-buffer-action '(display-buffer-same-window)
|
||||
"Display buffer action to use when opening room buffers.
|
||||
See function `display-buffer' and info node `(elisp) Buffer
|
||||
Display Action Functions'."
|
||||
:type 'function)
|
||||
|
||||
(defcustom ement-auto-view-room-display-buffer-action '(display-buffer-no-window)
|
||||
"Display buffer action to use when automatically opening room buffers.
|
||||
That is, rooms listed in `ement-auto-view-rooms', which see. See
|
||||
function `display-buffer' and info node `(elisp) Buffer Display
|
||||
Action Functions'."
|
||||
:type 'function)
|
||||
|
||||
;;;; Commands
|
||||
|
||||
;;;###autoload
|
||||
|
@ -300,7 +313,8 @@ Useful in, e.g. `ement-disconnect-hook', which see."
|
|||
(or (equal alias/id (ement-room-canonical-alias room))
|
||||
(equal alias/id (ement-room-id room))))
|
||||
(ement-session-rooms session)))
|
||||
(ement-view-room room session)))))
|
||||
(let ((ement-view-room-display-buffer-action ement-auto-view-room-display-buffer-action))
|
||||
(ement-view-room room session))))))
|
||||
|
||||
(defun ement--initial-transaction-id ()
|
||||
"Return an initial transaction ID for a new session."
|
||||
|
|
Loading…
Add table
Reference in a new issue