home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / MouseAndMenuEmacs / rmail-menus.el < prev    next >
Encoding:
Text File  |  1990-05-31  |  6.1 KB  |  178 lines

  1. ;;;; Rmail mode menus
  2. ;;;; Russell Ritchie, Scottish HCI Centre, <russell@uk.ac.strath.hci>.
  3. ;;;; Thu May 12 14:08:42 1988 
  4.  
  5. (if (eq window-system 'x)
  6.     (require 'x-menus)
  7.   (require 'hci-menus))
  8. (provide 'rmail-menus)
  9.  
  10. (defun rmail-search-backward ()
  11.   "Does the same thing as rmail-search, but searches backwards."
  12.   (let ((regexp
  13.      (read-string
  14.       (concat "Reverse Rmail search (regexp): "
  15.           (if rmail-search-last-regexp
  16.               (concat "(default " rmail-search-last-regexp ") ")
  17.             ""))))
  18.     (omin (point-min))
  19.     (omax (point-max))
  20.     (opoint (point))
  21.     (win nil)
  22.     (msg rmail-current-message))
  23.     ;; Trash the search regexp memory if necessary
  24.     (cond ((string= regexp "")
  25.        (setq regexp rmail-search-last-regexp))
  26.       ((not (string= regexp ""))
  27.        (setq rmail-search-last-regexp regexp))
  28.       ((not rmail-search-last-regexp)
  29.        (error "No previous Rmail search string")))
  30.     ;; Say what's going on for slow things.
  31.     (message "Reverse Rmail search for %s..." regexp)
  32.     (unwind-protect
  33.     (progn
  34.       (widen)
  35.       ;; Check messages one by one, decrementing message number
  36.       ;; but searching forward through each message.
  37.       (while (and (null win) (> msg 1))
  38.         (goto-char (rmail-msgbeg (setq msg (1- msg))))
  39.         (setq win (re-search-forward
  40.                regexp (rmail-msgend msg) t))))
  41.       (if win
  42.       (progn
  43.         ;; This is a reverse search and we found a message,
  44.         ;; search backward thru this message to position point.
  45.         (goto-char (rmail-msgend msg))
  46.         (re-search-backward regexp (rmail-msgbeg msg) t)
  47.         (setq win (point))
  48.         (rmail-show-message msg)
  49.         (message "Reverse Rmail search for %s...done" regexp)
  50.         (goto-char win))
  51.     (goto-char opoint)
  52.     (narrow-to-region omin omax)
  53.     (ding)
  54.     (message "Reverse Searched failed: %s" regexp)))))
  55.  
  56. (if (eq window-system 'x)
  57.  
  58.     (progn
  59.  
  60. (defXmenu 'rmail-menu
  61.   '("Rmail Menu"
  62.     ("Read Menu"
  63.      ("next non-deleted message"
  64.       call-interactively 'rmail-next-undeleted-message)
  65.      ("previous non-deleted message"
  66.       call-interactively 'rmail-previous-undeleted-message)
  67.      ("next message (deleted or not)"
  68.       call-interactively 'rmail-next-message)
  69.      ("previous message (deleted or not)"
  70.       call-interactively 'rmail-previous-message)
  71.      ("last message" rmail-last-message))
  72.     ("Search Menu"
  73.      ("for message by number?" call-interactively 'rmail-show-message)
  74.      ("for next message containing string?" call-interactively 'rmail-search)
  75.      ("previous message containing string?"
  76.       call-interactively 'rmail-search-backward))
  77.     ("Save Menu"
  78.      ("to Rmail file" call-interactively 'rmail-output-to-rmail-file)
  79.      ("to UNIX mail file" call-interactively 'rmail-output)
  80.      ("to Rmail file then delete"
  81.       progn
  82.       (call-interactively 'rmail-output-to-rmail-file)
  83.       (rmail-delete-forward))
  84.      ("to UNIX mail file then delete"
  85.       progn
  86.       (call-interactively 'rmail-output)
  87.       (rmail-delete-forward)))
  88.     ("Delete Menu"
  89.      ("this message then move forwards" rmail-delete-forward)
  90.      ("this message then move backwards"
  91.       prefix-arg-supplied 'rmail-delete-forward)
  92.      ("Undelete preceding message" rmail-undelete-previous-message))
  93.     ("Reply Menu"
  94.      ("Forward this message" rmail-forward)
  95.      ("Reply to the sender of this message" prefix-arg-supplied 'rmail-reply)
  96.      ("Reply to all recipients of this message"
  97.       call-interactively 'rmail-reply))
  98.     ("Miscellaneous Menu"
  99.      ("Give a one-line summary of all messages" rmail-summary)
  100.      ("Get new mail" rmail-get-new-mail)
  101.      ("Other Menus" x-mouse-other-menus)
  102.      ("Quit Rmail" rmail-quit))))
  103.  
  104.  (defXmenu 'rmailsum-menu
  105.   '("Rmail Summary Menu"
  106.     ("Rmail Summary Menu"
  107.      ("Move to next undeleted message after the cursor location"
  108.       call-interactively 'rmail-summary-next-msg)
  109.      ("Move to previous undeleted message after the cursor location"
  110.       rmail-summary-previous-msg)
  111.      ("Move to next message after the cursor location"
  112.       rmail-summary-next-all)
  113.      ("Move to previous message after the cursor location"
  114.       rmail-summary-previous-all)
  115.      ("Jump to the message at the cursor location"
  116.       rmail-summary-goto-msg)
  117.      ("Delete the message at the cursor location and move to next message"
  118.       rmail-summary-delete-forward)
  119.      ("Undelete this or previous deleted message"
  120.       rmail-summary-undelete)
  121.      ("Scroll displayed Rmail message forward"
  122.       rmail-summary-scroll-msg-up)
  123.      ("Scroll displayed Rmail message backward"
  124.       rmail-summary-scroll-msg-down)
  125.      ("Exit and kill the Summary window"
  126.       rmail-summary-exit)
  127.      ("Other Menus" x-mouse-other-menus)
  128.      ("Quit Rmail" rmail-summary-quit))))
  129.  
  130. )
  131.  
  132. (defHCImenu rmail-quit-menu
  133.   ("Rmail" rmail-quit)
  134.   ("Emacs" . emacs-quit-menu))
  135.  
  136. (defHCImenu rmail-search-menu
  137.   ("Search forwards" call-interactively 'rmail-search)
  138.   ("Search backwards" call-interactively 'rmail-search-backward))
  139.  
  140. (defHCImenu rmail-specific-message-menu
  141.   ("Message number?" call-interactively 'rmail-show-message)
  142.   ("Message containing string?" . rmail-search-menu))
  143.  
  144. (defHCImenu rmail-motion-menu
  145.   ("Next non-deleted message"
  146.    call-interactively 'rmail-next-undeleted-message)
  147.   ("Previous non-deleted message"
  148.    call-interactively 'rmail-previous-undeleted-message)
  149.   ("Next message (deleted or not)"
  150.    call-interactively 'rmail-next-message)
  151.   ("Previous message (deleted or not)"
  152.    call-interactively 'rmail-previous-message)
  153.   ("Last message" rmail-last-message)
  154.   ("Specific message:" . rmail-specific-message-menu))
  155.  
  156. (defHCImenu rmail-delete-menu
  157.   ("then move forwards" rmail-delete-forward)
  158.   ("then move backwards" prefix-arg-supplied 'rmail-delete-forward))
  159.  
  160. (defHCImenu rmail-reply-menu
  161.   ("Only to the sender" call-interactively 'rmail-reply)
  162.   ("To all recipients of original message" prefix-arg-supplied 'rmail-reply))
  163.  
  164. (defHCImenu rmail-menu
  165.   ("Rmail Menu")
  166.   ("Move to" . rmail-motion-menu)
  167.   ("Delete this message" . rmail-delete-menu)
  168.   ("Undelete preceding message" rmail-undelete-previous-message)
  169.   ("Forward this message" rmail-forward)
  170.   ("Reply to this message" . rmail-reply-menu)
  171.   ("Get new mail" rmail-get-new-mail)
  172.   ("Other menus" . other-menus-menu)
  173.   ("Quit" . rmail-quit-menu))
  174.  
  175.  
  176.  
  177.   )
  178.