Skip to content

Conversation

@progfolio
Copy link
Contributor

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)

@alphapapa
Copy link
Owner

This looks like a very interesting idea. Thanks.

@alphapapa alphapapa self-assigned this Aug 11, 2023
@alphapapa alphapapa added the enhancement New feature or request label Aug 11, 2023
@alphapapa alphapapa added this to the Future milestone Aug 11, 2023
@alphapapa alphapapa force-pushed the master branch 4 times, most recently from a68abe0 to 9da7b8e Compare September 7, 2023 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants