diff options
| author | Ulf Jasper | 2017-10-27 13:26:06 +0200 |
|---|---|---|
| committer | Ulf Jasper | 2017-10-27 13:26:06 +0200 |
| commit | cb185dfd0c227dda14de25d450d0d684e91cafb3 (patch) | |
| tree | 2a8dda2edbb88f84c9787ec6567e31cb72217f6c | |
| parent | c015f935e06cf2ba3ef8f69f5ef086fc1e51c9d1 (diff) | |
| download | emacs-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.texi | 14 | ||||
| -rw-r--r-- | lisp/net/newst-backend.el | 39 |
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 | |||
| 440 | Newsticker to do that for you. | 440 | Newsticker to do that for you. |
| 441 | 441 | ||
| 442 | @vindex newsticker-new-item-functions | 442 | @vindex newsticker-new-item-functions |
| 443 | In order to do so write a function which takes three arguments | 443 | In 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 |
| 447 | the name of the corresponding news feed, | 447 | the name of the corresponding news feed, |
| 448 | @item TITLE | 448 | @item ITEM |
| 449 | the title of the headline, | 449 | the decoded headline. |
| 450 | @item DESC | ||
| 451 | the decoded description of the headline. | ||
| 452 | @end table | 450 | @end table |
| 453 | 451 | ||
| 454 | and add it to @code{newsticker-new-item-functions}. Each function | 452 | and add it to @code{newsticker-new-item-functions}. Each function |
| 455 | contained in this list is called once for each new headline. | 453 | contained in this list is called once for each new headline. |
| 456 | Depending on the feed, the title and the description of a headline you | 454 | Depending on the feed name and the contents of the new headline you |
| 457 | can | 455 | can |
| 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 |
| 465 | automatically save enclosed audio and video files (for which another | 463 | automatically save enclosed audio and video files (for which another |
| 466 | function exists as well, see @code{newsticker-download-images}), | 464 | function exists as well, see @code{newsticker-download-enclosures}), |
| 467 | @item | 465 | @item |
| 468 | flash the screen while playing some sound, | 466 | flash 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. |
| 389 | Each function is called with the following three arguments: | 389 | Each function is called with the following two arguments: |
| 390 | FEED the name of the corresponding news feed, | 390 | FEEDNAME the name of the corresponding news feed, |
| 391 | TITLE the title of the headline, | 391 | ITEM the decoded headline. |
| 392 | DESC the decoded description of the headline. | ||
| 393 | 392 | ||
| 394 | See `newsticker-download-images', and | 393 | See `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 | ||
| 397 | Please note that these functions are called only once for a | 397 | Please 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. |
| 2449 | This function just prints out the values of the FEED and title of the ITEM." | 2449 | This 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. |
| 2456 | If FEED equals \"imagefeed\" download the first image URL found | 2456 | If FEEDNAME equals \"imagefeed\" download the first image URL |
| 2457 | in the description=contents of ITEM to the directory | 2457 | found 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") | 2459 | the 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. |
| 2478 | The object is saved to the directory \"~/tmp/newsticker/FEED/TITLE\", which | 2479 | The object is saved to the directory \"~/tmp/newsticker/FEEDNAME/TITLE\", which |
| 2479 | is created if it does not exist. TITLE is the title of the news | 2480 | is created if it does not exist. TITLE is the title of the news |
| 2480 | item. Argument FEED is ignored. | 2481 | item. Argument FEEDNAME is ignored. |
| 2481 | This function is suited for adding it to `newsticker-new-item-functions'." | 2482 | This 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)) |