emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Org-mode] feed.el
@ 2010-07-07  2:53 Mark Scala
  2010-07-07  6:22 ` [PATCH 1/2] Load XML library if necessary David Maus
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mark Scala @ 2010-07-07  2:53 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 703 bytes --]

Hi, all.

I was trying out feed.el today, and I've got an error that I don't
understand.

Following the docs, I put this in my .emacs:

(setq org-feed-alist
          '(("Slashdot"
         "http://rss.slashdot.org/Slashdot/slashdot"
             "~/org/feeds.org" "Slashdot Entries")))

I created a file in ~/org called feeds.org and in that file did C-c C-x g.
A headline for Slashdot Entries appeared.  But when I do C-c C-x g on that
entry I get the following message:  "Symbol's value as variable is void:
xml-entity-alist"

Nowhere do I find any information about setting that variable.  Any ideas?
(I'm using the latest development version of Org, compiled from git sources
today).

Thanks,
Mark

[-- Attachment #1.2: Type: text/html, Size: 976 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [PATCH 1/2] Load XML library if necessary.
  2010-07-07  2:53 [Org-mode] feed.el Mark Scala
@ 2010-07-07  6:22 ` David Maus
  2010-07-07  6:50   ` Carsten Dominik
  2010-07-07  6:22 ` [PATCH 2/2] Change indentation to match coding style guideline David Maus
  2010-07-07  6:25 ` [Org-mode] feed.el David Maus
  2 siblings, 1 reply; 6+ messages in thread
From: David Maus @ 2010-07-07  6:22 UTC (permalink / raw)
  To: emacs-orgmode

* org-feed.el (org-feed-unescape, org-feed-parse-atom-feed): Load XML
library if necessary.

Function that use xml.el must require 'xml to make sure it is loaded
at runtime.
---
 lisp/org-feed.el |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lisp/org-feed.el b/lisp/org-feed.el
index 999bfd8..e41ad97 100644
--- a/lisp/org-feed.el
+++ b/lisp/org-feed.el
@@ -270,6 +270,7 @@ have been saved."
 
 (defun org-feed-unescape (s)
   "Unescape protected entities in S."
+  (require 'xml)
   (let ((re (concat "&\\("
 		    (mapconcat 'car xml-entity-alist "\\|")
 		    "\\);")))
@@ -630,6 +631,7 @@ containing the properties `:guid' and `:item-full-text'.
 
 The `:item-full-text' property actually contains the sexp
 formatted as a string, not the original XML data."
+  (require 'xml)
   (with-current-buffer buffer
     (widen)
     (let ((feed (car (xml-parse-region (point-min) (point-max)))))
-- 
1.7.1

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

* [PATCH 2/2] Change indentation to match coding style guideline.
  2010-07-07  2:53 [Org-mode] feed.el Mark Scala
  2010-07-07  6:22 ` [PATCH 1/2] Load XML library if necessary David Maus
@ 2010-07-07  6:22 ` David Maus
  2010-07-07  6:47   ` Patchwork: Patch 122 Accepted Carsten Dominik
  2010-07-07  6:25 ` [Org-mode] feed.el David Maus
  2 siblings, 1 reply; 6+ messages in thread
From: David Maus @ 2010-07-07  6:22 UTC (permalink / raw)
  To: emacs-orgmode

* org-feed.el: Change indentation to match coding style
guideline.

Cosmetic changes.
---
 lisp/org-feed.el |   88 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/lisp/org-feed.el b/lisp/org-feed.el
index e41ad97..2af97e5 100644
--- a/lisp/org-feed.el
+++ b/lisp/org-feed.el
@@ -166,10 +166,11 @@ Here are the keyword-value pair allows in `org-feed-alist'.
      When the handler is called, point will be at the feed headline.
 
 :parse-feed function
-     This function gets passed a buffer, and should return a list of entries,
-     each being a property list containing the `:guid' and `:item-full-text'
-     keys.  The default is `org-feed-parse-rss-feed'; `org-feed-parse-atom-feed'
-     is an alternative.
+     This function gets passed a buffer, and should return a list
+     of entries, each being a property list containing the
+     `:guid' and `:item-full-text' keys.  The default is
+     `org-feed-parse-rss-feed'; `org-feed-parse-atom-feed' is an
+     alternative.
 
 :parse-entry function
      This function gets passed an entry as returned by the parse-feed
