[Top][All Lists]

[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 02:41:59 -0700 (PDT)
User-agent: G2/1.0

On Monday, 23 September 2013 11:20:00 UTC+2,  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) "\\"))
                   (substring lbl 0 gmail-label-length)
                   (gmail-parse-labels (cdr lbls))
                (gmail-parse-labels (cdr lbls)) ;; Else, just go for the next 
            (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 
      ;; (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)
   (nnimap-fetch-gmail-labels number)
;; ---


reply via email to

[Prev in Thread] Current Thread [Next in Thread]