summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-07-26 19:42:01 +0100
committerjao <jao@gnu.org>2022-07-26 19:42:01 +0100
commitbcf4198d468f5ae62cb29041fcccfba5c9aed709 (patch)
tree5684874bc5e3287a53ee8dad7f73fa92db753ef2
parentee070b516cc84e67571444bf27efaabbbb79c894 (diff)
downloadelibs-bcf4198d468f5ae62cb29041fcccfba5c9aed709.tar.gz
elibs-bcf4198d468f5ae62cb29041fcccfba5c9aed709.tar.bz2
better downloads
-rw-r--r--init.el21
1 files changed, 10 insertions, 11 deletions
diff --git a/init.el b/init.el
index 1ab56eb..989a674 100644
--- a/init.el
+++ b/init.el
@@ -1428,29 +1428,28 @@
;;;; downloads using wget
(defun jao-wget--get-title (filename)
- (let ((fn (file-name-base filename)))
- (if (string-blank-p fn)
- (plist-get eww-data :title)
- (subst-char-in-string ?- ? (capitalize fn)))))
+ (or (plist-get eww-data :title)
+ (and (not (string-blank-p (or filename "")))
+ (subst-char-in-string ?- ? (capitalize (file-name-base filename))))))
(defun jao-wget (url &optional user pwd)
- "Download URL using wget."
+ "Download URL using wget and kill a link for an org note."
(let* ((def (file-name-nondirectory url))
(pmt (format "Save %s to: " url))
(read-file-name-function nil)
(dest (expand-file-name
(read-file-name pmt jao-sink-dir nil nil def)))
(title (jao-wget--get-title dest))
- (src-url (jao-url-around-point t))
+ (src-url (or (jao-url-around-point t) (file-name-directory url)))
(auth (when (and user pwd)
`(,(format "--http-user=%s" user)
- ,(format "--http-password=%s" pwd)))))
+ ,(format "--http-password=%s" pwd))))
+ (lnk (concat "doc:" (file-name-nondirectory dest))))
(switch-to-buffer-other-window (get-buffer-create "*downloads*"))
(erase-buffer)
- (kill-new (format "[[doc:%s][%s]] (from [[%s][here]])"
- (file-name-nondirectory dest)
- (read-string "Title: " title)
- (or src-url (file-name-directory url))))
+ (kill-new (format "%s (from %s)"
+ (org-link-make-string lnk title)
+ (org-link-make-string src-url "here")))
(apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url))))
(defun jao-download (url &optional pws)