# HG changeset patch # User Alex Schroeder # Date 1137623395 0 # Node ID a965d43e06eaf757842bc20501335d7b8fa3803a # Parent 83e39e1cce60b142e986f978ccd7fb03262ff69e (rmail-add-label): Doc fix. (rmail-kill-label): Only read labels that the current message has. (rmail-read-label): Possibly only ask for existing labels. (rmail-set-label): Display labels at the end. diff -r 83e39e1cce60 -r a965d43e06ea lisp/mail/rmailkwd.el --- a/lisp/mail/rmailkwd.el Wed Jan 18 22:27:01 2006 +0000 +++ b/lisp/mail/rmailkwd.el Wed Jan 18 22:29:55 2006 +0000 @@ -1,7 +1,7 @@ ;;; rmailkwd.el --- part of the "RMAIL" mail reader for Emacs ;; Copyright (C) 1985, 1988, 1994, 2001, 2002, 2003, 2004, -;; 2005 Free Software Foundation, Inc. +;; 2005, 2006 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: mail @@ -121,37 +121,44 @@ ;;;###autoload (defun rmail-add-label (string) - "Add LABEL to labels associated with current RMAIL message. -Completion is performed over known labels when reading." + "Add LABEL to labels associated with current RMAIL message." (interactive (list (rmail-read-label "Add label"))) (rmail-set-label string t) (rmail-display-labels)) ;;;###autoload (defun rmail-kill-label (string) - "Remove LABEL from labels associated with current RMAIL message. -Completion is performed over known labels when reading." - (interactive (list (rmail-read-label "Remove label"))) + "Remove LABEL from labels associated with current RMAIL message." + (interactive (list (rmail-read-label "Remove label" t))) (rmail-set-label string nil)) ;;;###autoload -(defun rmail-read-label (prompt) - (if (= rmail-total-messages 0) - (error "No messages in this file")) +(defun rmail-read-label (prompt &optional existing) + "Ask for a label using PROMPT. +If EXISTING is non-nil, ask for one of the labels of the current +message." + (when (= rmail-total-messages 0) + (error "No messages in this file")) (with-current-buffer rmail-buffer - (let ((result - (completing-read (concat prompt - (if rmail-last-label - (concat " (default " - (symbol-name rmail-last-label) - "): ") - ": ")) - rmail-label-obarray - nil - nil))) - (if (string= result "") - rmail-last-label - (setq rmail-last-label (rmail-make-label result t)))))) + (let ((result (if existing + (let* ((keywords (rmail-desc-get-keywords + rmail-current-message)) + (last (symbol-name rmail-last-label)) + (default (if (member last keywords) + last + (car keywords)))) + (unless keywords + (error "No labels for the current message")) + (completing-read + (concat prompt " (default " default "): ") + keywords nil t nil nil default)) + (let ((default (symbol-name rmail-last-label))) + (completing-read + (concat prompt (if rmail-last-label + (concat " (default " default "): ") + ": ")) + rmail-label-obarray nil nil nil nil default))))) + (setq rmail-last-label (rmail-make-label result t))))) (defun rmail-set-label (l state &optional n) "Add (STATE is non-nil) or remove (STATE is nil) label L in message N. @@ -171,8 +178,9 @@ (let ((keyword (symbol-name l))) (if state (rmail-desc-add-keyword keyword n) - (rmail-desc-remove-keyword keyword n))))))) - + (rmail-desc-remove-keyword keyword n))) + ;; FIXME: handle redisplay in the summary buffer + (rmail-display-labels))))) ;; Motion on messages with keywords.