From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85206 Path: news.gmane.org!not-for-mail From: Alexander Baier Newsgroups: gmane.emacs.gnus.general Subject: Re: function to access raw article Date: Fri, 31 Oct 2014 15:01:28 +0100 Message-ID: <87lhnwgwxz.fsf@mailbox.org> References: <87fve4iqve.fsf@gmail.com> <87lhnwe6vl.fsf@lifelogs.com> <87ppd8gy0l.fsf@mailbox.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1414764141 16566 80.91.229.3 (31 Oct 2014 14:02:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2014 14:02:21 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33450=ding+2Daccount=gmane.org@lists.math.uh.edu Fri Oct 31 15:02:13 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XkCmI-00080b-RI for ding-account@gmane.org; Fri, 31 Oct 2014 15:02:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1XkCmH-0003SV-St for ding-account@gmane.org; Fri, 31 Oct 2014 09:02:09 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1XkCmG-0003SQ-Ty for ding@lists.math.uh.edu; Fri, 31 Oct 2014 09:02:08 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XkCmE-00024r-M2 for ding@lists.math.uh.edu; Fri, 31 Oct 2014 09:02:08 -0500 Original-Received: from mx2.mailbox.org ([80.241.60.215]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XkCmA-0004I3-Qa for ding@gnus.org; Fri, 31 Oct 2014 15:02:02 +0100 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 8779F4025B for ; Fri, 31 Oct 2014 15:01:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-type:content-type:mime-version:user-agent:message-id :in-reply-to:date:date:references:subject:subject:from:from :received; s=mail20140220; t=1414764116; bh=Yctw867XUywTxmnxzWfe yq2ebxlPc4KNcLSyOEjMxuQ=; b=cgWrvZgdYVcwv80FZJbVT0rfyw4+GV0W3K29 TDnYxEHAapsjP+DkjatYXD+/i9bBEOBh4xL5k5wrkShcnbOWjUTQ3gfsS78ChuVC 6YRQ7oS557XdRvvFL5Uvz0K7y5Y7F6Sdz3/h+sQZaoIbZMhZVJZzwWZP1d6CNLIH 0gx2+eXVlyZTBL1iFpu5DUJQtbTyKWVT8E6222We6Hu5nFTcw/SYTF/8pnYdx18a T73I0PuddLQiqdM5xbH9NquQ9Pn4XSC2qHtMppj6G+m4VvcUlWsNkghXm4sBSj50 cGWsTfKWzPOwIWQ994tnS35EK/Rah7zfowa0C2r+VGZUXfNVgRXWL7w9KeJaB+qL RvCg2QVdULlJbdi9fAyPn/aIBOOLtKLPF5cfpp8nu0VzC8PO3vJfwVF324/iMH2a qzCiCs2rWO1dE4LeW1vpsJEGMw/y9AHpLHaebOmrqC3c0Xotth7mFzrPlnoHXo6p I7AtHcAK0FEpoPhw57ibFEaIWCwv0FO7RBg32dWzAPgDZAfpA9faFnEhn+Tq1VMz /S1IsU7N4+odIEyX8tcpTPohsH791Di5o3cy5rr3K/1Ic X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) (using TLS with cipher AES256-GCM-SHA384) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTPS id AmTQtCTm8Cv2 for ; Fri, 31 Oct 2014 15:01:56 +0100 (CET) Mail-Followup-To: ding@gnus.org In-Reply-To: <87ppd8gy0l.fsf@mailbox.org> (Alexander Baier's message of "Fri, 31 Oct 2014 14:38:18 +0100") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.4 (gnu/linux) X-Spam-Score: -5.6 (-----) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85206 Archived-At: On 2014-10-31 14:38 Alexander Baier wrote: > On 2014-10-31 13:55 Ted Zlatanov wrote: >> On Fri, 31 Oct 2014 09:29:41 +0100 Alexander Baier >> wrote: >> >> AB> I want to access the raw (unwashed) version of an article from emacs >> AB> lisp to search for a regexp. I do this in order to extract information >> AB> from the body of the article to be used in the summary line. I used >> AB> `gnus-summary-show-raw-article' which did not seem to work. What is the >> AB> preferred way of doing this? >> >> Try `spam-get-article-as-string' in spam.el, which is used by spam >> backends that need the full article. But as others said, it may not >> work :) >> > > This is it! The following works like a charm. It is designed to extract > the title of the video from a mail you get from youtube when someone you > are subscribed to uploads a new video. > > #+BEGIN_SRC emacs-lisp > (defun gnus-user-format-function-Y (header) > "Returns the title of a youtube video." > (let ((body (spam-get-article-as-string (elt header 0)))) > (string-match "\n.*just uploaded a video\n\\(.*\\)\nhttp:.*" body) > (match-string-no-properties 1 body))) > #+END_SRC > > Thank you Ted, Steinar and Igor! :) > > Regards, I have updated the regexp to catch multiline titles: #+BEGIN_SRC emacs-lisp (defun gnus-user-format-function-Y (header) "Returns the title of a youtube video." (let ((body (spam-get-article-as-string (elt header 0))) (regex (concat "Content-Type: text/plain;.*\n" "\n.*just uploaded a video\n" "\\(.*\\(?:\n.*\\)*?\\)\nhttp:.*"))) (string-match regex body) (s-replace "\n" "" (match-string-no-properties 1 body)))) #+END_SRC Regards, -- Alexander Baier