X-Git-Url: https://git.donarmstrong.com/?p=lib.git;a=blobdiff_plain;f=emacs_el%2Fpost.el;h=46840738a283a1c2c9ca7da5f2dfb6edb6d7a8c7;hp=6c1caded0e9d239af5da5e92b5e6a55cb3611ddc;hb=bb6f856e564fafbcb00d953c5d5ac534430e2e7a;hpb=dfabe3732e6bcdce91dff00dbfb916e9c932396e diff --git a/emacs_el/post.el b/emacs_el/post.el index 6c1cade..4684073 100644 --- a/emacs_el/post.el +++ b/emacs_el/post.el @@ -1,9 +1,9 @@ -; $Id: post.el,v 2.4 2004/07/23 23:13:17 rreid Exp rreid $ +; $Id: post.el,v 1.10 2008/02/24 23:49:23 rreid Exp $ ;; post.el --- Use (X?)Emacs(client) as an external editor for mail and news. ;;; Authors: Eric Kidd , ;;; Dave Pearson , -;;; Rob Reid , +;;; Rob Reid , ;;; Roland Rosenfeld ;; This is free software distributed under the GPL, yadda, yadda, yadda. @@ -11,15 +11,18 @@ ;; information. Send us your feature requests and patches, and we'll try ;; to integrate everything. -;;; Maintainer: Rob Reid +;;; Maintainers: Rob Reid and +;;; Philip J. Hollenback ;;; Keywords: mail ;;; Commentary: -;; This is a major mode for use with Mutt, the spiffy *nix mailreader du jour -;; (See http://www.mutt.org/), slrn, the spiffy *nix newsreader du jour, or -;; whatever you can get it to work with. To use this mode, add the following -;; line to the .emacs file in your home directory: +;; This is a major mode for use with mutt (http://www.mutt.org/), slrn, or most +;; email and newsreaders that allow you to use an external editor. +;; +;; Installation: +;; +;; Add the following line to the .emacs(.el) file in your home directory: ;; ;; (load "/your/local/path/to/this/file/post") ;; @@ -30,7 +33,8 @@ ;; your sitewide default.el to (require 'post). ;; ;; You may find the latest version of this mode at -;; http://astro.utoronto.ca/~reid/mutt/ +;; http://www.cv.nrao.edu/~rreid/software/email/ or possibly +;; http://sourceforge.net/projects/post-mode/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -56,6 +60,25 @@ ;;; Revision History ;;; ;;; $Log: post.el,v $ +;;; Revision 1.10 2008/02/24 23:49:23 rreid +;;; *** empty log message *** +;;; +;;; Revision 1.9 2008/02/24 23:46:23 rreid +;;; I really hate the way RCS/VC mucks around with the version number and log. +;;; It's not as dwim as it thinks it is. +;;; +;;; Revision 1.8 2008/02/24 23:43:46 rreid +;;; Updated email address. +;;; +;;; Revision 2.402 2008/02/24 23:31:19 rreid +;;; Emacs 22 finally fixed (how-many) to return an int instead of a string, +;;; i.e. 13 instead of '13 occurrences'. A few people noticed that the change +;;; broke my workaround, but Erik Mugele submitted the winning patch that works +;;; for all emacs versions (I hope). +;;; +;;; This, and the below, are real entries, with real version numbers. Some of +;;; the above are fake commits to get the version number back in sync. +;;; ;;; Revision 2.401 2004/07/23 16:27:29 rreid ;;; Fixed post-delete-quoted-signatures to not remove sneaky things like quoted ;;; double dash arrows. Thanks go to Felix Klee for a clear bug report. @@ -286,12 +309,18 @@ ;; XEmacs gnuserv uses slightly different functions than the GNU Emacs ;; server, and some people are still wasting time and CPU cycles by starting ;; up a new emacs each time. - (cond ((fboundp 'server-edit) - (fset 'post-finish 'server-edit)) - ((fboundp 'gnuserv-kill-buffer-function) - (fset 'post-finish 'gnuserv-kill-buffer-function)) - (t - (fset 'post-finish 'save-buffers-kill-emacs))) + (fset 'post-finish (cond ((fboundp 'server-edit) + 'server-edit) + ((fboundp 'gnuserv-kill-buffer-function) + 'gnuserv-kill-buffer-function) + (t + 'save-buffers-kill-emacs))) +;; (cond ((fboundp 'server-edit) +;; (fset 'post-finish 'server-edit)) +;; ((fboundp 'gnuserv-kill-buffer-function) +;; (fset 'post-finish 'gnuserv-kill-buffer-function)) +;; (t +;; (fset 'post-finish 'save-buffers-kill-emacs))) ;; If customize isn't available just use defvar instead. (unless (fboundp 'defgroup) @@ -318,7 +347,7 @@ is very primitive), you can type \\[fill-paragraph] to rewrap the paragraph." :type 'boolean :group 'post) -(defcustom post-mail-message "mutt-[a-z0-9]+-[0-9]+-[0-9]+\\'" +(defcustom post-mail-message "mutt-[a-z0-9]+-[0-9]+-[0-9]+.*\\'" "*Regular expression which matches your mailer's temporary files." :type 'string :group 'post) @@ -666,7 +695,7 @@ post-signature-text-face) (cond (post-has-attachment) ((equal post-should-prompt-for-attachment 'Never)) ((or (equal post-should-prompt-for-attachment 'Always) - (post-body-says-attach)) + (post-body-says-attach-p)) (post-prompt-for-attachment))) (basic-save-buffer) @@ -679,7 +708,8 @@ post-signature-text-face) ;; Added by Rob Reid 10/13/1998 to prevent accumulating *Composing* buffers ;; when using (emacs|gnu)client. Helped by Eric Marsden's Eliza example in ;; http://www.ssc.com/lg/issue29/marsden.html - (kill-buffer post-buf)) +; (kill-buffer post-buf) +) (defun post-goto-body () "Go to the beginning of the message body." @@ -826,7 +856,7 @@ the signatures in `post-variable-signature-source' must be separated by (nth r marks-st) (nth r marks-end)))) (kill-buffer (current-buffer))) (goto-char (post-kill-signature)) - (insert-string "-- \n") + (insert "-- \n") (insert sig) (if (file-readable-p post-fixed-signature-source) (insert-file-contents post-fixed-signature-source) @@ -863,7 +893,7 @@ the signatures in `post-variable-signature-source' must be separated by (let ((sig (buffer-substring-no-properties sig-start sig-end))) (switch-to-buffer post-select-signature-last-buffer) (goto-char (post-kill-signature)) - (insert-string "-- \n") + (insert "-- \n") (insert sig)) (if (file-readable-p post-fixed-signature-source) (insert-file-contents post-fixed-signature-source)) @@ -898,7 +928,7 @@ the signatures in `post-variable-signature-source' must be separated by (setq sig-to-load (buffer-substring-no-properties sig-start (point))) (switch-to-buffer post-select-signature-last-buffer) (goto-char (post-kill-signature)) - (insert-string "-- \n") + (insert "-- \n") (insert-file (concat post-signature-directory sig-to-load)) (message "Signature set to %s%s" post-signature-directory sig-to-load) (post-select-signature-quit))) @@ -911,8 +941,47 @@ the signatures in `post-variable-signature-source' must be separated by (goto-char post-select-signature-last-point) (delete-other-windows)) +(defun post-attach-file () + "Prompt for an attachment." + (interactive) + (let ((file (read-file-name "Attach file: " nil nil t nil)) + (description (string-read "Description: "))) + (header-attach-file file description))) + ;;; Non-interactive functions +(defun post-prompt-for-attachment () + "Prompt for an attachment." + (if (y-or-n-p "Do you want to attach anything? ") + (post-attach-file))) + +(defun post-references-p () + "Is there a References header in this buffer?" + (save-excursion + (goto-char (point-min)) + (looking-at "^References: "))) + +(defun post-body-says-attach-p () + "Check if attach appears in the body." + (post-goto-body) + + ;; Aargh it's annoying that how-many returns a string, + ;; "13 occurences" instead of a number, 13. + ;; As of Emacs 22 how-many returns an integer number. Consideration + ;; must be taken for both newer and older versions. + (let ((total-attach (how-many post-attachment-regexp))) + (if (string= (type-of total-attach) 'string) + (setq total-attach (string-to-number (how-many post-attachment-regexp)))) + ;; And this mess is just to catch the unlikely false alarm of + ;; "attach" being in the signature, but not in the body. + (if (> total-attach 0) + (progn (post-goto-signature) + (if (string= (type-of (how-many post-attachment-regexp)) 'string) + (> total-attach (string-to-number (how-many + post-attachment-regexp))) + (> total-attach (how-many + post-attachment-regexp))))))) + (defun post-ask-for-address-with-default (header) "Prompt for an email address, showing default. Argument HEADER the header type." @@ -1073,33 +1142,6 @@ When you finish editing this message, type \\[post-save-current-buffer-and-exit] (message (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done.")))) -(defun post-references-p () - "Is there a References header in this buffer?" - (save-excursion - (goto-char (point-min)) - (looking-at "^References: "))) - -(defun post-body-says-attach () - "Check if attach appears in the body." - (post-goto-body) - - ;; Aargh it's annoying that how-many returns a string, - ;; "13 occurences" instead of a number, 13. - (let ((total-attach (string-to-int (how-many post-attachment-regexp)))) - ;; And this mess is just to catch the unlikely false alarm of - ;; "attach" being in the signature, but not in the body. - (if (> total-attach 0) - (progn (post-goto-signature) - (> total-attach (string-to-int (how-many - post-attachment-regexp))))))) - -(defun post-prompt-for-attachment () - "Prompt for an attachment." - (if (y-or-n-p "Do you want to attach anything? ") - (let ((file (read-file-name "Attach file: " nil nil t nil)) - (description (string-read "Description: "))) - (header-attach-file file description)))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Post Header Mode @@ -1144,7 +1186,7 @@ Optional argument ARG ." (when (re-search-forward (concat "^\\($\\|" field ": \\)")) (if (looking-at "^$") (progn - (insert-string field ": \n") + (insert field ": \n") (forward-char -1)) (header-position-on-value)))))) @@ -1177,7 +1219,7 @@ Argument DESCRIPTION MIME description." (widen) (goto-char (point-min)) (search-forward-regexp "^$") - (insert-string (concat "Attach: " (file-truename file) " " + (insert (concat "Attach: " (file-truename file) " " description "\n")) (message (concat "Attached '" file "'.")) (setq post-has-attachment t)))))) @@ -1286,7 +1328,7 @@ Optional argument DEFAULT ." (cond ((post-find-header-line header) (beginning-of-line) (kill-line) - (insert-string (concat header ": " value))) + (insert (concat header ": " value))) (t (header-append-value header value)))) (message "%s set to %s" header value)) @@ -1295,7 +1337,7 @@ Optional argument DEFAULT ." "Add a HEADER and set it's VALUE (if header exists, will add multiple headers)." (goto-char (point-min)) (search-forward-regexp "^$" nil t) - (insert-string (concat header ": " value "\n"))) + (insert (concat header ": " value "\n"))) ;;; Setup the mode map for the select-signature buffer. (if post-select-signature-mode-map nil