aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Jasper2017-10-27 13:26:06 +0200
committerUlf Jasper2017-10-27 13:26:06 +0200
commitcb185dfd0c227dda14de25d450d0d684e91cafb3 (patch)
tree2a8dda2edbb88f84c9787ec6567e31cb72217f6c
parentc015f935e06cf2ba3ef8f69f5ef086fc1e51c9d1 (diff)
downloademacs-cb185dfd0c227dda14de25d450d0d684e91cafb3.tar.gz
emacs-cb185dfd0c227dda14de25d450d0d684e91cafb3.zip
Fix documentation of `newsticker-new-item-functions' (bug#29023).
* lisp/net/newst-backend.el (newsticker-new-item-functions), (newsticker-new-item-functions-sample), (newsticker-download-enclosures): Fix docstring, rename variable feed to feedname (bug#29023). * doc/misc/newsticker.texi (Automatic Processing) (Automatic Processing): Fix documentation of `newsticker-new-item-functions' (bug#29023).
-rw-r--r--doc/misc/newsticker.texi14
-rw-r--r--lisp/net/newst-backend.el39
2 files changed, 26 insertions, 27 deletions
diff --git a/doc/misc/newsticker.texi b/doc/misc/newsticker.texi
index 6928baab1fa..f60ffba358d 100644
--- a/doc/misc/newsticker.texi
+++ b/doc/misc/newsticker.texi
@@ -440,20 +440,18 @@ headlines. Instead of reading headlines yourself you can tell
440Newsticker to do that for you. 440Newsticker to do that for you.
441 441
442@vindex newsticker-new-item-functions 442@vindex newsticker-new-item-functions
443In order to do so write a function which takes three arguments 443In order to do so write a function which takes two arguments
444 444
445@table @var 445@table @var
446@item FEED 446@item FEEDNAME
447the name of the corresponding news feed, 447the name of the corresponding news feed,
448@item TITLE 448@item ITEM
449the title of the headline, 449the decoded headline.
450@item DESC
451the decoded description of the headline.
452@end table 450@end table
453 451
454and add it to @code{newsticker-new-item-functions}. Each function 452and add it to @code{newsticker-new-item-functions}. Each function
455contained in this list is called once for each new headline. 453contained in this list is called once for each new headline.
456Depending on the feed, the title and the description of a headline you 454Depending on the feed name and the contents of the new headline you
457can 455can
458 456
459@itemize 457@itemize
@@ -463,7 +461,7 @@ descriptions (for which a function already exists, see
463@code{newsticker-download-images}), 461@code{newsticker-download-images}),
464@item 462@item
465automatically save enclosed audio and video files (for which another 463automatically save enclosed audio and video files (for which another
466function exists as well, see @code{newsticker-download-images}), 464function exists as well, see @code{newsticker-download-enclosures}),
467@item 465@item
468flash the screen while playing some sound, 466flash the screen while playing some sound,
469@item 467@item
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el
index 7a73d4688aa..048a7e734a6 100644
--- a/lisp/net/newst-backend.el
+++ b/lisp/net/newst-backend.el
@@ -386,12 +386,12 @@ This hook is run at the very end of `newsticker-stop'."
386(defcustom newsticker-new-item-functions 386(defcustom newsticker-new-item-functions
387 nil 387 nil
388 "List of functions run after a new headline has been retrieved. 388 "List of functions run after a new headline has been retrieved.
389Each function is called with the following three arguments: 389Each function is called with the following two arguments:
390FEED the name of the corresponding news feed, 390FEEDNAME the name of the corresponding news feed,
391TITLE the title of the headline, 391ITEM the decoded headline.
392DESC the decoded description of the headline.
393 392
394See `newsticker-download-images', and 393See `newsticker-new-item-functions-sample',
394`newsticker-download-images', and
395`newsticker-download-enclosures' for sample functions. 395`newsticker-download-enclosures' for sample functions.
396 396
397Please note that these functions are called only once for a 397Please note that these functions are called only once for a
@@ -2444,24 +2444,25 @@ LIST must be an element of `newsticker-auto-mark-filter-list'."
2444;; ====================================================================== 2444;; ======================================================================
2445;;; Hook samples 2445;;; Hook samples
2446;; ====================================================================== 2446;; ======================================================================
2447(defun newsticker-new-item-functions-sample (feed item) 2447(defun newsticker-new-item-functions-sample (feedname item)
2448 "Demonstrate the use of the `newsticker-new-item-functions' hook. 2448 "Demonstrate the use of the `newsticker-new-item-functions' hook.
2449This function just prints out the values of the FEED and title of the ITEM." 2449This function just prints out the values of the FEEDNAME and title of the ITEM."
2450 (message (concat "newsticker-new-item-functions-sample: feed=`%s', " 2450 (message (concat "newsticker-new-item-functions-sample: feed=`%s', "
2451 "title=`%s'") 2451 "title=`%s'")
2452 feed (newsticker--title item))) 2452 feedname (newsticker--title item)))
2453 2453
2454(defun newsticker-download-images (feed item) 2454(defun newsticker-download-images (feedname item)
2455 "Download the first image. 2455 "Download the first image.
2456If FEED equals \"imagefeed\" download the first image URL found 2456If FEEDNAME equals \"imagefeed\" download the first image URL
2457in the description=contents of ITEM to the directory 2457found in the description=contents of ITEM to the directory
2458\"~/tmp/newsticker/FEED/TITLE\" where TITLE is the title of the item." 2458\"~/tmp/newsticker/FEEDNAME/TITLE\" where TITLE is the title of
2459 (when (string= feed "imagefeed") 2459the item."
2460 (when (string= feedname "imagefeed")
2460 (let ((title (newsticker--title item)) 2461 (let ((title (newsticker--title item))
2461 (desc (newsticker--desc item))) 2462 (desc (newsticker--desc item)))
2462 (when (string-match "<img src=\"\\(http://[^ \"]+\\)\"" desc) 2463 (when (string-match "<img src=\"\\(http://[^ \"]+\\)\"" desc)
2463 (let ((url (substring desc (match-beginning 1) (match-end 1))) 2464 (let ((url (substring desc (match-beginning 1) (match-end 1)))
2464 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) 2465 (temp-dir (concat "~/tmp/newsticker/" feedname "/" title))
2465 (org-dir default-directory)) 2466 (org-dir default-directory))
2466 (unless (file-directory-p temp-dir) 2467 (unless (file-directory-p temp-dir)
2467 (make-directory temp-dir t)) 2468 (make-directory temp-dir t))
@@ -2473,17 +2474,17 @@ in the description=contents of ITEM to the directory
2473 (list url)) 2474 (list url))
2474 (cd org-dir)))))) 2475 (cd org-dir))))))
2475 2476
2476(defun newsticker-download-enclosures (feed item) 2477(defun newsticker-download-enclosures (feedname item)
2477 "In all FEEDs download the enclosed object of the news ITEM. 2478 "In all feeds download the enclosed object of the news ITEM.
2478The object is saved to the directory \"~/tmp/newsticker/FEED/TITLE\", which 2479The object is saved to the directory \"~/tmp/newsticker/FEEDNAME/TITLE\", which
2479is created if it does not exist. TITLE is the title of the news 2480is created if it does not exist. TITLE is the title of the news
2480item. Argument FEED is ignored. 2481item. Argument FEEDNAME is ignored.
2481This function is suited for adding it to `newsticker-new-item-functions'." 2482This function is suited for adding it to `newsticker-new-item-functions'."
2482 (let ((title (newsticker--title item)) 2483 (let ((title (newsticker--title item))
2483 (enclosure (newsticker--enclosure item))) 2484 (enclosure (newsticker--enclosure item)))
2484 (when enclosure 2485 (when enclosure
2485 (let ((url (cdr (assoc 'url enclosure))) 2486 (let ((url (cdr (assoc 'url enclosure)))
2486 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) 2487 (temp-dir (concat "~/tmp/newsticker/" feedname "/" title))
2487 (org-dir default-directory)) 2488 (org-dir default-directory))
2488 (unless (file-directory-p temp-dir) 2489 (unless (file-directory-p temp-dir)
2489 (make-directory temp-dir t)) 2490 (make-directory temp-dir t))