ange@hplb.hpl.hp.com (Andy Norman) (07/01/89)
I enclose some code which allows mh-e users to take advantage of the recently
posted superyank package.
Enjoy...
-- ange --
--------------------------------------------------------------------------------
(require 'mh-e)
(defun mh-yank-msg (confirm buf)
"Insert the message in the given buffer into the current buffer citing as
per user preferences."
(local-set-key "\C-cq" 'sy-fill-paragraph-manually)
(local-set-key "\C-c\i" 'sy-insert-persist-attribution)
(local-set-key "\C-c\C-o" 'sy-open-line)
(let ((mail-reply-buffer buf))
(save-window-excursion
(save-restriction
(narrow-to-region (point-max) (point-max))
(sy-yank-original confirm)))))
(defun mh-yank-cur-msg (confirm)
"Insert the currently displayed message into the draft buffer citing as per user
preferences. Numeric argument forces confirmation."
(interactive "P")
(if (and (boundp 'mh-sent-from-folder)
mh-sent-from-folder
mh-sent-from-msg)
(let ((buf (save-excursion
(set-buffer mh-sent-from-folder)
(if mh-delete-yanked-msg-window
(delete-windows-on mh-show-buffer))
mh-show-buffer)))
(mh-yank-msg confirm buf))
(error "There is no current message.")))
(defun mh-insert-letter (confirm folder msg)
"Insert a message from any folder into the draft buffer citing as per
user preferences. Numeric arguement forces confirmation."
(interactive
(list current-prefix-arg
(mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
(read-input (format "Message number%s: "
(if mh-sent-from-msg
(format " [%d]" mh-sent-from-msg)
"")))))
(if (equal msg "")
(setq msg (format "%d" mh-sent-from-msg)))
(let* ((file (mh-expand-file-name msg (mh-expand-file-name folder)))
(buf (create-file-buffer file)))
(save-excursion
(set-buffer buf)
(insert-file-contents file)
(set-buffer-modified-p nil))
(mh-yank-msg confirm buf)
(kill-buffer buf)))
--
-- ange --
ange@hplb.hpl.hp.comtale@pawl.rpi.edu (David C Lawrence) (07/03/89)
I had already mailed this off to superyank@cme.nist.gov last week;
curiously, mail to one of the addresses (@hpl.hp.com) bounced, who I
guess is ange. I had also mailed it concurrently to
info-gnu-emacs@ai.mit.edu but that bounced with an unknown user as did
the same address at prep. (Len? Bob? Temporary thing or did the
list move or what?)
Anyway, this function I put in mh-etc.el and require it from my
mh-compose-letter-hook. The advantage I see with it over ange's code
is that it behaves like the original mh-yank-cur-msg with the
exception that it will quote like superyank. This is a big win for
people like me who don't like to yank the whole 4k message when I just
want to quote three lines of it -- I set the region in the
mh-show-buffer and yank away. The disadvantage compared to ange's
functions are that I didn't do anything with mh-insert-letter so it
still uses the old style mh-ins-buf-prefix. I could write that if
people really want it ...
Dave
---cut---
(require 'mh-e)
(provide 'mh-etc)
(defun mh-yank-cur-msg (arg)
"Insert the currently displayed message into the draft buffer. Prefix each
line in the message by calling sy-insert-citation. If a region is set in the
message's buffer, then only the region will be inserted. Otherwise, the entire
message will be inserted if mh-yank-from-start-of-msg is non-nil. If this
variable is nil, the portion of the message following the point will be yanked.
If mh-delete-yanked-msg-window is non-nil, any window displaying the yanked
message will be deleted.
NOTE: this function has been modified to work with the superyank package."
(interactive "P")
(local-set-key "\C-cq" 'sy-fill-paragraph-manually)
(local-set-key "\C-ci" 'sy-insert-persist-attribution)
(local-set-key "\C-c\C-o" 'sy-open-line)
(if (and (boundp 'mh-sent-from-folder) mh-sent-from-folder mh-sent-from-msg)
(let* ((sy-confirm-always-p (if (consp arg) t sy-confirm-always-p))
(mh-show-buffer (save-excursion (set-buffer mh-sent-from-folder)
mh-show-buffer))
(attribution (sy-scan-rmail-for-names mh-show-buffer))
(start (point)))
(if mh-delete-yanked-msg-window (delete-windows-on mh-show-buffer))
(set-mark (point))
(insert-before-markers
(save-excursion
(set-buffer mh-show-buffer)
(sy-yank-fields (point-min))
(cond
((mark) (buffer-substring (point) (mark)))
((eq 'body mh-yank-from-start-of-msg)
(mh-goto-header-end 1)
(buffer-substring (point) (point-max)))
(mh-yank-from-start-of-msg (buffer-string))
(t (buffer-substring (point) (point-max))))))
(sy-rewrite-headers start)
(mail-yank-clear-headers (point) (mark))
(setq sy-persist-attribution (concat attribution " "))
(sy-insert-citation (point) (mark) attribution))
(error "There is no current message.")))
--cut--
--
(setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))
"Drinking coffee for instant relaxation? That's like drinking
alcohol for instant motor skills." -- Mike Price (?)