@@ -200,12 +201,12 @@ Here are the keyword-value pair allows in `org-feed-alist'.
 		    (list :inline t :tag "Changed items"
 			  (const :changed-handler)
 			  (symbol :tag "Handler Function"))
-                    (list :inline t :tag "Parse Feed"
-                          (const :parse-feed)
-                          (symbol :tag "Parse Feed Function"))
-                    (list :inline t :tag "Parse Entry"
-                          (const :parse-entry)
-                          (symbol :tag "Parse Entry Function"))
+		    (list :inline t :tag "Parse Feed"
+			  (const :parse-feed)
+			  (symbol :tag "Parse Feed Function"))
+		    (list :inline t :tag "Parse Entry"
+			  (const :parse-entry)
+			  (symbol :tag "Parse Entry Function"))
 		    )))))
 
 (defcustom org-feed-drawer "FEEDSTATUS"
@@ -314,10 +315,10 @@ it can be a list structured like an entry in `org-feed-alist'."
 			org-feed-default-template))
 	  (drawer (or (nth 1 (memq :drawer feed))
 		      org-feed-drawer))
-          (parse-feed (or (nth 1 (memq :parse-feed feed))
-                          'org-feed-parse-rss-feed))
-          (parse-entry (or (nth 1 (memq :parse-entry feed))
-                           'org-feed-parse-rss-entry))
+	  (parse-feed (or (nth 1 (memq :parse-feed feed))
+			  'org-feed-parse-rss-feed))
+	  (parse-entry (or (nth 1 (memq :parse-entry feed))
+			   'org-feed-parse-rss-entry))
 	  feed-buffer inbox-pos new-formatted
 	  entries old-status status new changed guid-alist e guid olds)
       (setq feed-buffer (org-feed-get-feed url))
@@ -333,10 +334,11 @@ it can be a list structured like an entry in `org-feed-alist'."
 	  (setq old-status (org-feed-read-previous-status inbox-pos drawer))
 	  ;; Add the "handled" status to the appropriate entries
 	  (setq entries (mapcar (lambda (e)
-				  (setq e (plist-put e :handled
-						     (nth 1 (assoc
-							     (plist-get e :guid)
-							     old-status)))))
+				  (setq e
+					(plist-put e :handled
+						   (nth 1 (assoc
+							   (plist-get e :guid)
+							   old-status)))))
 				entries))
 	  ;; Find out which entries are new and which are changed
 	  (dolist (e entries)
@@ -637,9 +639,9 @@ formatted as a string, not the original XML data."
     (let ((feed (car (xml-parse-region (point-min) (point-max)))))
       (mapcar
        (lambda (entry)
-         (list
-          :guid (car (xml-node-children (car (xml-get-children entry 'id))))
-          :item-full-text (prin1-to-string entry)))
+	 (list
+	  :guid (car (xml-node-children (car (xml-get-children entry 'id))))
+	  :item-full-text (prin1-to-string entry)))
        (xml-get-children feed 'entry)))))
 
 (defun org-feed-parse-atom-entry (entry)
@@ -647,28 +649,36 @@ formatted as a string, not the original XML data."
   (let ((xml (car (read-from-string (plist-get entry :item-full-text)))))
     ;; Get first <link href='foo'/>.
     (setq entry (plist-put entry :link
-                           (xml-get-attribute
-                            (car (xml-get-children xml 'link))
-                            'href)))
+			   (xml-get-attribute
+			    (car (xml-get-children xml 'link))
+			    'href)))
     ;; Add <title/> as :title.
     (setq entry (plist-put entry :title
-			   (org-feed-unescape (car (xml-node-children
-						    (car (xml-get-children xml 'title)))))))
+			   (org-feed-unescape
+			    (car (xml-node-children
+				  (car (xml-get-children xml 'title)))))))
     (let* ((content (car (xml-get-children xml 'content)))
-           (type (xml-get-attribute-or-nil content 'type)))
+	   (type (xml-get-attribute-or-nil content 'type)))
       (when content
-        (cond
-         ((string= type "text")
-          ;; We like plain text.
-	  (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content))))))
-         ((string= type "html")
-          ;; TODO: convert HTML to Org markup.
-	  (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content))))))
-         ((string= type "xhtml")
-          ;; TODO: convert XHTML to Org markup.
-          (setq entry (plist-put entry :description (prin1-to-string (xml-node-children content)))))
-         (t
-          (setq entry (plist-put entry :description (format "Unknown '%s' content." type)))))))
+	(cond
+	 ((string= type "text")
+	  ;; We like plain text.
+	  (setq entry (plist-put entry :description
+				 (org-feed-unescape
+				  (car (xml-node-children content))))))
+	 ((string= type "html")
+	  ;; TODO: convert HTML to Org markup.
+	  (setq entry (plist-put entry :description
+				 (org-feed-unescape
+				  (car (xml-node-children content))))))
+	 ((string= type "xhtml")
+	  ;; TODO: convert XHTML to Org markup.
+	  (setq entry (plist-put entry :description
+				 (prin1-to-string
+				  (xml-node-children content)))))
+	 (t
+	  (setq entry (plist-put entry :description
+				 (format "Unknown '%s' content." type)))))))
     entry))
 
 (provide 'org-feed)
-- 
1.7.1

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

* Re: [Org-mode] feed.el
  2010-07-07  2:53 [Org-mode] feed.el Mark Scala
  2010-07-07  6:22 ` [PATCH 1/2] Load XML library if necessary David Maus
  2010-07-07  6:22 ` [PATCH 2/2] Change indentation to match coding style guideline David Maus
@ 2010-07-07  6:25 ` David Maus
  2 siblings, 0 replies; 6+ messages in thread
From: David Maus @ 2010-07-07  6:25 UTC (permalink / raw)
  To: Mark Scala; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 822 bytes --]

Mark Scala wrote:
>I created a file in ~/org called feeds.org and in that file did C-c C-x g.
>A headline for Slashdot Entries appeared.  But when I do C-c C-x g on that
>entry I get the following message:  "Symbol's value as variable is void:
>xml-entity-alist"

>Nowhere do I find any information about setting that variable.  Any ideas?
>(I'm using the latest development version of Org, compiled from git sources
>today).

The variable is defined in the XML library xml.el and the error
occurs, because this library wasn't loaded when Org parsed the feed.
The patch I've just send should fix this: xml.el is part of Emacs, so
the functions the use xml.el will load it if necessary (i.e. it wasn't
loaded before).

HTH
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Patchwork: Patch 122 Accepted
  2010-07-07  6:22 ` [PATCH 2/2] Change indentation to match coding style guideline David Maus
@ 2010-07-07  6:47   ` Carsten Dominik
  0 siblings, 0 replies; 6+ messages in thread
From: Carsten Dominik @ 2010-07-07  6:47 UTC (permalink / raw)
  To: emacs-orgmode

Patch 122 (http://patchwork.newartisans.com/patch/122/) is now Accepted.

This relates to the following submission:

http://mid.gmane.org/%3C1278483744-8255-2-git-send-email-dmaus%40ictsoc.de%3E

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

* Re: [PATCH 1/2] Load XML library if necessary.
  2010-07-07  6:22 ` [PATCH 1/2] Load XML library if necessary David Maus
@ 2010-07-07  6:50   ` Carsten Dominik
  0 siblings, 0 replies; 6+ messages in thread
From: Carsten Dominik @ 2010-07-07  6:50 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode

Appied, thanks.

- Carsten

On Jul 7, 2010, at 8:22 AM, David Maus wrote:

> * org-feed.el (org-feed-unescape, org-feed-parse-atom-feed): Load XML
> library if necessary.
>
> Function that use xml.el must require 'xml to make sure it is loaded
> at runtime.
> ---
> lisp/org-feed.el |    2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/org-feed.el b/lisp/org-feed.el
> index 999bfd8..e41ad97 100644
> --- a/lisp/org-feed.el
> +++ b/lisp/org-feed.el
> @@ -270,6 +270,7 @@ have been saved."
>
> (defun org-feed-unescape (s)
>   "Unescape protected entities in S."
> +  (require 'xml)
>   (let ((re (concat "&\\("
> 		    (mapconcat 'car xml-entity-alist "\\|")
> 		    "\\);")))
> @@ -630,6 +631,7 @@ containing the properties `:guid' and `:item- 
> full-text'.
>
> The `:item-full-text' property actually contains the sexp
> formatted as a string, not the original XML data."
> +  (require 'xml)
>   (with-current-buffer buffer
>     (widen)
>     (let ((feed (car (xml-parse-region (point-min) (point-max)))))
> -- 
> 1.7.1
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

end of thread, other threads:[~2010-07-11 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07  2:53 [Org-mode] feed.el Mark Scala
2010-07-07  6:22 ` [PATCH 1/2] Load XML library if necessary David Maus
2010-07-07  6:50   ` Carsten Dominik
2010-07-07  6:22 ` [PATCH 2/2] Change indentation to match coding style guideline David Maus
2010-07-07  6:47   ` Patchwork: Patch 122 Accepted Carsten Dominik
2010-07-07  6:25 ` [Org-mode] feed.el David Maus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).