[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Display X-GM-LABELS in Summary Buffer/Artice Buffer
From: |
mikael . svahnberg |
Subject: |
Re: Display X-GM-LABELS in Summary Buffer/Artice Buffer |
Date: |
Fri, 11 Oct 2013 04:26:20 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Friday, 11 October 2013 11:41:59 UTC+2, mikael.s...@gmail.com wrote:
> On Monday, 23 September 2013 11:20:00 UTC+2, mikael.s...@gmail.com wrote:
>
> > Hi,
>
> >
>
> >
>
> >
>
> > Are there any ready-made scripts that will allow me to display the labels
> > already attached to a (gmail) message?
>
> >
>
> >
>
> >
>
> > Preferrably, I would like it to be shown as a header line in the article
> > buffer, but perhaps also as a user-defined field in the summary buffer.
>
> >
>
> >
>
> >
>
> > /Mikael
>
>
>
> There I was with a successful research career when on a whim I decided to
> read my emails in gnus. "Join the hurd", they said. "See the world", they
> said.
>
>
>
> This is my first foray into lisp, so I beg for some indulgence. Also, it
> ought to be possible to speed things up by requesting the labels for all
> messages in one go and then sort things out, but at least it does something
> like showing the gmail labels.
>
>
>
> ;; ---
>
> (setq gmail-label-length 1)
>
>
>
> (defun gmail-parse-labels (lbls)
>
> (if (not (= (length lbls) 0))
>
> (let ((lbl (car lbls)))
>
> (setq lbl (replace-regexp-in-string "[\"\(\)]" "" lbl))
>
> (if (not (= (length lbl) 0))
>
> (if (not (string= (substring lbl 0 1) "\\"))
>
> (concat
>
> (substring lbl 0 gmail-label-length)
>
> (gmail-parse-labels (cdr lbls))
>
> )
>
> (gmail-parse-labels (cdr lbls)) ;; Else, just go for the next
> label
>
> )
>
> (gmail-parse-labels (cdr lbls)) ;; Else, just go for the next label
> (to be on the safe side)
>
> )
>
> )
>
> )
>
> )
>
>
>
> (defun nnimap-fetch-gmail-labels (number)
>
> ;;(message "Requesting Gmail labels for message #%s..." number)
>
> (with-current-buffer (nnimap-buffer)
>
> (let ((result (nnimap-command "UID FETCH %d (%s)" number 'X-GM-LABELS))
>
> lbls lbl)
>
> ;; This gives me a response looking like
>
> ;; (t (OK Success) (11 FETCH (X-GM-LABELS ("\\Important" "\\Starred")
> UID 12641)))
>
> ;; (message "Result: %s" result)
>
> (setq lbls (nthcdr 2 result))
>
> (setq lbls (nthcdr 2 (car lbls)))
>
> (setq lbls (nthcdr 1 (car lbls)))
>
> (gmail-parse-labels lbls)
>
> )))
>
>
>
> (defun gnus-user-format-function-g (headers)
>
> (concat
>
> (nnimap-fetch-gmail-labels number)
>
> ""
>
> ))
>
> ;; ---
>
>
>
> /Mikael
... And immediately I realised that if I do this on the "All Mail" group, I
will kill emacs, imap, and myself before getting to the list of mails. The main
reason for why I wanted to display the labels in the first place was so that I
would not have to re-label all mails whenever I was done with them and wanted
to archive them away from the inbox. Hence, it makes (most) sense to use this
in the INBOX group:
; ---
(defun gnus-user-format-function-g (headers)
(concat
(if (string= group "INBOX")
(nnimap-fetch-gmail-labels number)
(concat "-")
)
"")
)
; ---
/Mikael