"Roland Winkler" <wink...@gnu.org> writes:

> On Sun Aug 5 2012 Stephen Leake wrote:
>> I've traced thru several executions of bbdb-complete-mail, with various
>> patterns, and various settings of bbdb-completion-list. It appears there
>> is no way to get to the line ";; Consider cycling" with 'done' set to
>> nil, so there is no way to get cycling. I hope I'm wrong!
>
> I cannot quite reproduce this. DONE is initially let-bound to nil.

Yes.

> Only if DONE did not get bound to something else before reaching the
> line ";;consider cycling" the code should perform cycling.

Yes.

> So can you check the non-nil value of DONE at this point?

I could not create the initial conditions that would cause it to be
non-nil.

All the conditions I tried made sense in the setting of done; ignoring
done at this point also makes sense, as far as I can tell.

> This should give some hint where the code decided to fork in some way
> you do not want it to go.

No, in all the cases I've tried, it does exactly what I want, when
ignoring done in consider cycling.

Can you describe a set of initial conditions that result in done being
nil at that point?

Actually, I did achieve that once, by setting bbdb-completion-list to
nil (accidently); but that also meant there were no email addresses
found, which is clearly not what we want.


done can have the following values (searching for 'setq done' in
bbdb-complete-mail):

'unchanged
    the pattern matches an email exactly, and
    bbdb-complete-mail-allow-cycling is nil or there is only one email
    in the record

    no need for cycling, so ignoring done is wrong in this case; but it
    will have no effect (it will just return the single email already found).

'unique
    the pattern matches only one record

    we want to cycle thru the emails in the record

'partial
    the pattern matches more than one record

    done should not be ignored, but the cycling code does nothing, I
    think (I didn't actually trace this path)


So the correct condition for cycling seems to be this:

    ;; Consider cycling
    (when (and (eq done 'unique) bbdb-complete-mail-allow-cycling)

Hmm; testing that says it doesn't work. And I finally found out when
done is nil; when we've found one match and inserted in the buffer,
using bbdb-dwim-mail; that is now the pattern for the next attempt, and
it matches no records.

So adding to the above list:

nil
    the pattern (most likely the result of a previous match) matches no
    records (as searched by bbdb-complete-mail to this point)

    If the pattern contains a name or email address that matches a
    record, then we cycle; take the next email address in that record.

So testing done for nil is correct, and that now works for me; I don't
understand why I had to change it! I must have changed some other
setting that was the real culprit; probably using (bbdb-complete-mail
nil t).

I suggest adding the following comment:

    ;; Consider cycling
    (when (and (not done) bbdb-complete-mail-allow-cycling)
      ;; The pattern has matched no records; it is most likely the
      ;; result of a previous match, and we want to cycle to the next
      ;; email address.
      ;;

Otherwise, sorry for the noise.

Patch, adding this comment, and fixing the kill non-existing window bug,
below.

--
-- Stephe
--- a/lisp/bbdb-com.el
+++ b/lisp/bbdb-com.el
@@ -1801,8 +1801,8 @@ as part of the MUA insinuation."
     ;; Clean up *Completions* buffer, if it exists
     (when bbdb-complete-mail-saved-window-config
       (let ((window (get-buffer-window "*Completions*")))
+       (set-window-configuration bbdb-complete-mail-saved-window-config)
         (when (window-live-p window)
-          (set-window-configuration bbdb-complete-mail-saved-window-config)
           (quit-window nil window)))
       (setq bbdb-complete-mail-saved-window-config nil))
 
@@ -1913,6 +1913,10 @@ as part of the MUA insinuation."
 
     ;; Consider cycling
     (when (and (not done) bbdb-complete-mail-allow-cycling)
+      ;; The pattern has matched no records; it is most likely the
+      ;; result of a previous match, and we want to cycle to the next
+      ;; email address.
+      ;;
       ;; find the record we are working on.
       (let* ((address (mail-extract-address-components orig))
              (record (and (listp address)


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to