[gnu.emacs] superyank and mh-e

edward@vangogh.sybase.com (Ed Hirgelt) (08/03/89)

A while back some kind soul (whose name I forgot, mea culpa) posted some
elisp that integrated superyank and mh-e. Due to some really strange
events on my workstation I lost a couple of directories including my
elisp stuff.

Could the kind soul or some other kind soul either repost or mail me the
routine. I'm feeling to lazy to reinvent that particular wheel.

Thanks,
Ed
--
---------------------------------------------------
Ed Hirgelt		sun!sybase!edward
Sybase, Inc.   		edward@sybase.com
6475 Christie Ave
Emeryville, Ca. 94608

tale@pawl.rpi.edu (David C Lawrence) (08/03/89)

In <EDWARD.89Aug2113405@vangogh.sybase.com> edward@vangogh.sybase.com
(Ed Hirgelt) writes:

Ed> A while back some kind soul (whose name I forgot, mea culpa) posted some
                      ^^^^ ^^^^ hey, let's not start any rumours here
Ed> elisp that integrated superyank and mh-e.

Ed> Could the kind soul or some other kind soul either repost or mail me the
Ed> routine. I'm feeling to lazy to reinvent that particular wheel.

Well I would have mailed it to you if I saw your message yesterday but
wonder of wonders someone sent me the one and only comment I've heard
on it until now and it was a minor bugfix.  It's just one silly
function, but here 'tis. 

Actually, that kind soul you mention might be someone else who had
rewritten the mh-insert-letter function to use superyank too.  Maybe
I'll put that in if anyone bothers to ask for it.  I prefer yanking
with this function though because it is the same as the original
mh-yank-cur-msg with the exception of using superyank for citation.

Dave
--cut here--
;;; To use put the following in .emacs:
;;;    (setq mh-letter-mode-hook '(lambda () (require 'mh-etc)))
;;; and save this file as mh-etc.el in a directory in load-path.
;;; Byte-compiling is sort of a waste for just one function, but whatever
;;; flips your bits.

;;; History
;;;  3-Aug-89  David C Lawrence (tale@pawl.rpi.edu)
;;;	Incorporated bugfix by Johan Wilden <jw@sics.se> to save point in
;;;	mh-show-buffer before sy-scan-rmail-for-names moves it.

(require 'superyank)
(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))
             (mh-show-buffer-point (save-excursion (set-buffer mh-show-buffer)
                                                   (point)))
             (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 mh-show-buffer-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 mh-show-buffer-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 here--
--
 (setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))