emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/xkcd 51bf8b0d49 05/82: Rename functions, make json retriev


From: ELPA Syncer
Subject: [nongnu] elpa/xkcd 51bf8b0d49 05/82: Rename functions, make json retrieving function smaller.
Date: Mon, 12 Dec 2022 21:59:49 -0500 (EST)

branch: elpa/xkcd
commit 51bf8b0d49ea528c98ab79fae803afe2f62b96df
Author: Vibhav Pant <vibhavp@cthulhu-p5kpl.lan>
Commit: Vibhav Pant <vibhavp@cthulhu-p5kpl.lan>

    Rename functions, make json retrieving function smaller.
---
 emacs-xkcd.el | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/emacs-xkcd.el b/emacs-xkcd.el
index 7a5dfe5f74..830a934e38 100644
--- a/emacs-xkcd.el
+++ b/emacs-xkcd.el
@@ -43,14 +43,12 @@
            (define-key map (kbd "C-c t") 'xkcd-alt-text)
            map))
 
-;;taken from http://frozenlock.org/2012/07/07/url-retrieve-and-json-api/
-(defun get-json (url)
+(defun xkcd-get-json (url)
   (let ((buffer (url-retrieve-synchronously url))
         (json nil))
     (with-current-buffer buffer
-      (goto-char (point-min))
-      (re-search-forward "^$" nil 'move)
-      (setq json (buffer-substring-no-properties (point) (point-max)))
+      (re-search-backward "^$")
+      (setq json (buffer-substring-no-properties (+ (point) 1) (point-max)))
       (kill-buffer (current-buffer)))
     json))
 
@@ -109,7 +107,7 @@
   (xkcd-get (random (cdr (assoc 'num (json-read-from-string
                                      (get-json 
"http://xkcd.com/info.0.json";)))))))
   
-(defun get-lastest-xkcd ()
+(defun xkcd-get-latest ()
   "Get the latest xkcd"
   (interactive)
   (if (and (boundp 'xkcd-mode) (not xkcd-mode))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]