From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/16536 Path: news.gmane.org!not-for-mail From: mikael.svahnberg@gmail.com Newsgroups: gmane.emacs.gnus.user Subject: Re: Display X-GM-LABELS in Summary Buffer/Artice Buffer Date: Fri, 11 Oct 2013 02:41:59 -0700 (PDT) Message-ID: <380faf10-e298-41cd-a0f4-9e94b7666689@googlegroups.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1381484703 13291 80.91.229.3 (11 Oct 2013 09:45:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Oct 2013 09:45:03 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Fri Oct 11 11:45:08 2013 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUZHO-0004ii-VO for gegu-info-gnus-english@m.gmane.org; Fri, 11 Oct 2013 11:45:07 +0200 Original-Received: from localhost ([::1]:53312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUZHO-0001jE-36 for gegu-info-gnus-english@m.gmane.org; Fri, 11 Oct 2013 05:45:06 -0400 X-Received: by 10.50.85.109 with SMTP id g13mr1273181igz.1.1381484519532; Fri, 11 Oct 2013 02:41:59 -0700 (PDT) X-Received: by 10.49.13.40 with SMTP id e8mr599679qec.1.1381484519502; Fri, 11 Oct 2013 02:41:59 -0700 (PDT) Original-Path: usenet.stanford.edu!z6no50841527pbz.1!news-out.google.com!9ni29063qaf.0!nntp.google.com!i2no5948412qav.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.gnus In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=213.67.233.187; posting-account=IOBunwoAAACfl5iZYKlvkMNaEfd0O_mW Original-NNTP-Posting-Host: 213.67.233.187 User-Agent: G2/1.0 Injection-Date: Fri, 11 Oct 2013 09:41:59 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.gnus:87663 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:16536 Archived-At: 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