]> err.no Git - eweouz/commitdiff
Make it possible to cycle through results
authorTollef Fog Heen <tfheen@err.no>
Sat, 29 May 2010 11:50:41 +0000 (13:50 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sat, 29 May 2010 11:50:41 +0000 (13:50 +0200)
lisp/eweouz.el

index fc015690e6da42d75fea20d8e812fcc3860847e2..adb2eeaa9f1c49f26415763130767f9a2eee871e 100644 (file)
                    (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
                    (goto-char (match-end 0))
                    (point))))
-        (orig (buffer-substring beg end))
-        (typed (downcase orig))
+        (typed (or (and (eq this-command last-command)
+                        (get this-command 'typed))
+                   (downcase (buffer-substring beg end))))
+        (index (or (and (eq this-command last-command)
+                        (get this-command 'index))
+                   0))
         (match-recs '()))
     (eweouz-search-do '(lambda (x) (add-to-list 'match-recs x)) typed)
-    (message (format "%s" match-recs))
-    (message (format "%d" (length match-recs)))
     (cond ((= 0 (length match-recs))
           (message "No matching records"))
          ((= 1 (length match-recs))
          ((< 1 (length match-recs))
           ;; For now, just display the records and leave the user to
           ;; complete
-          (save-excursion
-            (set-buffer (get-buffer-create eweouz-buffer-name))
-            (mapcar '(lambda (x) (insert (format "%s\n" 
+          (if (eq this-command last-command)
+              ;; Select next in list
+              (progn
+                (delete-region beg end)
+                (insert (vcard-format-sample-get-name (nth index match-recs)))
+                (put this-command 'index (% (+ 1 index)
+                                            (length match-recs))))
+            (save-excursion
+              (put this-command 'typed typed)
+              (put this-command 'index 0)
+              (set-buffer (get-buffer-create eweouz-buffer-name))
+              (mapcar '(lambda (x) (insert (format "%s\n"
                                                  (vcard-format-sample-get-name x)))) match-recs)
-            (eweouz-pop-up-eweouz-buffer))))))
+              (eweouz-pop-up-eweouz-buffer)))))))
 
 ;
 ; Mostly stolen from bbdb-pop-up-bbdb-buffer