[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/xkcd 4845ef86f1 76/82: Add prefix arg to next/prev fn, ad
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/xkcd 4845ef86f1 76/82: Add prefix arg to next/prev fn, add copy-link fn |
Date: |
Mon, 12 Dec 2022 21:59:57 -0500 (EST) |
branch: elpa/xkcd
commit 4845ef86f171dae5c3a84095d2d37693870a8ae6
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
Add prefix arg to next/prev fn, add copy-link fn
- It is now possible to navigate the next/prev comics in "jumps"
Example: C-u M-x xkcd-next will take you from comic 1000 to 1004
C-u M-x xkcd-prev will take you from comic 1000 to 996
- Add xkcd-copy-link fn to copy the link to the current comic
- Move the xkcd-custom-dir creation to defcustom.. that way that
directory existence check will happen just once each time xkcd is
loaded.
- Replace hard-coded `~/.emacs.d` with user-emacs-directory
---
xkcd.el | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/xkcd.el b/xkcd.el
index f8192e0ec8..11ae401d85 100644
--- a/xkcd.el
+++ b/xkcd.el
@@ -59,7 +59,9 @@
"A xkcd reader for Emacs"
:group 'multimedia)
-(defcustom xkcd-cache-dir "~/.emacs.d/xkcd/"
+(defcustom xkcd-cache-dir (let ((dir (concat user-emacs-directory "xkcd/")))
+ (make-directory dir :parents)
+ dir)
"Directory to cache images and json files to."
:group 'xkcd
:type 'directory)
@@ -98,9 +100,6 @@ The return value is a string."
(defun xkcd-download (url num)
"Download the image linked by URL to NUM. If NUM arleady exists, do
nothing."
- ;;check if the cache directory exists
- (unless (file-exists-p xkcd-cache-dir)
- (make-directory xkcd-cache-dir))
(let ((name (format "%s%s.%s" xkcd-cache-dir (number-to-string num)
(substring url (- (length url) 3)))))
(if (file-exists-p name)
@@ -175,15 +174,21 @@ If the image is a gif, animate it."
(setq xkcd-alt (cdr (assoc 'alt json-assoc)))
(message title))))
-(defun xkcd-next ()
+(defun xkcd-next (arg)
"Get next xkcd."
- (interactive)
- (xkcd-get (+ xkcd-cur 1)))
+ (interactive "p")
+ (let ((num (+ xkcd-cur arg)))
+ (when (> num xkcd-latest)
+ (setq num xkcd-latest))
+ (xkcd-get num)))
-(defun xkcd-prev ()
+(defun xkcd-prev (arg)
"Get previous xkcd."
- (interactive)
- (xkcd-get (- xkcd-cur 1)))
+ (interactive "p")
+ (let ((num (- xkcd-cur arg)))
+ (when (< num 1)
+ (setq num 1))
+ (xkcd-get num)))
(defun xkcd-rand ()
"Show random xkcd."
@@ -243,5 +248,13 @@ If the image is a gif, animate it."
(browse-url-default-browser (concat
"http://www.explainxkcd.com/wiki/index.php/"
(number-to-string xkcd-cur))))
+(defun xkcd-copy-link ()
+ "Save the link to the current comic to the kill-ring."
+ (interactive)
+ (let ((link (concat "http://xkcd.com/"
+ (number-to-string xkcd-cur))))
+ (kill-new link)
+ (message link)))
+
(provide 'xkcd)
;;; xkcd.el ends here
- [nongnu] elpa/xkcd 6338b49627 40/82: Use major mode instead of minor mode, (continued)
- [nongnu] elpa/xkcd 6338b49627 40/82: Use major mode instead of minor mode, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd c13dacaf70 56/82: Correct table., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd e5d4ab24f6 18/82: Add xkcd-kill-buffer and a keybinding to the function., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 2923195a57 53/82: Add customization option for handling links., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 2db04f9015 66/82: Merge pull request #13 from TobiMarg/master, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 66eceb7896 62/82: Remove xkcd-handle-urls and friends., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd f539b436cc 60/82: Remove xkcd-handle-link parts to prevent links from being broken., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd f940c7646a 74/82: Add line between MELPA badge and text., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 20e24f1c9b 70/82: Code block is in emacs-lisp, fix directories., ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 8f0009f159 77/82: Merge pull request #16 from kaushalmodi/next-prev-args-and-copy-link, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd 4845ef86f1 76/82: Add prefix arg to next/prev fn, add copy-link fn,
ELPA Syncer <=
- [nongnu] elpa/xkcd 2c538d41a9 79/82: Merge pull request #18 from kaushalmodi/retain-quote-style-in-messages, ELPA Syncer, 2022/12/12
- [nongnu] elpa/xkcd b9a3dfa150 33/82: Add docstring for xkcd-alt-text., ELPA Syncer, 2022/12/12
- [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