📄 mh-e.el
字号:
"-cc" "all" "-nocc" "me" (if prefix-provided (list "-filter" "mhl.reply"))))) (let ((draft (mh-read-draft "reply" (expand-file-name "reply" mh-user-path) t))) (delete-other-windows) (set-buffer-modified-p nil) (let ((to (mh-get-field "To:")) (subject (mh-get-field "Subject:")) (cc (mh-get-field "Cc:"))) (goto-char (point-min)) (mh-goto-header-end 1) (if (not prefix-provided) (mh-display-msg msg folder)) (mh-add-msgs-to-seq msg 'answered t) (message "Composing a reply...done") (mh-compose-and-send-mail draft "" folder msg to subject cc mh-note-repl "Replied:" config))))))(defun mh-quit () "Quit mh-e.Start by running mh-before-quit-hook. Restore the previous windowconfiguration, if one exists. Finish by running mh-quit-hook." (interactive) (run-hooks 'mh-before-quit-hook) (if mh-previous-window-config (set-window-configuration mh-previous-window-config)) (run-hooks 'mh-quit-hook))(defun mh-page-digest () "Advance displayed message to next digested message." (interactive) (save-excursion (mh-show-message-in-other-window) ;; Go to top of screen (in case user moved point). (move-to-window-line 0) (let ((case-fold-search nil)) ;; Search for blank line and then for From: (mh-when (not (and (search-forward "\n\n" nil t) (search-forward "From:" nil t))) (other-window -1) (error "No more messages"))) ;; Go back to previous blank line, then forward to the first non-blank. (search-backward "\n\n" nil t) (forward-line 2) (mh-recenter 0) (other-window -1)))(defun mh-page-digest-backwards () "Back up displayed message to previous digested message." (interactive) (save-excursion (mh-show-message-in-other-window) ;; Go to top of screen (in case user moved point). (move-to-window-line 0) (let ((case-fold-search nil)) (beginning-of-line) (mh-when (not (and (search-backward "\n\n" nil t) (search-backward "From:" nil t))) (other-window -1) (error "No more messages"))) ;; Go back to previous blank line, then forward to the first non-blank. (search-backward "\n\n" nil t) (forward-line 2) (mh-recenter 0) (other-window -1)))(defun mh-page-msg (&optional arg) "Page the displayed message forwards.Scrolls ARG lines or a full screen if no argument is supplied." (interactive "P") (scroll-other-window arg))(defun mh-previous-page (&optional arg) "Page the displayed message backwards.Scrolls ARG lines or a full screen if no argument is supplied." (interactive "P") (save-excursion (mh-show-message-in-other-window) (unwind-protect (scroll-down arg) (other-window -1))))(defun mh-previous-undeleted-msg (&optional arg) "Move to previous undeleted message in window." (interactive "p") (setq mh-next-direction 'backward) (beginning-of-line) (cond ((re-search-backward mh-good-msg-regexp nil 0 arg) (mh-maybe-show)) (t (if (get-buffer mh-show-buffer) (delete-windows-on mh-show-buffer)))))(defun mh-print-msg (prefix-provided msg-or-seq) "Print MESSAGE(s) (default: displayed message) on a line printer.If optional prefix argument provided, then prompt for the message sequence." (interactive (list current-prefix-arg (if current-prefix-arg (reverse (mh-seq-to-msgs (mh-read-seq-default "Print" t))) (mh-get-msg-num t)))) (if prefix-provided (message "Printing sequence...") (message "Printing message...")) (let ((print-command (if prefix-provided (format "(scan -clear %s ; %s -nobell -clear %s %s) | %s" (mapconcat (function (lambda (msg) msg)) msg-or-seq " ") (expand-file-name "mhl" mh-lib) (if (stringp mhl-formfile) (format "-form %s" mhl-formfile) "") (mh-msg-filenames msg-or-seq) (format mh-lpr-command-format (if prefix-provided (format "Sequence from %s" mh-current-folder) (format "%s/%d" mh-current-folder msg-or-seq)))) (format "%s -nobell -clear %s %s | %s" (expand-file-name "mhl" mh-lib) (mh-msg-filename msg-or-seq) (if (stringp mhl-formfile) (format "-form %s" mhl-formfile) "") (format mh-lpr-command-format (if prefix-provided (format "Sequence from %s" mh-current-folder) (format "%s/%d" mh-current-folder msg-or-seq))))))) (if mh-print-background (mh-exec-cmd-daemon shell-file-name "-c" print-command) (call-process shell-file-name nil nil nil "-c" print-command)) (if prefix-provided (mh-notate-seq msg-or-seq ?P mh-cmd-note) (mh-notate msg-or-seq ?P mh-cmd-note)) (mh-add-msgs-to-seq msg-or-seq 'printed t) (if prefix-provided (message "Printing sequence...done") (message "Printing message...done"))))(defun mh-put-msg-in-seq (prefix-provided from to) "Add MESSAGE(s) (default: displayed message) to SEQUENCE.If optional prefix argument provided, then prompt for the message sequence." (interactive (list current-prefix-arg (if current-prefix-arg (mh-seq-to-msgs (mh-read-seq-default "Add messages from" t)) (mh-get-msg-num t)) (mh-read-seq-default "Add to" nil))) (setq mh-previous-seq to) (mh-add-msgs-to-seq from to))(defun mh-rescan-folder (&optional range) "Rescan a folder after optionally processing the outstanding commands.If optional prefix argument is provided, prompt for the range ofmessages to display. Otherwise show the entire folder." (interactive (list (if current-prefix-arg (mh-read-msg-range "Range to scan [all]? ") nil))) (setq mh-next-direction 'forward) (mh-scan-folder mh-current-folder (or range "all")))(defun mh-redistribute (to cc msg) "Redistribute a letter.Depending on how your copy of MH was compiled, you may need to change thesetting of the variable mh-redist-full-contents. See its documentation." (interactive (list (read-string "Redist-To: ") (read-string "Redist-Cc: ") (mh-get-msg-num t))) (save-window-excursion (let ((folder mh-current-folder) (draft (mh-read-draft "redistribution" (if mh-redist-full-contents (mh-msg-filename msg) nil) nil))) (mh-goto-header-end 0) (insert "Resent-To: " to "\n") (if (not (equal cc "")) (insert "Resent-cc: " cc "\n")) (mh-clean-msg-header (point-min) "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:" nil) (save-buffer) (message "Redistributing...") (if mh-redist-full-contents (call-process "/bin/sh" nil 0 nil "-c" (format "mhdist=1 mhaltmsg=%s %s -push %s" (buffer-file-name) (expand-file-name "send" mh-progs) (buffer-file-name))) (call-process "/bin/sh" nil 0 nil "-c" (format "mhdist=1 mhaltmsg=%s mhannotate=1 %s -push %s" (mh-msg-filename msg folder) (expand-file-name "send" mh-progs) (buffer-file-name)))) (mh-annotate-msg msg folder mh-note-dist "-component" "Resent:" "-text" (format "\"%s %s\"" to cc)) (kill-buffer draft) (message "Redistributing...done"))))(defun mh-write-msg-to-file (msg file) "Append MESSAGE to the end of a FILE." (interactive (list (mh-get-msg-num t) (let ((default-dir (if (eq 'write (car mh-last-destination)) (file-name-directory (cdr mh-last-destination)) default-directory))) (read-file-name "Save message in file: " default-dir (expand-file-name "mail.out" default-dir))))) (let ((file-name (mh-msg-filename msg)) (output-file (mh-expand-file-name file))) (setq mh-last-destination (cons 'write file)) (save-excursion (set-buffer (get-buffer-create " *mh-temp*")) (erase-buffer) (insert-file-contents file-name) (append-to-file (point-min) (point-max) output-file))))(defun mh-search-folder (folder) "Search FOLDER for messages matching a pattern." (interactive (list (mh-prompt-for-folder "Search" mh-current-folder t))) (switch-to-buffer-other-window "pick-pattern") (if (or (zerop (buffer-size)) (not (y-or-n-p "Reuse pattern? "))) (mh-make-pick-template) (message "")) (setq mh-searching-folder folder))(defun mh-send (to cc subject) "Compose and send a letter.The letter is composed in mh-letter-mode; see its documentation for moredetails. If `mh-compose-letter-function' is defined, it is called on thedraft and passed three arguments: to, subject, and cc." (interactive "sTo: \nsCc: \nsSubject: ") (let ((config (current-window-configuration))) (delete-other-windows) (mh-send-sub to cc subject config)))(defun mh-send-other-window (to cc subject) "Compose and send a letter in another window.." (interactive "sTo: \nsCc: \nsSubject: ") (let ((pop-up-windows t)) (mh-send-sub to cc subject (current-window-configuration))))(defun mh-send-sub (to cc subject config) "Do the real work of composing and sending a letter.Expects the TO, CC, and SUBJECT fields as arguments.CONFIG is the window configuration before sending mail." (let ((folder mh-current-folder) (msg-num (mh-get-msg-num nil))) (message "Composing a message...") (let ((draft (mh-read-draft "message" (if (file-exists-p (expand-file-name "components" mh-user-path)) (expand-file-name "components" mh-user-path) (if (file-exists-p (expand-file-name "components" mh-lib)) (expand-file-name "components" mh-lib) (error "Can't find components file"))) nil))) (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc) (set-buffer-modified-p nil) (goto-char (point-max)) (message "Composing a message...done") (mh-compose-and-send-mail draft "" folder msg-num to subject cc nil nil config))))(defun mh-show (&optional msg) "Show MESSAGE (default: displayed message).Forces a two-window display with the folder window on top (sizemh-summary-height) and the show buffer below it." (interactive) (if (not msg) (setq msg (mh-get-msg-num t))) (setq mh-showing t) (mh-set-mode-name "mh-e show") (if (not (eql (next-window (minibuffer-window)) (selected-window))) (delete-other-windows)) ; force ourself to the top window (let ((folder mh-current-folder)) (mh-show-message-in-other-window) (mh-display-msg msg folder)) (other-window -1) (if (not (= (1+ (window-height)) (screen-height))) ;not horizontally split (shrink-window (- (window-height) mh-summary-height))) (mh-recenter nil) (if (not (memq msg mh-seen-list)) (mh-push msg mh-seen-list)))(defun mh-sort-folder () "Sort the messages in the current folder by date." (interactive) (mh-process-or-undo-commands mh-current-folder) (setq mh-next-direction 'forward) (mh-set-folder-modified-p t) ; lock folder while sorting (message "Sorting folder...") (mh-exec-cmd "sortm" mh-current-folder) (message "Sorting folder...done") (mh-scan-folder mh-current-folder "all"))(defun mh-toggle-showing () "Toggle the scanning mode/showing mode of displaying messages." (interactive) (if mh-showing (mh-set-scan-mode) (mh-show)))(defun mh-undo (prefix-provided msg-or-seq) "Undo the deletion or refile of the specified MESSAGE(s).Default is the displayed message. If optional prefix argument isprovided, then prompt for the message sequence." (interactive (list current-prefix-arg (if current-prefix-arg (mh-read-seq-default "Undo" t) (mh-get-msg-num t)))) (cond (prefix-provided (mh-mapc (function mh-undo-msg) (mh-seq-to-msgs msg-or-seq))) (t (let ((original-position (point))) (beginning-of-line) (while (not (or (looking-at mh-deleted-msg-regexp) (looking-at mh-refiled-msg-regexp) (and (eq mh-next-direction 'forward) (bobp)) (and (eq mh-next-direction 'backward) (save-excursion (forward-line) (eobp))))) (forward-line (if (eq mh-next-direction 'forward) -1 1))) (if (or (looking-at mh-deleted-msg-regexp) (looking-at mh-refiled-msg-regexp)) (progn (mh-undo-msg (mh-get-msg-num t)) (mh-maybe-show)) (goto-char original-position) (error "Nothing to undo"))))) ;; update the mh-refile-list so mh-outstanding-commands-p will work (mh-mapc (function (lambda (elt) (if (not (mh-seq-to-msgs elt)) (setq mh-refile-list (delq elt mh-refile-list))))) mh-refile-list) (if (not (mh-outstanding-commands-p)) (mh-set-folder-modified-p nil)))(defun mh-undo-msg (msg) ;; Undo the deletion or refile of one MESSAGE. (cond ((memq msg mh-delete-list) (setq mh-delete-list (delq msg mh-delete-list)) (mh-remove-msg-from-seq msg 'deleted t)) (t (mh-mapc (function (lambda (dest) (mh-remove-msg-from-seq msg dest t))) mh-refile-list))) (mh-notate msg ? mh-cmd-note))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -