changeset 8909:d9c10eb46ce9

Build proper keymap for the "Input (menu)" and "Output (menu)" submenus: (rmail-find-all-files, rmail-list-to-menu, rmail-construct-io-menu): New functions. (rmail-input-menu): Function deleted. (rmail). Call rmail-construct-io-menu. (rmail-mode-map): 'Input Rmail file (menu)' renamed to `Input Rmail File'. `Output (Rmail Menu)' renamed to 'Output Rmail File'.
author Richard M. Stallman <rms@gnu.org>
date Mon, 19 Sep 1994 05:01:33 +0000
parents 25d8b804abd3
children 964b419c227a
files lisp/mail/rmail.el
diffstat 1 files changed, 62 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Mon Sep 19 04:32:41 1994 +0000
+++ b/lisp/mail/rmail.el	Mon Sep 19 05:01:33 1994 +0000
@@ -280,7 +280,8 @@
       ;; determine already unseen messages first, as rmail-get-new-mail
       ;; positions on the first new message, thus marking it as seen.
       (rmail-show-message existing-unseen))
-    (if rmail-display-summary (rmail-summary))))
+    (if rmail-display-summary (rmail-summary))
+    (rmail-construct-io-menu)))
 
 ;; Given the value of MAILPATH, return a list of inbox file names.
 ;; This is turned off because it is not clear that the user wants
@@ -414,10 +415,10 @@
   (cons "Classify" (make-sparse-keymap "Classify")))
 
 (define-key rmail-mode-map [menu-bar classify input-menu]
-  '("Input Rmail file (menu)..." . rmail-input-menu))
+  nil)
 
 (define-key rmail-mode-map [menu-bar classify output-menu]
-  '("Output (Rmail menu)..." . rmail-output-menu))
+  nil)
 
 (define-key rmail-mode-map [menu-bar classify output-inbox]
   '("Output (inbox)..." . rmail-output))
@@ -691,31 +692,66 @@
   (interactive "FRun rmail on RMAIL file: ")
   (rmail filename))
 
-;; Choose a .xmail file in dir rmail-secondary-file-directory.
-(defun rmail-secondary-file-menu (event)
-  (let ((files (directory-files rmail-secondary-file-directory nil
-				rmail-secondary-file-regexp)))
-    (if files
-	(let* ((menu (list "Rmail Files"
-			   (cons "Rmail Files"
-				 (mapcar (function (lambda (f) (cons f f)))
-					 files))))
-	       (chosen (x-popup-menu event menu)))
-	  (if chosen
-	      (expand-file-name chosen rmail-secondary-file-directory)))
-      (message "No files matching %s%s found"
-	       rmail-secondary-file-directory rmail-secondary-file-regexp)
-      nil)))
+(defun rmail-find-all-files (start)
+  (if (file-accessible-directory-p start)
+      (let ((files (directory-files start nil
+				    rmail-secondary-file-regexp))
+	    (ret nil))
+	(while files
+	  (setq file (car files))
+	  (setq files (cdr files))
+	  (setq ret (cons
+		     (rmail-find-all-files (concat start "/" file))
+		     ret))) 
+	(cons (file-name-nondirectory start) ret))
+    (file-name-nondirectory start)))
 
+(defun rmail-list-to-menu (menu-name l action &optional full-name)
+  (let ((menu (make-sparse-keymap menu-name)))
+    (mapcar
+     (function (lambda (item)
+		 (if (consp item)
+		     (progn
+		       (setq command
+			     (rmail-list-to-menu (car item) (cdr item) 
+						 action 
+						 (if full-name
+						     (concat full-name "/"
+							     (car item))
+						   (car item))))
+		       (setq name (car item)))
+		   (progn
+		     (setq name item)
+		     (setq command 
+			   (list 'lambda () '(interactive)
+				 (list action
+				  (expand-file-name 
+				   (if full-name
+				       (concat full-name "/" item)
+				     item)
+				   rmail-secondary-file-directory))))))
+		 (define-key menu (vector (intern name))
+		   (cons name command))))
+     l)
+    menu))
+ 
+(defun rmail-construct-io-menu ()
+  (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
+    (if (listp files)
+	(progn
+	  (define-key rmail-mode-map [menu-bar classify input-menu]
+	    (cons "Input Rmail File" 
+		  (rmail-list-to-menu "Input Rmail File" 
+				      (cdr files) 
+				      'rmail-input)))
+	  (define-key rmail-mode-map [menu-bar classify output-menu]
+	    (cons "Output Rmail File" 
+		  (rmail-list-to-menu "Output Rmail File" 
+				      (cdr files) 
+				      'rmail-output-to-rmail-file)))))
+    (message "No files matching %s/%s found"
+	     rmail-secondary-file-directory rmail-secondary-file-regexp)))
 
-(defun rmail-input-menu (event)
-  "Choose a new Rmail file to edit, with a menu.
-The variables `rmail-secondary-file-directory' and
-`rmail-secondary-file-regexp' control which files are offered in the menu."
-  (interactive "e")
-  (let ((file-name (rmail-secondary-file-menu event)))
-    (if file-name
-	(rmail-input file-name))))
 
 ;;;; *** Rmail input ***
 
@@ -2332,10 +2368,6 @@
   "Append this message to Unix mail file named FILE-NAME."
   t)
 
-(autoload 'rmail-output-menu "rmailout"
-  "Output current message to another Rmail file, chosen with a menu."
-  t)
-
 ;;;; *** Rmail undigestification ***
 
 (autoload 'undigestify-rmail-message "undigest"