+ string))))
+ (ecomplete-save))
+
+(defun message-next-abbrev ()
+ "Display the next possible abbrev for the text before point."
+ (interactive)
+ (message-display-abbrev 'next))
+
+(defun message-prev-abbrev ()
+ "Display the previous possible abbrev for the text before point."
+ (interactive)
+ (message-display-abbrev 'prev))
+
+(defun message-display-abbrev (direction)
+ (when (and (message-point-in-header-p)
+ (save-excursion
+ (save-restriction
+ (message-narrow-to-field)
+ (goto-char (point-min))
+ (looking-at "To\\|Cc"))))
+ (let ((word (buffer-substring (point) (save-excursion
+ (backward-word) (point)))))
+ (if (eq direction 'next)
+ (ecomplete-next-match 'mail word)
+ (ecomplete-prev-match 'mail word)))))
+
+(defun message-newline-and-indent ()
+ "If looking at an abbrev, insert that. Otherwise `newline-and-indent'."
+ (interactive)
+ (let ((current-message (current-message)))
+ (debug current-message)
+ (if (and (not (zerop (length current-message)))
+ (get-text-property 0 'ecomplete current-message))
+ (insert (ecomplete-return-current-match))
+ (newline-and-indent))))