From: Tollef Fog Heen Date: Sat, 29 May 2010 11:50:41 +0000 (+0200) Subject: Make it possible to cycle through results X-Git-Tag: 0.7~9 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aa5672b6a4cdbf855ad195432dc31a682d45cee;p=eweouz Make it possible to cycle through results --- diff --git a/lisp/eweouz.el b/lisp/eweouz.el index fc01569..adb2eea 100644 --- a/lisp/eweouz.el +++ b/lisp/eweouz.el @@ -66,12 +66,14 @@ (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)) @@ -82,11 +84,20 @@ ((< 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