Gnus development mailing list
 help / color / mirror / Atom feed
* problem when creating group and editing params from code
@ 2012-10-25 21:34 joakim
  2012-12-24 22:08 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: joakim @ 2012-10-25 21:34 UTC (permalink / raw)
  To: ding

I'm patching gnus-sieve.el so you can create a group and add a sieve
rule in one go.

So, I ask for a groupname. If it does not exist, create it.
But then when I try to add something to the group params, they are nil,
and it fails. What more must I do to make the new group accept group
param editing?

Heres the code:

(defun gnus-sieve-group ()
  "ask for an nnimap group to sieve into"
  (interactive)
  ;;the returned group will be "fully qualified", like "nnimap+naru:imapmail.testgroup"  
  ;;the chosen group is verified to be an nnimap group
  ;;if it doesnt exist, create it

  (let ( (group-name (gnus-group-completing-read  "group to sieve message to:")))
    (if (gnus-gethash group-name
                      gnus-active-hashtb)
        group-name
      (if (yes-or-no-p (format "Create and subscribe group %s ?" group-name))
          (let
              ((just-group (cadr  (split-string group-name ":")))
               (method  (replace-regexp-in-string "+" ":" (car  (split-string group-name ":")))))
            (with-current-buffer gnus-group-buffer (gnus-group-make-group just-group     method
                                                                          )))
        (error "group does not exist")))))

(defun gnus-sieve-jv-article-add-rule ()
  "ask for a header and a group.
add a sieve rule that filters that header value to the group"
  (interactive)
  (gnus-summary-select-article nil 'force)
  (with-current-buffer gnus-original-article-buffer
    (let* ((rule (gnus-sieve-rule-for-article-header (completing-read "header:" '("from" "to" "cc"))))
          (gnus-filter-newsgroup-name (gnus-sieve-group))
	  (info (gnus-get-info gnus-filter-newsgroup-name)))
      (if (null rule)
	  (error "Could not guess rule for article")
        ;;either create a rule or merge. TODO dont assume we have only one type of rule
        (if (gnus-group-find-parameter gnus-filter-newsgroup-name 'sieve t)
            (gnus-sieve-merge-rule gnus-filter-newsgroup-name rule)
            (gnus-info-set-params info (cons rule (gnus-info-params info))))
	(message "Added rule in group %s for article: %s" gnus-filter-newsgroup-name
		 rule)))))

-- 
Joakim Verona




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

* Re: problem when creating group and editing params from code
  2012-10-25 21:34 problem when creating group and editing params from code joakim
@ 2012-12-24 22:08 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2012-12-24 22:08 UTC (permalink / raw)
  To: joakim; +Cc: ding

joakim@verona.se writes:

> So, I ask for a groupname. If it does not exist, create it.
> But then when I try to add something to the group params, they are nil,
> and it fails. What more must I do to make the new group accept group
> param editing?

Hm.

[...]

>             (gnus-info-set-params info (cons rule (gnus-info-params info))))

Perhaps you need the `extend' parameter to `gnus-info-set-params'?

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Lars Magne Ingebrigtsen



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

end of thread, other threads:[~2012-12-24 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 21:34 problem when creating group and editing params from code joakim
2012-12-24 22:08 ` Lars Ingebrigtsen

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).