From 078537773c499837ba0b0253c449cc1564eaea47 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Fri, 14 Apr 2006 10:23:45 +0000 Subject: [PATCH] * ecomplete.el (ecomplete-display-matches): Allow automatic display. * message.el (message-strip-forbidden-properties): Display abbrevs. (message-display-abbrev): Get automatic display right. --- lisp/ChangeLog | 7 +++++++ lisp/ecomplete.el | 24 ++++++++++++++---------- lisp/message.el | 18 +++++++++++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3c455f009..3aa0a2db2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,12 @@ 2006-04-14 Lars Magne Ingebrigtsen + * ecomplete.el (ecomplete-display-matches): Allow automatic + display. + + * message.el (message-strip-forbidden-properties): Display + abbrevs. + (message-display-abbrev): Get automatic display right. + * ecomplete.el (ecomplete-display-matches): Use M-n/M-p keystrokes. diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el index 862a7a298..e9eef9d5a 100644 --- a/lisp/ecomplete.el +++ b/lisp/ecomplete.el @@ -97,7 +97,7 @@ 'face 'isearch)) (buffer-string))))) -(defun ecomplete-display-matches (type word) +(defun ecomplete-display-matches (type word &optional choose) (let* ((matches (ecomplete-get-matches type word)) (line 0) (max-lines (when matches (- (length (split-string matches "\n")) 2))) @@ -107,15 +107,19 @@ (message "No ecomplete matches") nil) (setq highlight (ecomplete-highlight-match-line matches line)) - (while (not (memq (setq command (read-event highlight)) '(? return))) - (cond - ((eq command (aref (kbd "M-n") 0)) - (setq line (min (1+ line) max-lines))) - ((eq command (aref (kbd "M-p") 0)) - (setq line (max (1- line) 0)))) - (setq highlight (ecomplete-highlight-match-line matches line))) - (when (eq command 'return) - (nth line (split-string matches "\n")))))) + (if (not choose) + (progn + (message highlight) + nil) + (while (not (memq (setq command (read-event highlight)) '(? return))) + (cond + ((eq command (aref (kbd "M-n") 0)) + (setq line (min (1+ line) max-lines))) + ((eq command (aref (kbd "M-p") 0)) + (setq line (max (1- line) 0)))) + (setq highlight (ecomplete-highlight-match-line matches line))) + (when (eq command 'return) + (nth line (split-string matches "\n"))))))) (defun ecomplete-highlight-match-line (matches line) (with-temp-buffer diff --git a/lisp/message.el b/lisp/message.el index 452f60fc9..bde3bba12 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -2517,6 +2517,8 @@ These properties are essential to work, so we should never strip them." "Strip forbidden properties between BEGIN and END, ignoring the third arg. This function is intended to be called from `after-change-functions'. See also `message-forbidden-properties'." + (when (eq message-mail-alias-type 'ecomplete) + (message-display-abbrev)) (when (and message-strip-special-text-properties (message-tamago-not-in-use-p begin)) (let ((buffer-read-only nil) @@ -7177,9 +7179,9 @@ From headers in the original article." string)))) (ecomplete-save)) -(defun message-display-abbrev () +(defun message-display-abbrev (&optional choose) "Display the next possible abbrev for the text before point." - (interactive) + (interactive (list t)) (when (and (message-point-in-header-p) (save-excursion (save-restriction @@ -7188,11 +7190,13 @@ From headers in the original article." (looking-at "To\\|Cc")))) (let* ((end (point)) (start (save-excursion - (re-search-backward "[\n\t ]" nil t) - (1+ (point)))) - (word (buffer-substring start end)) - (match (ecomplete-display-matches 'mail word))) - (when match + (and (re-search-backward "[\n\t ]" nil t) + (1+ (point))))) + (word (when start (buffer-substring start end))) + (match (when (and word + (not (zerop (length word)))) + (ecomplete-display-matches 'mail word choose)))) + (when (and choose match) (delete-region start end) (insert match))))) -- 2.34.1