ement: auto-connect on startup, my/ement-open, remove ement-sync binding
- my/ement-maybe-restore: restores saved session on after-init-hook, no credentials prompt (requires one manual login first) - my/ement-open: SPC o M o — connects if needed, then ement-list-rooms - Remove SPC o M s (ement-sync is internal, manual call causes double-loop) - Update quick reference comments
This commit is contained in:
32
config.el
32
config.el
@@ -852,20 +852,21 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
|
|||||||
;; Matrix client. Package declared in packages.el.
|
;; Matrix client. Package declared in packages.el.
|
||||||
;; Keybindings: SPC o M (open → matrix)
|
;; Keybindings: SPC o M (open → matrix)
|
||||||
;; Note: SPC o m is taken by Doom's mu4e module (#'mu4e), hence uppercase M.
|
;; Note: SPC o m is taken by Doom's mu4e module (#'mu4e), hence uppercase M.
|
||||||
;; E2EE: connect via Pantalaimon proxy (see notes/emacs-matrix.org)
|
|
||||||
;;
|
;;
|
||||||
;; Quick reference:
|
;; Quick reference:
|
||||||
;; SPC o M c — connect (ement-connect)
|
;; SPC o M o — open Matrix panel (connect + room list, no credentials)
|
||||||
|
;; SPC o M c — connect / re-connect manually
|
||||||
|
;; SPC o M C — disconnect
|
||||||
;; SPC o M l — list rooms
|
;; SPC o M l — list rooms
|
||||||
;; SPC o M r — open room
|
;; SPC o M r — open room
|
||||||
;; SPC o M d — direct message
|
;; SPC o M d — direct message
|
||||||
|
|
||||||
(after! ement
|
(after! ement
|
||||||
|
|
||||||
;; Persist session across restarts (token stored in ~/.cache/emacs/ement.el)
|
;; Persist session across restarts (saved token = no credentials on next start)
|
||||||
(setq ement-save-sessions t)
|
(setq ement-save-sessions t)
|
||||||
|
|
||||||
;; Background auto-sync
|
;; Background auto-sync (internal — do NOT call ement-sync manually, causes issues)
|
||||||
(setq ement-auto-sync t)
|
(setq ement-auto-sync t)
|
||||||
|
|
||||||
;; Show timestamp on every message
|
;; Show timestamp on every message
|
||||||
@@ -877,11 +878,29 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
|
|||||||
|
|
||||||
;; Notify on mentions (@martin)
|
;; Notify on mentions (@martin)
|
||||||
(setq ement-notify-mentions-p t
|
(setq ement-notify-mentions-p t
|
||||||
ement-notify-dingalings-p nil)) ; no sound
|
ement-notify-dingalings-p nil) ; no sound
|
||||||
|
|
||||||
|
;; Auto-connect on startup: restore saved session without prompting for credentials.
|
||||||
|
;; Activates only when session file exists (requires one manual ement-connect first).
|
||||||
|
(defun my/ement-maybe-restore ()
|
||||||
|
"Restore saved ement session silently (no credentials prompt)."
|
||||||
|
(when (file-exists-p (expand-file-name ement-sessions-file))
|
||||||
|
(ement-connect :user-id "@martin:sukany.cz")))
|
||||||
|
|
||||||
|
;; Open Matrix panel: restore/connect if needed, then show room list.
|
||||||
|
(defun my/ement-open ()
|
||||||
|
"Switch to Matrix: reconnect if needed, then open room list."
|
||||||
|
(interactive)
|
||||||
|
(if (and (boundp 'ement-sessions) ement-sessions)
|
||||||
|
(ement-list-rooms)
|
||||||
|
(my/ement-maybe-restore)))
|
||||||
|
|
||||||
|
(add-hook 'after-init-hook #'my/ement-maybe-restore))
|
||||||
|
|
||||||
;; Keybindings under SPC o M (uppercase M — o m is taken by mu4e)
|
;; Keybindings under SPC o M (uppercase M — o m is taken by mu4e)
|
||||||
(map! :leader
|
(map! :leader
|
||||||
(:prefix ("o M" . "Matrix")
|
(:prefix ("o M" . "Matrix")
|
||||||
|
:desc "Open panel" "o" #'my/ement-open
|
||||||
:desc "Connect" "c" #'ement-connect
|
:desc "Connect" "c" #'ement-connect
|
||||||
:desc "Disconnect" "C" #'ement-disconnect
|
:desc "Disconnect" "C" #'ement-disconnect
|
||||||
:desc "List rooms" "l" #'ement-list-rooms
|
:desc "List rooms" "l" #'ement-list-rooms
|
||||||
@@ -889,5 +908,4 @@ Keeps the status bar and tab bar fully visible at any zoom level.")
|
|||||||
:desc "Direct message" "d" #'ement-send-direct-message
|
:desc "Direct message" "d" #'ement-send-direct-message
|
||||||
:desc "Join room" "j" #'ement-join-room
|
:desc "Join room" "j" #'ement-join-room
|
||||||
:desc "Notifications" "n" #'ement-notifications
|
:desc "Notifications" "n" #'ement-notifications
|
||||||
:desc "Mentions" "m" #'ement-mentions
|
:desc "Mentions" "m" #'ement-mentions))
|
||||||
:desc "Sync" "s" #'ement-sync))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user