[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/xkcd 20e0b48044 42/82: Correct flycheck warnings
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/xkcd 20e0b48044 42/82: Correct flycheck warnings |
Date: |
Mon, 12 Dec 2022 21:59:52 -0500 (EST) |
branch: elpa/xkcd
commit 20e0b480444b23b018fb55ae65e96df4b45349fe
Author: Raphaël Cauderlier <cauderlier@crans.org>
Commit: Raphaël Cauderlier <cauderlier@crans.org>
Correct flycheck warnings
I use both emacs-lisp and emacs-lisp-checkdoc checkers.
---
xkcd.el | 104 +++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 54 insertions(+), 50 deletions(-)
diff --git a/xkcd.el b/xkcd.el
index 5a51f65c99..3cb49781ec 100644
--- a/xkcd.el
+++ b/xkcd.el
@@ -53,7 +53,8 @@
(defvar xkcd-latest 0)
(defgroup xkcd nil
- "A xkcd reader for Emacs")
+ "A xkcd reader for Emacs"
+ :group 'multimedia)
(defcustom xkcd-cache-dir "~/.emacs.d/xkcd/"
"Directory to cache images and json files to."
@@ -61,12 +62,16 @@
:type 'directory)
(defcustom xkcd-cache-latest (concat xkcd-cache-dir "latest")
- "File to store the latest cached xkcd number in. Should preferably
-be located in xkcd-cache-dir"
+ "File to store the latest cached xkcd number in.
+Should preferably be located in `xkcd-cache-dir'."
:group 'xkcd
:type 'file)
(defun xkcd-get-json (url &optional num)
+ "Fetch the Json coming from URL.
+If the file NUM.json exists, use it instead.
+If NUM is 0, always download from URL.
+The return value is a string."
(let ((json-string nil)
(file (concat xkcd-cache-dir (number-to-string num) ".json")))
(with-current-buffer (if (and (file-exists-p file) (not (eq num 0)))
@@ -81,7 +86,8 @@ be located in xkcd-cache-dir"
json-string))
(defun xkcd-download (url num)
- "Download the image linked by URL. If the file arleady exists, do nothing"
+ "Download the image linked by URL to NUM.png.
+If the file NUM.png arleady exists, do nothing"
;;check if the cache directory exists
(if (not (file-exists-p xkcd-cache-dir))
(make-directory xkcd-cache-dir))
@@ -91,7 +97,7 @@ be located in xkcd-cache-dir"
(url-copy-file url name))))
(defun xkcd-cache-json (num json-string)
- "Save xkcd NUM's JSON-STRING to cache directory, and write xkcd-latest to a
file"
+ "Save xkcd NUM's JSON-STRING to cache directory, and write xkcd-latest to a
file."
(let ((name (concat xkcd-cache-dir (number-to-string num) ".json"))
(file (concat xkcd-cache-latest)))
(if (> num xkcd-latest)
@@ -101,7 +107,7 @@ be located in xkcd-cache-dir"
(insert (number-to-string num))
(save-buffer)
(kill-buffer (current-buffer))))
-
+
(if (file-exists-p name)
nil
(with-current-buffer (find-file name)
@@ -111,89 +117,87 @@ be located in xkcd-cache-dir"
;;;###autoload
(defun xkcd-get (num)
- "Get the xkcd number NUM"
+ "Get the xkcd number NUM."
(interactive "nEnter comic number: ")
(xkcd-update-latest)
(get-buffer-create "*xkcd*")
(switch-to-buffer "*xkcd*")
(if (and (boundp 'xkcd-mode) (not xkcd-mode))
(xkcd-mode))
- (if buffer-read-only
- (toggle-read-only))
- (erase-buffer)
- (setq xkcd-cur num)
- (let ((out (if (eq num 0)
- (xkcd-get-json "http://xkcd.com/info.0.json" 0)
- (xkcd-get-json (concat "http://xkcd.com/" (number-to-string num)
- "/info.0.json") num)))
- (img nil)
- (num nil)
- (title nil))
- (setq num (cdr (assoc 'num (json-read-from-string out))))
- (setq img (cdr (assoc 'img (json-read-from-string out))))
-
- ;; FIXME: This looks pretty ugly.
- (message "Getting comic...")
- (xkcd-download img num)
- (setq title (format "%d: %s" (cdr (assoc 'num (json-read-from-string out)))
- (cdr (assoc 'safe_title (json-read-from-string out)))))
- (insert (concat title "\n"))
- (let ((start (point)))
- (insert-image (create-image
- (concat xkcd-cache-dir
- (number-to-string
- (cdr
- (assoc 'num (json-read-from-string out))))
".png") 'png))
- (add-text-properties start (point) '(help-echo xkcd-alt))
- )
- (if (eq xkcd-cur 0)
- (setq xkcd-cur (cdr (assoc 'num (json-read-from-string out)))))
- (xkcd-cache-json num out)
- (setq xkcd-alt (cdr (assoc 'alt (json-read-from-string out))))
- (read-only-mode)
- (message title)))
+ (let (buffer-read-only)
+ (erase-buffer)
+ (setq xkcd-cur num)
+ (let ((out (if (eq num 0)
+ (xkcd-get-json "http://xkcd.com/info.0.json" 0)
+ (xkcd-get-json (concat "http://xkcd.com/" (number-to-string
num)
+ "/info.0.json") num)))
+ (img nil)
+ (num nil)
+ (title nil))
+ (setq num (cdr (assoc 'num (json-read-from-string out))))
+ (setq img (cdr (assoc 'img (json-read-from-string out))))
+
+ ;; FIXME: This looks pretty ugly.
+ (message "Getting comic...")
+ (xkcd-download img num)
+ (setq title (format "%d: %s" (cdr (assoc 'num (json-read-from-string
out)))
+ (cdr (assoc 'safe_title (json-read-from-string
out)))))
+ (insert (concat title "\n"))
+ (let ((start (point)))
+ (insert-image (create-image
+ (concat xkcd-cache-dir
+ (number-to-string
+ (cdr
+ (assoc 'num (json-read-from-string out))))
".png") 'png))
+ (add-text-properties start (point) '(help-echo xkcd-alt))
+ )
+ (if (eq xkcd-cur 0)
+ (setq xkcd-cur (cdr (assoc 'num (json-read-from-string out)))))
+ (xkcd-cache-json num out)
+ (setq xkcd-alt (cdr (assoc 'alt (json-read-from-string out))))
+ (message title))))
(defun xkcd-next ()
- "Get next xkcd"
+ "Get next xkcd."
(interactive)
(xkcd-get (+ xkcd-cur 1)))
(defun xkcd-prev ()
- "Get previous xkcd"
+ "Get previous xkcd."
(interactive)
(xkcd-get (- xkcd-cur 1)))
(defun xkcd-rand ()
- "Show random xkcd"
+ "Show random xkcd."
(interactive)
(xkcd-get (random (cdr (assoc 'num (json-read-from-string
(xkcd-get-json
"http://xkcd.com/info.0.json" 0)))))))
-
+
(defun xkcd-get-latest ()
- "Get the latest xkcd"
+ "Get the latest xkcd."
(interactive)
(xkcd-get 0))
(defalias 'xkcd 'xkcd-get-latest)
(defun xkcd-get-latest-cached ()
- "Get the latest cached xkcd"
+ "Get the latest cached xkcd."
(interactive)
(xkcd-update-latest)
(xkcd-get xkcd-latest))
(defun xkcd-alt-text ()
- "View the alt text in the buffer"
+ "View the alt text in the buffer."
(interactive)
(message xkcd-alt))
(defun xkcd-kill-buffer ()
- "Kill the xkcd buffer"
+ "Kill the xkcd buffer."
(interactive)
(kill-buffer "*xkcd*"))
(defun xkcd-update-latest ()
- "Update xkcd-latest to point to the last cached comic"
+ "Update `xkcd-latest' to point to the last cached comic."
(let ((file (concat xkcd-cache-latest)))
(with-current-buffer (find-file file)
(setq xkcd-latest (string-to-number
- [nongnu] elpa/xkcd 4d280972bc 35/82: Add (xkcd-update-latest) to xkcd-get., (continued)
- [nongnu] elpa/xkcd 4d280972bc 35/82: Add (xkcd-update-latest) to xkcd-get., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd b966b340b4 22/82: Rename to xkcd.el, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd e04bb9535d 44/82: Incorporate some changes from rafoo's branch., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 57659266fa 65/82: Fix jpg viewing issue., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd a55c3f7dcd 75/82: Add faces to comic title., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 80011da2e7 82/82: Update copyright years., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd ca3eed5603 80/82: Prefer HTTPS to HTTP, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 5c10f6a679 21/82: Merge pull request #4 from purcell/patch-1, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 25594f98c7 31/82: Add info about Melpa in README., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 52c0d270de 36/82: Use one-letter keybindings, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 20e0b48044 42/82: Correct flycheck warnings,
ELPA Syncer <=
- [nongnu] elpa/xkcd f5942003bf 45/82: Fix xkcd-get-json, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 3c13ae29c4 49/82: Docstrings, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd e2daa08012 25/82: Add a better screenshot., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd df47be622f 28/82: The package isn't that hackish now., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd d1bc89dee2 34/82: Add variable xkcd-latest: Stores the latest cached xkcd number., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 7b1a312239 37/82: Add an help-echo text property to display the alt-text, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd e61b7e6ed6 51/82: xkcd-get-json: Get substring between (point) and (point-max), instead of, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 5693718f71 52/82: Add support for browse-url., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 0db98c2ca2 72/82: Add instructions for el-get., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 046ad2c582 67/82: Add README.org, ELPA Syncer, 2022/12/12