* message.el (message-display-abbrev): Fix regexp.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 12 Apr 2006 14:50:57 +0000 (14:50 +0000)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 12 Apr 2006 14:50:57 +0000 (14:50 +0000)
* ecomplete.el (ecomplete-highlight-match-line): Reimplement
choosing.

lisp/ChangeLog
lisp/ecomplete.el
lisp/message.el

index 4e3f7eb..b3d1c12 100644 (file)
@@ -1,7 +1,11 @@
 2006-04-12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * message.el (message-display-abbrev): Fix regexp.
+
        * ecomplete.el (ecomplete-highlight-match-line): Reimplement
        choosing. 
+       (ecomplete-highlight-match-line): Fix up code rewrite, remove
+       dead variables. 
 
        * message.el (message-newline-and-indent): Remove debugging.
        (message-display-abbrev): Use new implementation.
index 1be9d66..c5d8e8f 100644 (file)
 ;;; Internal variables.
 
 (defvar ecomplete-database nil)
-(defvar ecomplete-current-matches nil)
-(defvar ecomplete-match-length nil)
-(defvar ecomplete-current-line nil)
-(defvar ecomplete-current-match nil)
 
 (defun ecomplete-setup ()
   (when (file-exists-p ecomplete-database-file)
@@ -79,7 +75,6 @@
     (write-region (point-min) (point-max) ecomplete-database-file nil 'silent)))
 
 (defun ecomplete-get-matches (type match)
-  (setq ecomplete-current-match match)
   (let* ((elems (cdr (assq type ecomplete-database)))
         (match (regexp-quote match))
         (candidates
 (defun ecomplete-display-matches (type word)
   (let* ((matches (ecomplete-get-matches type word))
         (line 0)
-        (max-lines (length (split-string matches "\n")))
-        command)
-    (while (not (memq (setq command (read-char)) '(?  ?\r)))
-      (cond
-       ((eq command ?n)
-       (setq line (min (1+ line) max-lines)))
-       ((eq command ?p)
-       (setq line (max (1- line) 0))))
-      (ecomplete-highlight-match-line matches line))
-    (when (eq command ?\r)
-      (nth line (split-string ecomplete-current-matches "\n")))))
+        (max-lines (when matches (- (length (split-string matches "\n")) 2)))
+        command highlight)
+    (if (not matches)
+       (progn
+         (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 ?n)
+         (setq line (min (1+ line) max-lines)))
+        ((eq command ?p)
+         (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
        (unless (get-text-property (point) 'face)
          (put-text-property (point) (1+ (point)) 'face 'region))
        (forward-char 1)))
-    (message "%s" (buffer-string))))
+    (buffer-string)))
 
 (provide 'ecomplete)
 
index 04d58fe..452f60f 100644 (file)
@@ -7188,8 +7188,8 @@ 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))))
+                   (re-search-backward "[\n\t ]" nil t)
+                   (1+ (point))))
           (word (buffer-substring start end))
           (match (ecomplete-display-matches 'mail word)))
       (when match