summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-10-11 17:38:48 +0000
committerRichard M. Stallman <rms@gnu.org>1994-10-11 17:38:48 +0000
commit91d59133b157e98d066cfe71c0764d21db0a3a37 (patch)
tree92afbb2dbfc2f1e2c32e9011f68e1e29fb6df070 /lisp
parentb38eb88b3e5e1018c4a9a6534eac40ba18516d46 (diff)
downloademacs-91d59133b157e98d066cfe71c0764d21db0a3a37.tar.gz
(rmail-find-all-files): Fix several errors and make faster.
Always return a single-level list of file names. (rmail-construct-io-menu): If FILES is null, turn off the menus. (rmail-disable-menu): A phony "command", always disabled in menus. (rmail-list-to-menu): Reverse the list L.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mail/rmail.el40
1 files changed, 28 insertions, 12 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 2d409b6ea11..2510e3cb46b 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -708,19 +708,27 @@ Instead, these commands are available:
(interactive "FRun rmail on RMAIL file: ")
(rmail filename))
+;; Return a list of file names for all files in or under START
+;; whose names match rmail-secondary-file-regexp.
+;; This includes START itself, if that name matches.
+;; But normally START is a directory.
(defun rmail-find-all-files (start)
(if (file-accessible-directory-p start)
- (let ((files (directory-files start nil
- rmail-secondary-file-regexp))
+ ;; Don't sort here.
+ (let ((files (directory-files start t
+ rmail-secondary-file-regexp t))
(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)))
+ (setq ret (nconc
+ (rmail-find-all-files file)
+ ret)))
+ ;; Sort here instead of in directory-files
+ ;; because this list is usually much shorter.
+ (sort ret 'string<))
+ (if (string-match rmail-secondary-file-regexp start)
+ (list (file-name-nondirectory start)))))
(defun rmail-list-to-menu (menu-name l action &optional full-name)
(let ((menu (make-sparse-keymap menu-name)))
@@ -748,23 +756,31 @@ Instead, these commands are available:
rmail-secondary-file-directory))))))
(define-key menu (vector (intern name))
(cons name command))))
- l)
+ (reverse l))
menu))
+;; This command is always "disabled" when it appears in a menu.
+(put 'rmail-disable-menu 'menu-enable ''nil)
+
(defun rmail-construct-io-menu ()
(let ((files (rmail-find-all-files rmail-secondary-file-directory)))
- (if (listp files)
+ (if 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)
+ 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)))))))
+ files
+ 'rmail-output-to-rmail-file))))
+
+ (define-key rmail-mode-map [menu-bar classify input-menu]
+ '("Input Rmail File" . rmail-disable-menu))
+ (define-key rmail-mode-map [menu-bar classify output-menu]
+ '("Output Rmail File" . rmail-disable-menu)))))
;;;; *** Rmail input ***