ement.el icon indicating copy to clipboard operation
ement.el copied to clipboard

wip: add ement-room-compose-send-functions

Open progfolio opened this issue 2 years ago • 1 comments

Proof of concept for replacing the single message filter function with a hook. The hook could be configured like so:

For those who want to skip the minibuffer confirmation after sending from a compose buffer:

(defun +ement--exit-minibuffer-once ()
  "Exit the minibuffer once after `ement-compose-message-send'."
  (remove-hook 'post-command-hook #'+ement--exit-minibuffer-once)
  (exit-minibuffer))

(defun +ement--install-minibuffer-skip ()
  "Automatically exit minibuffer after change."
  (add-hook 'post-command-hook #'+ement--exit-minibuffer-once))
(add-hook 'ement-room-compose-send-functions #'+ement--install-minibuffer-skip)

A silly example:

(defun +ement-censor-message ()
  "Censor messages containing bad words."
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "bad" nil t)
      (replace-match "b**"))))
(add-hook 'ement-room-compose-send-functions #'+ement-censor-message -90)

A less silly example:

(defun +ement-force-spellcheck ()
  "Force me to spell check a message before sending."
  (require 'flyspell)
  (flyspell-buffer)
  (save-excursion
    (goto-char (point-min))
    (while (text-property-search-forward 'face 'flyspell-incorrect)
      (flyspell-correct-at-point))))
(add-hook 'ement-room-compose-send-functions #'+ement-force-spellcheck -90)

progfolio avatar Aug 10 '23 21:08 progfolio

This looks like a very interesting idea. Thanks.

alphapapa avatar Aug 11 '23 01:08 alphapapa