Skip to content

Commit

Permalink
WIP: ement-compose-mode
Browse files Browse the repository at this point in the history
See #140.
  • Loading branch information
alphapapa committed May 15, 2023
1 parent 4d44ea2 commit 1c6ad51
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -3653,24 +3653,27 @@ To be called from an `ement-room-compose' buffer."
(ement-room-send-message ement-room ement-session :body body :replying-to-event replying-to-event))))

(defun ement-room-init-compose-buffer (room session)
"Eval BODY, setting up the current buffer as a compose buffer.
Sets ROOM and SESSION buffer-locally, binds `save-buffer' in
a copy of the local keymap, and sets `header-line-format'."
;; Using a macro for this seems awkward but necessary.
"Set the current buffer as a compose buffer for ROOM and SESSION."
(ement-compose-mode)
(setq-local ement-room room)
(setq-local ement-session session)
(setq-local ement-session session))

(define-derived-mode ement-compose-mode text-mode "Ement-Compose"
"Major mode for composing messages to `ement' rooms."
:interactive nil
(setf ement-room-compose-buffer t)
(setq-local completion-at-point-functions
(append '(ement-room--complete-members-at-point ement-room--complete-rooms-at-point)
completion-at-point-functions))
;; FIXME: Compose with local map?
(use-local-map (if (current-local-map)
(copy-keymap (current-local-map))
(make-sparse-keymap)))
(local-set-key [remap save-buffer] #'ement-room-compose-send)
(setq header-line-format (substitute-command-keys
(format " Press \\[save-buffer] to send message to room (%s)"
(ement-room-display-name room)))))
(setq header-line-format '(:eval (substitute-command-keys
(format " Press \\[save-buffer] to send message to room (%s)"
(ement-room-display-name ement-room))))))

(defvar ement-compose-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [remap save-buffer] #'ement-room-compose-send)
map)
"Map for `ement-compose-mode' buffers.")

;;;;; Widgets

Expand Down

1 comment on commit 1c6ad51

@progfolio
Copy link
Contributor

@progfolio progfolio commented on 1c6ad51 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came to open a fresh issue suggesting this. Glad to see you not only already had it in mind, but have implemented it! Looking forward to this change.

Please sign in to comment.