Gnus development mailing list
 help / color / mirror / Atom feed
* nnimap-generate-folder-list-from-bbdb, almost.
@ 2005-02-24  1:38 Uwe Brauer
  2005-02-24 17:46 ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2005-02-24  1:38 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 5472 bytes --]

Hello

Some  weeks ago I  asked in the gnus group  for a function which would
allow to generate a entry  in the nnimap-split-fancy  list, based on a
relevant bbdb entry.

I am almost there, that is I obtained  a function
(my:nnimap-folder-list-from-bbdb) --which I have added below--

Evaluation the function, that 
(eval-expression '(my:nnimap-folder-list-from-bbdb) nil)
returns
(
("From" "bill@upct\\.es" "testbill") 
                            ^this is the relevant bbdb entry.
("From" "oub@mat\\.ucm\\.es" "testimap"))
                                ^this is the relevant bbdb entry.
                              

Now the problem is I don't know who to add this to the
nnimap-split-entry

That variable is as follows:

   (setq
 nnimap-split-rule  'nnimap-split-fancy
 nnimap-split-inbox "INBOX"
 nnimap-split-fancy
 '(|
   ("Subject" "POSIBLE SPAM" "SPAM.POSS")
   ("Subject"  ".*\\[labest05\\].*" "Labest05")	
   ("To" "xemacs-patches@xemacs.org" "Xemacs-patches") ;
   ("Sender" "xemacs-patches-bounces@xemacs.org" "Xemacs-patches") ;
   ("To" " users@dba.openoffice.org" "OO-dba") ;
   ("Sender" "preview-latex-devel-admin@lists.sourceforge.net" "Preview-latex") ;
   ("Sender" "linux-thinkpad-admin@linux-thinkpad.org" "Linux-thinkpad") ;
   ("From" "MA_Quimicas@mat.ucm.es" "Secrequi")
   ("From" "Matematica_Aplicada@mat.ucm.es" "Secremat")
   (: setq spam-use-BBDB-exclusive nil)
   (: spam-split 'spam-use-BBDB 'spam-use-stat "SPAM.REAL")
   (: spam-split 'spam-use-regex-headers "SPAM.POSS") ;Version:1.10
   (: setq spam-use-BBDB-exclusive t fake-variable nil)
   (: spam-split 'spam-use-BBDB "SPAM.HAM")
   (: setq spam-use-BBDB-exclusive nil)
   "MAILBOX"))



So I thought of either doing

(defun my:nnimap-generate-folder-list-from-bbdb ()
   "Sets 'nnimap-folder-list to the result of
 my:nnimap-folder-list-from-bbdb."
   (interactive)
    (add-to-list 'nnimap-split-fancy
          (my:nnimap-folder-list-from-bbdb) )) 


Which resulted in 



`nnimap-split-fancy' is a variable declared in Lisp.
  -- loaded from "nnimap"

Value: ((("From" "oub@mat\\.ucm\\.es" "testimap")) | ("Subject"
"POSIBLE SPAM" "SPAM.POSS") ("Subject" ".*\\[labest05\\].*"
"Labest05") ("To" "xemacs-patches@xemacs.org" "Xemacs-patches")
("Sender" "xemacs-patches-bounces@xemacs.org" "Xemacs-patches") ("To"
" users@dba.openoffice.org" "OO-dba") ("Sender"
"preview-latex-devel-admin@lists.sourceforge.net" "Preview-latex")
("Sender" "linux-thinkpad-admin@linux-thinkpad.org" "Linux-thinkpad")
("From" "MA_Quimicas@mat.ucm.es" "Secrequi") ("From"
"Matematica_Aplicada@mat.ucm.es" "Secremat") (: setq
spam-use-BBDB-exclusive nil) (: spam-split (quote spam-use-BBDB)
(quote spam-use-stat) "SPAM.REAL") (: spam-split (quote
spam-use-regex-headers) "SPAM.POSS") (: setq spam-use-BBDB-exclusive t
fake-variable nil) (: spam-split (quote spam-use-BBDB) "SPAM.HAM") (:
setq spam-use-BBDB-exclusive nil) "MAILBOX")

which is wrong the new entry has to appear
after the | symbol

Or

(defun my:nnimap-generate-folder-list-from-bbdb ()
   "Sets 'nnimap-folder-list to the result of
 my:nnimap-folder-list-from-bbdb."
   (interactive)
   (add-to-list 'nnimap-split-fancy
         (my:nnimap-folder-list-from-bbdb) 'append))

Which results in 
`nnimap-split-fancy' is a variable declared in Lisp.
  -- loaded from "nnimap"

Value: (| ("Subject" "POSIBLE SPAM" "SPAM.POSS") ("Subject"
".*\\[labest05\\].*" "Labest05") ("To" "xemacs-patches@xemacs.org"
"Xemacs-patches") ("Sender" "xemacs-patches-bounces@xemacs.org"
"Xemacs-patches") ("To" " users@dba.openoffice.org" "OO-dba")
("Sender" "preview-latex-devel-admin@lists.sourceforge.net"
"Preview-latex") ("Sender" "linux-thinkpad-admin@linux-thinkpad.org"
"Linux-thinkpad") ("From" "MA_Quimicas@mat.ucm.es" "Secrequi") ("From"
"Matematica_Aplicada@mat.ucm.es" "Secremat") (: setq
spam-use-BBDB-exclusive nil) (: spam-split (quote spam-use-BBDB)
(quote spam-use-stat) "SPAM.REAL") (: spam-split (quote
spam-use-regex-headers) "SPAM.POSS") (: setq spam-use-BBDB-exclusive t
fake-variable nil) (: spam-split (quote spam-use-BBDB) "SPAM.HAM") (:
setq spam-use-BBDB-exclusive nil) "MAILBOX" (("From"
"oub@mat\\.ucm\\.es" "testimap")))

Which is also bad, since it is the last entry.





or
(setq
 nnimap-split-rule  'nnimap-split-fancy
 nnimap-split-inbox "INBOX"
 nnimap-split-fancy
 '(|
  (: my:nnimap-folder-list-from-bbdb)
   ("Subject" "POSIBLE SPAM" "SPAM.POSS")
   ("Subject"  ".*\\[labest05\\].*" "Labest05")	;DAS IST ES!!!! Jan 27, 2005 13:34
   ("To" "xemacs-patches@xemacs.org" "Xemacs-patches") ;
   ("Sender" "xemacs-patches-bounces@xemacs.org" "Xemacs-patches") ;
   ("To" " users@dba.openoffice.org" "OO-dba") ;
   ("Sender" "preview-latex-devel-admin@lists.sourceforge.net" "Preview-latex") ;
   ("Sender" "linux-thinkpad-admin@linux-thinkpad.org" "Linux-thinkpad") ;
   ("From" "MA_Quimicas@mat.ucm.es" "Secrequi")
   ("From" "Matematica_Aplicada@mat.ucm.es" "Secremat")
   (: setq spam-use-BBDB-exclusive nil)
   (: spam-split 'spam-use-BBDB 'spam-use-stat "SPAM.REAL")
   (: spam-split 'spam-use-regex-headers "SPAM.POSS") ;Version:1.10
   (: setq spam-use-BBDB-exclusive t fake-variable nil)
   (: spam-split 'spam-use-BBDB "SPAM.HAM")
   (: setq spam-use-BBDB-exclusive nil)
   "MAILBOX"))

That however gave an error I have attached below. (As I understand
there are to may parenthesis generated.)

I would appreciate any help on this subject. I think that function can
be really convenient.


Thanks

Uwe Brauer 



[-- Attachment #2: imap-split-bbdb-bug --]
[-- Type: application/octet-stream, Size: 1959 bytes --]

Debugger entered--Lisp error: (invalid-function (my:nnimap-folder-list-from-bbdb))
  ((my:nnimap-folder-list-from-bbdb))
  eval(((my:nnimap-folder-list-from-bbdb)))
  nnmail-split-it((: (my:nnimap-folder-list-from-bbdb)))
  nnmail-split-it((| (: (my:nnimap-folder-list-from-bbdb)) ("Subject" ".*\\[POSSILBLE SPAM\\].*" "SPAM.POSS") ("Subject" ".*\\<\\[POSSIBLE.SPAM\\]\\>.*" "SPAM.POSS") ("Subject" "POSIBLE SPAM" "SPAM.POSS") ("Subject" ".*\\[labest05\\].*" "Labest05") ("To" "xemacs-patches@xemacs.org" "Xemacs-patches") ("Sender" "xemacs-patches-bounces@xemacs.org" "Xemacs-patches") ("To" " users@dba.openoffice.org" "OO-dba") ("Sender" "preview-latex-devel-admin@lists.sourceforge.net" "Preview-latex") ("Sender" "linux-thinkpad-admin@linux-thinkpad.org" "Linux-thinkpad") ("From" "MA_Quimicas@mat.ucm.es" "Secrequi") ("From" "Matematica_Aplicada@mat.ucm.es" "Secremat") (: setq spam-use-BBDB-exclusive nil) (: spam-split (quote spam-use-BBDB) (quote spam-use-stat) "SPAM.REAL") (: spam-split (quote spam-use-regex-headers) "SPAM.POSS") (: setq spam-use-BBDB-exclusive t fake-variable nil) (: spam-split (quote spam-use-BBDB) "SPAM.HAM") (: setq spam-use-BBDB-exclusive nil) "MAILBOX"))
  nnmail-split-fancy()
  nnimap-split-fancy()
  nnimap-split-to-groups(nnimap-split-fancy)
  nnimap-split-articles(nil "ucmail.ucm.es")
  nnimap-request-scan(nil "ucmail.ucm.es")
  gnus-request-scan(nil (nnimap "ucmail.ucm.es"))
  gnus-read-active-file-1((nnimap "ucmail.ucm.es") nil)
  gnus-read-active-file()
  gnus-group-get-new-news(nil)
  call-interactively(gnus-group-get-new-news)
  recursive-edit()
  byte-code("..." [buffer-read-only noninteractive debugger-buffer middlestart debugger-args debugger-batch-max-lines pop-to-buffer debugger-mode debugger-setup-buffer count-lines 2 "...\n" message buffer-string kill-emacs debug backtrace-debug 3 t debugger-reenable "" nil recursive-edit standard-output] 3)
  debug(error (void-function folding-fold-region))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: nnimap-generate-folder-list-from-bbdb, almost.
  2005-02-24  1:38 nnimap-generate-folder-list-from-bbdb, almost Uwe Brauer
@ 2005-02-24 17:46 ` Ted Zlatanov
  2005-02-25  1:23   ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2005-02-24 17:46 UTC (permalink / raw)
  Cc: ding

On Wed, 23 Feb 2005, oub@mat.ucm.es wrote:

> Some weeks ago I asked in the gnus group for a function which would
> allow to generate a entry  in the nnimap-split-fancy  list, based on a
> relevant bbdb entry.
> 
> I am almost there, that is I obtained  a function
> (my:nnimap-folder-list-from-bbdb) --which I have added below--
> 
> Evaluation the function, that 
> (eval-expression '(my:nnimap-folder-list-from-bbdb) nil)
> returns
> (
> ("From" "bill@upct\\.es" "testbill") 
>                             ^this is the relevant bbdb entry.
> ("From" "oub@mat\\.ucm\\.es" "testimap"))
>                                 ^this is the relevant bbdb entry.
>                               
> 
> Now the problem is I don't know who to add this to the
> nnimap-split-entry

You can use a macro to do this.

For example (from the manual, see the ELisp manual, node "Macros"):

    '(a list of (+ 2 3) elements)
          => (a list of (+ 2 3) elements)
    `(a list of (+ 2 3) elements)
          => (a list of (+ 2 3) elements)
     `(a list of ,(+ 2 3) elements)
          => (a list of 5 elements)

Note how the backquote turns the expression into a macro.

So it seems that in your case, something like this:

(setq nnimap-split-fancy
 `(|
   ("Subject" "POSIBLE SPAM" "SPAM.POSS")
...
  ,(my:nnimap-folder-list-from-bbdb)
...
  "MAILBOX"
  ))

should work.

Ted



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: nnimap-generate-folder-list-from-bbdb, almost.
  2005-02-25  1:23   ` Uwe Brauer
@ 2005-02-24 20:12     ` Ted Zlatanov
  2005-02-25 16:06       ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2005-02-24 20:12 UTC (permalink / raw)
  Cc: ding

On Thu, 24 Feb 2005, oub@mat.ucm.es wrote:

> I works when (my:nnimap-folder-list-from-bbdb) would just return one
> entry however if there are more the above setting leads to 
> `nnimap-split-fancy' is a variable declared in Lisp.
>   -- loaded from "nnimap"
> 
> Value: (| 
> (("From" "oub@gmx\\.net" "imapgmx") 
> ^evil par
>         ("From" "oub@mat\\.ucm\\.es" "testimap")) 
>                                                 ^evil par
> ("Subject" ".*\\[POSSILBLE
> SPAM\\].*" "SPAM.POSS")
> and this is evil
> 
> 
> So I was pointed out that ,(car (my:nnimap-folder-list-from-bbdb))
> might, work, it does, but of course it will add only *the first*  of the above
> list entries not all of them. Lisp is made to deal with lists, but
> how?

Use the ,@ expansion instead of just ,

See the Elisp manual, section "Macros" for more information.  It's
really not that complicated, and you'll understand it better from the
many examples.  I tried to avoid it for a while, and my code turned
out much uglier without macros :)

Here's an example that returns (1 5 6 2 3) because the (list) function
call is flattened by the ,@ operator.

`(1 ,@(list 5 6) 2 3)

That should be exactly what you need.

Ted



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: nnimap-generate-folder-list-from-bbdb, almost.
  2005-02-24 17:46 ` Ted Zlatanov
@ 2005-02-25  1:23   ` Uwe Brauer
  2005-02-24 20:12     ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2005-02-25  1:23 UTC (permalink / raw)


>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:

    Ted> On Wed, 23 Feb 2005, oub@mat.ucm.es wrote:

    Ted> You can use a macro to do this.

    Ted> For example (from the manual, see the ELisp manual, node "Macros"):

    Ted>     '(a list of (+ 2 3) elements)
    Ted>           => (a list of (+ 2 3) elements)
    Ted>     `(a list of (+ 2 3) elements)
    Ted>           => (a list of (+ 2 3) elements)
    Ted>      `(a list of ,(+ 2 3) elements)
    Ted>           => (a list of 5 elements)

Great I did not know about this.
    Ted> Note how the backquote turns the expression into a macro.

    Ted> So it seems that in your case, something like this:

    Ted> (setq nnimap-split-fancy
    Ted>  `(|
    Ted>    ("Subject" "POSIBLE SPAM" "SPAM.POSS")
    Ted> ...
    Ted>   ,(my:nnimap-folder-list-from-bbdb)
    Ted> ...
    Ted>   "MAILBOX"
    Ted>   ))

    Ted> should work.
Almost almost.

I works when (my:nnimap-folder-list-from-bbdb) would just return one
entry however if there are more the above setting leads to 
`nnimap-split-fancy' is a variable declared in Lisp.
  -- loaded from "nnimap"

Value: (| 
(("From" "oub@gmx\\.net" "imapgmx") 
^evil par
        ("From" "oub@mat\\.ucm\\.es" "testimap")) 
                                                ^evil par
("Subject" ".*\\[POSSILBLE
SPAM\\].*" "SPAM.POSS")
and this is evil


So I was pointed out that    ,(car (my:nnimap-folder-list-from-bbdb))
might, work, it does, but of course it will add only *the first*  of the above
list entries not all of them. Lisp is made to deal with lists, but
how?

Thanks

Uwe 




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: nnimap-generate-folder-list-from-bbdb, almost.
  2005-02-24 20:12     ` Ted Zlatanov
@ 2005-02-25 16:06       ` Uwe Brauer
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2005-02-25 16:06 UTC (permalink / raw)


>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:

    Ted> Use the ,@ expansion instead of just ,

    Ted> See the Elisp manual, section  "Macros" for more information.
    Ted> It's  really not that  complicated, and you'll  understand it
    Ted>  better from the  many examples.  I tried to   avoid it for a
    Ted> while, and my code turned out much uglier without macros :)

    Ted> Here's an example that returns (1 5 6 2 3) because the (list) function
    Ted> call is flattened by the ,@ operator.

    Ted> `(1 ,@(list 5 6) 2 3)

    Ted> That should be exactly what you need.

THANKS, VERY MUCH


It works like charm. I think after some review I will try that this
function gets included into gnus (and/or bbdb. find it *very* useful.

Uwe 




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-02-25 16:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24  1:38 nnimap-generate-folder-list-from-bbdb, almost Uwe Brauer
2005-02-24 17:46 ` Ted Zlatanov
2005-02-25  1:23   ` Uwe Brauer
2005-02-24 20:12     ` Ted Zlatanov
2005-02-25 16:06       ` Uwe Brauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).