From 66fb229bc11dff59c839527e001d8767eb532d81 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 9 Sep 2023 12:19:04 +1000 Subject: [emacs] some convenience editing functions in message mode --- emacs/.emacs.d/lisp/my/my-gnus.el | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'emacs/.emacs.d/lisp') diff --git a/emacs/.emacs.d/lisp/my/my-gnus.el b/emacs/.emacs.d/lisp/my/my-gnus.el index 9c42204..599a19c 100644 --- a/emacs/.emacs.d/lisp/my/my-gnus.el +++ b/emacs/.emacs.d/lisp/my/my-gnus.el @@ -27,6 +27,69 @@ ;;; Code: +;;; `message-mode', the mode to compose messages +(defun my-message-elide-remaining () + "Elide all cited text after point." + (interactive) + (when-let* ((beg (point)) + (citexp (concat "^\\(" + (concat message-yank-cited-prefix "\\|") + message-yank-prefix + "\\)")) + (end (save-excursion + (goto-char (point-max)) + (when (re-search-backward citexp nil t) + (beginning-of-line 2) + (point))))) + (when (< beg end) (message-elide-region beg end)))) + +(defun my-message-remove-trailing-cited-lines () + "Remove all trailing cited lines." + (interactive) + (save-excursion + (when-let* ((citexp (concat "^\\(" + (concat message-yank-cited-prefix "\\|") + message-yank-prefix + "\\)+ *\n")) + (end (progn + (goto-char (point-max)) + (when (re-search-backward citexp nil t) + (beginning-of-line 2) + (point)))) + (beg (progn (beginning-of-line 0) + (while (looking-at-p citexp) + (beginning-of-line 0)) + (beginning-of-line 2) + (point)))) + (when (< beg end) (delete-region beg end))))) + +(defun my-message-before-previous-cited () + "Move point to before previous cited portion." + (interactive) + (let ((citexp (concat "^\\(" + (concat message-yank-cited-prefix "\\|") + message-yank-prefix + "\\)"))) + (beginning-of-line 1) + (unless (looking-at-p citexp) + (re-search-backward citexp nil t)) + (beginning-of-line 0) + (while (looking-at-p citexp) + (beginning-of-line 0)))) + +(defun my-message-after-next-cited () + "Move point to after the next cited portion." + (interactive) + (let ((citexp (concat "^\\(" + (concat message-yank-cited-prefix "\\|") + message-yank-prefix + "\\)"))) + (beginning-of-line 1) + (unless (looking-at-p citexp) + (re-search-forward citexp nil t)) + (beginning-of-line 2) + (while (looking-at-p citexp) + (beginning-of-line 2)))) (defun my-gnus-summary-exit-like-mu4e () (interactive) (if (get-buffer-window (gnus-buffer-live-p gnus-article-buffer)) -- cgit v1.2.3