dotfiles/emacs-lisp/ement_el.org
Magic_RB 931b5aa764 Improve ement password handling
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2023-09-16 19:54:34 +02:00

69 lines
2.3 KiB
Org Mode

:PROPERTIES:
:ID: cfb02bea-f9a2-4c7c-8971-d082feedab22
:END:
#+title: ement.el
#+filetags: emacs-load
#+begin_src emacs-lisp
(use-package password-store
:straight t)
(defun ement-connect-sentinel (process msg)
(when (memq (process-status process) '(exit signal))
(with-current-buffer " *ement-pass*"
(ement-connect
:uri-prefix "http://localhost:8008"
:password (let ((password (string-trim (substring-no-properties (buffer-string)))))
(if (not (equal (process-exit-status process) 0))
(read-passwd "Ement password: ")
password))
:user-id "@magic_rb:matrix.redalder.org")
(kill-buffer))))
(defun after-init-ement-connect ()
(interactive)
(set-process-sentinel (start-process "ement-pass" " *ement-pass*" "pass" "Matrix/@magic_rb:matrix.redalder.org") #'ement-connect-sentinel))
(use-package ement
:straight '(ement :type git :host github :repo "alphapapa/ement.el")
:after (password-store)
:custom
(ement-save-sessions t)
:config
(remove-hook 'ement-after-initial-sync-hook #'ement-room-list--after-initial-sync)
(setf ement-sessions (ement--read-sessions)))
#+end_src
#+begin_src emacs-lisp
(defun ement-send-anyways ()
(interactive)
(when (ement-room-p ement-room)
(let ((ement-room- ement-room)
(ement-session- ement-session))
(save-excursion
(panctl "*panctl-temp-send-anyway*")
(vterm-insert "send-anyways " (ement-user-id (ement-session-user ement-session-)) " " (ement-room-id ement-room-))
(vterm-send-return)
(vterm-send-C-c)))))
#+end_src
Enable message composition in [[id:986ca7a5-d225-49bb-9e35-f2dffafe8aee][Org Mode]] by default.
#+begin_src emacs-lisp
(setq ement-room-send-message-filter #'ement-room-send-org-filter)
#+end_src
Define an interactive command to open [[https://github.com/matrix-org/pantalaimon][pantalaimon]] in Emacs.
#+begin_src emacs-lisp
(defun panctl (&optional name)
(interactive)
(let* ((name- (or name "panctl"))
(buffer (get-buffer name-))
(vterm-shell "panctl"))
(if buffer
(switch-to-buffer buffer)
(vterm name-)
(whitespace-mode -1))))
#+end_src