aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-09-09 12:19:04 +1000
committerYuchen Pei <id@ypei.org>2023-09-09 12:19:04 +1000
commit66fb229bc11dff59c839527e001d8767eb532d81 (patch)
tree146349525a59a5ff1c81484e8132c0116158bcd2 /emacs/.emacs.d/lisp
parente229072e3d97738bc2ed50d12d8f2927549f44b8 (diff)
[emacs] some convenience editing functions in message mode
Diffstat (limited to 'emacs/.emacs.d/lisp')
-rw-r--r--emacs/.emacs.d/lisp/my/my-gnus.el63
1 files changed, 63 insertions, 0 deletions
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))