* patches and one bug
@ 2013-06-24 9:58 Ivan Kanis
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Ivan Kanis @ 2013-06-24 9:58 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Emacs Development List
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
Lars,
I have attached more patches.
There is a bug that I don't think I'll fix: it is the function
eww-open-file. It doesn't work with a file that doesn't have HTTP
headers.
emacs-wget fetches a file with wget asynchronously. It pops a small
window with the progress of the download.
I have attached my wget.el. I sent the author an e-mail to see if he
would sign the FSF paper work to include it in Emacs.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-fix-opening-file-URL.patch --]
[-- Type: text/x-diff, Size: 980 bytes --]
From 017c749f5590e0e564d9dab2de7dabd60766318e Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 08:06:08 +0200
Subject: [PATCH 1/7] fix opening file:/// URL
---
emacs/gnus/eww.el | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index 959fc4d..53fa882 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -106,8 +106,9 @@ It will be used when emacs runs on neither Windows or Mac."
(> (length (split-string url "\\.")) 1))
(unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
(setq url (concat "http://" url)))
- (setq url (concat eww-search-prefix
- (replace-regexp-in-string " " "+" url))))
+ (unless (string-match-p "^file:" url)
+ (setq url (concat eww-search-prefix
+ (replace-regexp-in-string " " "+" url)))))
(url-retrieve url 'eww-render (list url)))
;;;###autoload
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-handle-quoted-charset-header.patch --]
[-- Type: text/x-diff, Size: 828 bytes --]
From 22526c5f7dabdf2d48ee58e93cb78c2d1f2ec9ed Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 08:39:26 +0200
Subject: [PATCH 2/7] handle quoted charset header
(https://wincent.com/products/command-t to reproduce bug)
---
emacs/gnus/eww.el | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index 53fa882..aa39585 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -180,7 +180,7 @@ It will be used when emacs runs on neither Windows or Mac."
(pt (point)))
(or (and html-p
(re-search-forward
- "<meta[\t\n\r ]+[^>]*charset=\"?\\([^\t\n\r \"/>]+\\)" nil t)
+ "<meta[\t\n\r ]+[^>]*charset=\"?\\([^\t\n\r \"/>]+\\)[\\\"'.*]" nil t)
(goto-char pt)
(match-string 1))
(and (looking-at
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-key-y-puts-page-url-in-kill-ring.patch --]
[-- Type: text/x-diff, Size: 1035 bytes --]
From f5ccea29a6f31f3d3e742d5d224ec6140a7316e3 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 08:44:58 +0200
Subject: [PATCH 3/7] key 'y' puts page url in kill ring
---
emacs/gnus/eww.el | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index aa39585..50737d5 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -321,6 +321,7 @@ It will be used when emacs runs on neither Windows or Mac."
(define-key map "u" 'eww-up-url)
(define-key map "t" 'eww-top-url)
(define-key map "w" 'eww-browse-with-external-browser)
+ (define-key map "y" 'eww-yank-page-url)
map))
(define-derived-mode eww-mode nil "eww"
@@ -845,6 +846,10 @@ It support Windows and Mac then calls the function specified in
(t
(funcall eww-external-browser url)))))
+(defun eww-yank-page-url ()
+ (interactive)
+ (message eww-current-url)
+ (kill-new eww-current-url))
(provide 'eww)
;;; eww.el ends here
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-tack-at-the-end-of-naked-url.patch --]
[-- Type: text/x-diff, Size: 1236 bytes --]
From b183f74911508df20c2aee843490da05f4535a59 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 10:14:21 +0200
Subject: [PATCH 4/7] tack / at the end of naked url
ie: http://google.com -> http://google.com/
---
emacs/gnus/eww.el | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index 50737d5..d34b84a 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -109,6 +109,16 @@ It will be used when emacs runs on neither Windows or Mac."
(unless (string-match-p "^file:" url)
(setq url (concat eww-search-prefix
(replace-regexp-in-string " " "+" url)))))
+
+ (and (string-match "https*://\\(.*\\)" url)
+ ;; true when url part is just a hostname
+ (not (string-match "/" (substring url (match-beginning 1)
+ (match-end 1))))
+ ;; Last character is not /
+ (not (string= (substring url (1- (length url)) (length url)) "/"))
+ ;; tack / at the end of naked url
+ ;; ie: http://google.com -> http://google.com/
+ (setq url ( concat url "/")))
(url-retrieve url 'eww-render (list url)))
;;;###autoload
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-add-optional-argument-needed-for-browse-url.patch --]
[-- Type: text/x-diff, Size: 888 bytes --]
From b879b382de4ee3f14dbe652ebc996645cf52807a Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 11:17:51 +0200
Subject: [PATCH 5/7] add optional argument needed for browse url
---
emacs/gnus/eww.el | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index d34b84a..f5c2eb9 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -99,8 +99,9 @@ It will be used when emacs runs on neither Windows or Mac."
(defvar eww-contents-url nil)
;;;###autoload
-(defun eww (url)
- "Fetch URL and render the page."
+(defun eww (url &optional new-session interactive-p)
+ "Fetch URL and render the page.
+NEW-SESSION and INTERCATIVE-P are not used"
(interactive "sEnter URL or keywords: ")
(if (and (= (length (split-string url)) 1)
(> (length (split-string url "\\.")) 1))
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-add-emacs-wget.patch --]
[-- Type: text/x-diff, Size: 1131 bytes --]
From 8816a9029f33ca98437ad88323ab9068f5b964fe Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 11:41:58 +0200
Subject: [PATCH 6/7] add emacs-wget
---
emacs/gnus/shr.el | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/emacs/gnus/shr.el b/emacs/gnus/shr.el
index 868956d..5f74f27 100644
--- a/emacs/gnus/shr.el
+++ b/emacs/gnus/shr.el
@@ -141,6 +141,7 @@ cid: URL as the argument.")
(define-key map "u" 'shr-copy-url)
(define-key map "v" 'shr-browse-url)
(define-key map "o" 'shr-save-contents)
+ (define-key map "d" 'shr-wget)
(define-key map "\r" 'shr-browse-url)
map))
@@ -1634,6 +1635,17 @@ ones, in case fg and bg are nil."
(list oldval face)
(list face oldval))))))))))
+(defun shr-wget ()
+ "Download URL under point."
+ (interactive)
+ (when (not (fboundp 'wget-api))
+ (error "You need to install emacs-wget."))
+
+ (let ((url (get-text-property (point) 'shr-url)))
+ (if (not url)
+ (message "No URL under point")
+ (wget-api url nil))))
+
(provide 'shr)
;; Local Variables:
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-C-u-RET-opens-link-in-external-browser.patch --]
[-- Type: text/x-diff, Size: 1062 bytes --]
From 5ab007318cab14c2cb354a8d2c956321d4fe09f3 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 11:50:25 +0200
Subject: [PATCH 7/7] C-u RET opens link in external browser
---
emacs/gnus/shr.el | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/emacs/gnus/shr.el b/emacs/gnus/shr.el
index 5f74f27..117c7f6 100644
--- a/emacs/gnus/shr.el
+++ b/emacs/gnus/shr.el
@@ -640,9 +640,9 @@ size, and full-buffer size."
(forward-line 1)
(goto-char end))))))
-(defun shr-browse-url ()
+(defun shr-browse-url (arg)
"Browse the URL under point."
- (interactive)
+ (interactive "P")
(let ((url (get-text-property (point) 'shr-url)))
(cond
((not url)
@@ -650,7 +650,9 @@ size, and full-buffer size."
((string-match "^mailto:" url)
(browse-url-mail url))
(t
- (browse-url url)))))
+ (if arg
+ (eww-browse-with-external-browser)
+ (browse-url url))))))
(defun shr-save-contents (directory)
"Save the contents from URL in a file."
--
1.7.1
[-- Attachment #9: wget.el --]
[-- Type: application/emacs-lisp, Size: 39567 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 9:58 patches and one bug Ivan Kanis
@ 2013-06-24 13:36 ` Lars Magne Ingebrigtsen
2013-06-24 13:43 ` Lars Magne Ingebrigtsen
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-24 13:36 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Ivan Kanis <ivan@kanis.fr> writes:
> emacs-wget fetches a file with wget asynchronously. It pops a small
> window with the progress of the download.
I don't see the point -- Emacs is perfectly able to download stuff
asynchronously itself.
> - (setq url (concat eww-search-prefix
> - (replace-regexp-in-string " " "+" url))))
> + (unless (string-match-p "^file:" url)
> + (setq url (concat eww-search-prefix
> + (replace-regexp-in-string " " "+" url)))))
Applied.
> Subject: [PATCH 2/7] handle quoted charset header
Applied.
> Subject: [PATCH 3/7] key 'y' puts page url in kill ring
Applied.
> Subject: [PATCH 4/7] tack / at the end of naked url
[...]
> + (and (string-match "https*://\\(.*\\)" url)
> + ;; true when url part is just a hostname
> + (not (string-match "/" (substring url (match-beginning 1)
> + (match-end 1))))
> + ;; Last character is not /
> + (not (string= (substring url (1- (length url)) (length url)) "/"))
> + ;; tack / at the end of naked url
> + ;; ie: http://google.com -> http://google.com/
> + (setq url ( concat url "/")))
> (url-retrieve url 'eww-render (list url)))
First of all, use `url-generic-parse-url' to parse an URL instead of
using regexps. Second of all, I don't really see the point. We'll get
a redirect, anyway.
> Subject: [PATCH 5/7] add optional argument needed for browse url
[...]
> -(defun eww (url)
> - "Fetch URL and render the page."
> +(defun eww (url &optional new-session interactive-p)
> + "Fetch URL and render the page.
> +NEW-SESSION and INTERCATIVE-P are not used"
No, just use `url-browse-url' instead.
> Subject: [PATCH 6/7] add emacs-wget
[...]
> +(defun shr-wget ()
> + "Download URL under point."
> + (interactive)
> + (when (not (fboundp 'wget-api))
> + (error "You need to install emacs-wget."))
Downloading the URL under point is fine, but just use `url-retrieve'.
> Subject: [PATCH 7/7] C-u RET opens link in external browser
Applied.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
@ 2013-06-24 13:43 ` Lars Magne Ingebrigtsen
2013-06-24 14:05 ` Rüdiger Sonderfeld
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-24 13:43 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>> Subject: [PATCH 7/7] C-u RET opens link in external browser
>
> Applied.
Actually not applied. shr shouldn't rely on eww stuff. Perhaps a
solution would be to move the external-browser stuff to shr instead.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
2013-06-24 13:43 ` Lars Magne Ingebrigtsen
@ 2013-06-24 14:05 ` Rüdiger Sonderfeld
2013-06-24 17:42 ` Lars Magne Ingebrigtsen
2013-06-24 16:18 ` Ivan Kanis
2013-06-24 16:46 ` Ivan Kanis
3 siblings, 1 reply; 14+ messages in thread
From: Rüdiger Sonderfeld @ 2013-06-24 14:05 UTC (permalink / raw)
To: emacs-devel; +Cc: Ivan Kanis, Lars Magne Ingebrigtsen
On Monday 24 June 2013 15:36:40 Lars Magne Ingebrigtsen wrote:
> > - (setq url (concat eww-search-prefix
> > - (replace-regexp-in-string " " "+" url))))
> > + (unless (string-match-p "^file:" url)
> > + (setq url (concat eww-search-prefix
> > + (replace-regexp-in-string " " "+" url)))))
>
> Applied.
Minor nitpick. The regex should probably use \\` instead of ^. The former
matches only at the beginning of the string while the latter also matches
after newlines.
"\\`file:"
Regards,
Rüdiger
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
2013-06-24 13:43 ` Lars Magne Ingebrigtsen
2013-06-24 14:05 ` Rüdiger Sonderfeld
@ 2013-06-24 16:18 ` Ivan Kanis
2013-06-24 17:36 ` Lars Magne Ingebrigtsen
2013-06-24 16:46 ` Ivan Kanis
3 siblings, 1 reply; 14+ messages in thread
From: Ivan Kanis @ 2013-06-24 16:18 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Emacs Development List
[-- Attachment #1: Type: text/plain, Size: 314 bytes --]
June, 24 at 15:36 Lars Magne Ingebrigtsen wrote:
>> +(defun shr-wget ()
>> + "Download URL under point."
>> + (interactive)
>> + (when (not (fboundp 'wget-api))
>> + (error "You need to install emacs-wget."))
>
> Downloading the URL under point is fine, but just use `url-retrieve'.
How about this patch?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-use-url-retrieve-to-download-files.patch --]
[-- Type: text/x-diff, Size: 1966 bytes --]
From 3168367eed8a388efe7bf934cb3d626b9c98e44c Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 18:15:05 +0200
Subject: [PATCH] use url-retrieve to download files
---
emacs/misc/eww.el | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/emacs/misc/eww.el b/emacs/misc/eww.el
index 5359925..0db84ab 100644
--- a/emacs/misc/eww.el
+++ b/emacs/misc/eww.el
@@ -50,6 +50,12 @@
:group 'eww
:type 'string)
+(defcustom eww-download-path "~"
+ "Path where files will downloaded."
+ :version "24.4"
+ :group 'eww
+ :type 'string)
+
(defface eww-form-submit
'((((type x w32 ns) (class color)) ; Like default mode line
:box (:line-width 2 :style released-button)
@@ -319,6 +325,7 @@ word(s) will be searched for via `eww-search-prefix'."
(define-key map "u" 'eww-up-url)
(define-key map "t" 'eww-top-url)
(define-key map "w" 'eww-browse-with-external-browser)
+ (define-key map "d" 'eww-download)
(define-key map "y" 'eww-yank-page-url)
map))
@@ -841,6 +848,26 @@ The browser to used is specified by the `shr-external-browser' variable."
(interactive)
(message eww-current-url)
(kill-new eww-current-url))
+
+(defun shr-download ()
+ "Download URL under point."
+ (interactive)
+ (let ((url (get-text-property (point) 'shr-url)))
+ (if (not url)
+ (message "No URL under point")
+ (if (fboundp 'wget-api)
+ (wget-api url nil)
+ (url-retrieve url 'shr-download-callback (list url))))))
+
+(defun shr-download-callback (status url)
+ "Download callback."
+ (unless (plist-get status :error)
+ (let* ((obj (url-generic-parse-url url))
+ (path (car (url-path-and-query obj)))
+ (file (file-name-nondirectory path)))
+ (write-file (expand-file-name (concat eww-download-path "/" file)))
+ (message "File %s saved." file))))
+
(provide 'eww)
;;; eww.el ends here
--
1.7.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 16:18 ` Ivan Kanis
@ 2013-06-24 17:36 ` Lars Magne Ingebrigtsen
2013-06-24 19:41 ` Ivan Kanis
0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-24 17:36 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Ivan Kanis <ivan@kanis.fr> writes:
> How about this patch?
> + (if (fboundp 'wget-api)
> + (wget-api url nil)
> + (url-retrieve url 'shr-download-callback (list url))))))
Looks good, but just drop the wget stuff altogether.
> + (write-file (expand-file-name (concat eww-download-path "/" file)))
That should be `(expand-file-name file eww-download-path)'
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 17:36 ` Lars Magne Ingebrigtsen
@ 2013-06-24 19:41 ` Ivan Kanis
2013-06-24 19:47 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Ivan Kanis @ 2013-06-24 19:41 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Emacs Development List
June, 24 at 19:36 Lars Magne Ingebrigtsen wrote:
> Ivan Kanis <ivan@kanis.fr> writes:
>
>> How about this patch?
>> + (if (fboundp 'wget-api)
>> + (wget-api url nil)
>> + (url-retrieve url 'shr-download-callback (list url))))))
>
> Looks good, but just drop the wget stuff altogether.
Aww that's too bad. I will have to override the function in my
configuration :(
>
>> + (write-file (expand-file-name (concat eww-download-path "/" file)))
>
> That should be `(expand-file-name file eww-download-path)'
I didn't know expand-file-name did that, neat.
Do you want a new patch?
--
Your program is not ISO 9000 compliant.
-- BOFH excuse #56
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 19:41 ` Ivan Kanis
@ 2013-06-24 19:47 ` Lars Magne Ingebrigtsen
2013-06-25 6:21 ` Ivan Kanis
0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-24 19:47 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Ivan Kanis <ivan@kanis.fr> writes:
> Do you want a new patch?
Yes, please.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 19:47 ` Lars Magne Ingebrigtsen
@ 2013-06-25 6:21 ` Ivan Kanis
2013-06-25 19:51 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Ivan Kanis @ 2013-06-25 6:21 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Emacs Development List
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
June, 24 at 21:47 Lars Magne Ingebrigtsen wrote:
> Ivan Kanis <ivan@kanis.fr> writes:
>
>> Do you want a new patch?
>
> Yes, please.
Here you go. I have removed wget-api. Instead I use a variable that will
hold the function to call.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-use-url-retrieve-to-download-files.patch --]
[-- Type: text/x-diff, Size: 2337 bytes --]
From 8a251f6f85ffa9ba3cf48d2c95ac27eeda58ac4d Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Mon, 24 Jun 2013 18:15:05 +0200
Subject: [PATCH] use url-retrieve to download files
---
emacs/misc/eww.el | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/emacs/misc/eww.el b/emacs/misc/eww.el
index 7b37eda..96e70b1 100644
--- a/emacs/misc/eww.el
+++ b/emacs/misc/eww.el
@@ -50,6 +50,20 @@
:group 'eww
:type 'string)
+(defcustom eww-download-path "~"
+ "Path where files will downloaded."
+ :version "24.4"
+ :group 'eww
+ :type 'string)
+
+(defcustom eww-download-function nil
+ "Function used to download a link.
+The function takes one argument. It is the URL of the link. It is
+called in `shr-download'."
+ :version "24.4"
+ :group 'shr
+ :type 'function)
+
(defface eww-form-submit
'((((type x w32 ns) (class color)) ; Like default mode line
:box (:line-width 2 :style released-button)
@@ -323,6 +337,7 @@ word(s) will be searched for via `eww-search-prefix'."
(define-key map "u" 'eww-up-url)
(define-key map "t" 'eww-top-url)
(define-key map "w" 'eww-browse-with-external-browser)
+ (define-key map "d" 'eww-download)
(define-key map "y" 'eww-yank-page-url)
map))
@@ -845,6 +860,27 @@ The browser to used is specified by the `shr-external-browser' variable."
(interactive)
(message eww-current-url)
(kill-new eww-current-url))
+
+(defun eww-download ()
+ "Download URL under point.
+It calls `shr-dowload-function' with argument URL if it's non-nil."
+ (interactive)
+ (let ((url (get-text-property (point) 'shr-url)))
+ (if (not url)
+ (message "No URL under point")
+ (if eww-download-function
+ (funcall eww-download-function url)
+ (url-retrieve url 'eww-download-callback (list url))))))
+
+(defun eww-download-callback (status url)
+ "Download callback."
+ (unless (plist-get status :error)
+ (let* ((obj (url-generic-parse-url url))
+ (path (car (url-path-and-query obj)))
+ (file (file-name-nondirectory path)))
+ (write-file (expand-file-name file eww-download-path))
+ (message (expand-file-name file eww-download-path))
+ (message "File %s saved." file))))
+
(provide 'eww)
-;;; eww.el ends here
--
1.7.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-25 6:21 ` Ivan Kanis
@ 2013-06-25 19:51 ` Lars Magne Ingebrigtsen
2013-06-25 20:23 ` Ivan Kanis
0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-25 19:51 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Ivan Kanis <ivan@kanis.fr> writes:
>>> Do you want a new patch?
>>
>> Yes, please.
>
> Here you go. I have removed wget-api. Instead I use a variable that will
> hold the function to call.
Ok; mostly applied, but I removed that variable. Doesn't `url-retrieve'
work perfectly?
And I added some more code to avoid overwriting existing files and stuff.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-25 19:51 ` Lars Magne Ingebrigtsen
@ 2013-06-25 20:23 ` Ivan Kanis
0 siblings, 0 replies; 14+ messages in thread
From: Ivan Kanis @ 2013-06-25 20:23 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Emacs Development List
June, 25 at 21:51 Lars Magne Ingebrigtsen wrote:
> Ivan Kanis <ivan@kanis.fr> writes:
>
>>>> Do you want a new patch?
>>>
>>> Yes, please.
>>
>> Here you go. I have removed wget-api. Instead I use a variable that will
>> hold the function to call.
>
> Ok; mostly applied, but I removed that variable. Doesn't `url-retrieve'
> work perfectly?
Bummer, I'll have to redefine the function in my customization :(
--
Backup tape overwritten with copy of system manager's favourite CD.
-- BOFH excuse #10
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: patches and one bug
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
` (2 preceding siblings ...)
2013-06-24 16:18 ` Ivan Kanis
@ 2013-06-24 16:46 ` Ivan Kanis
2013-06-24 17:39 ` Lars Magne Ingebrigtsen
3 siblings, 1 reply; 14+ messages in thread
From: Ivan Kanis @ 2013-06-24 16:46 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Emacs Development List
[-- Attachment #1: Type: text/plain, Size: 382 bytes --]
June, 24 at 15:36 Lars Magne Ingebrigtsen wrote:
> First of all, use `url-generic-parse-url' to parse an URL instead of
> using regexps. Second of all, I don't really see the point. We'll get
> a redirect, anyway.
My site doesn't redirect. Try:
M-x eww kanis.fr
I am sure I am not the only one ;)
I rewrote the patch with `url-generic-parse-url'.
Does it look good to you?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-add-for-web-site-that-don-t-redirect.patch --]
[-- Type: text/x-diff, Size: 1201 bytes --]
From 18f9f3ba20a76a3f27dc8648391a1b0d720b3402 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@kanis.fr>
Date: Mon, 24 Jun 2013 18:39:39 +0200
Subject: [PATCH] add / for web site that don't redirect
---
emacs/misc/eww.el | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/emacs/misc/eww.el b/emacs/misc/eww.el
index 0db84ab..3a8ec0b 100644
--- a/emacs/misc/eww.el
+++ b/emacs/misc/eww.el
@@ -108,8 +108,12 @@ word(s) will be searched for via `eww-search-prefix'."
(interactive "sEnter URL or keywords: ")
(if (and (= (length (split-string url)) 1)
(> (length (split-string url "\\.")) 1))
- (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
- (setq url (concat "http://" url)))
+ (progn
+ (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
+ (setq url (concat "http://" url)))
+ ;; some site don't redirect final /
+ (when (string= (url-filename (url-generic-parse-url url)) "")
+ (setq url (concat url "/"))))
(unless (string-match-p "^file:" url)
(setq url (concat eww-search-prefix
(replace-regexp-in-string " " "+" url)))))
--
1.7.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-06-25 20:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-24 9:58 patches and one bug Ivan Kanis
2013-06-24 13:36 ` Lars Magne Ingebrigtsen
2013-06-24 13:43 ` Lars Magne Ingebrigtsen
2013-06-24 14:05 ` Rüdiger Sonderfeld
2013-06-24 17:42 ` Lars Magne Ingebrigtsen
2013-06-24 16:18 ` Ivan Kanis
2013-06-24 17:36 ` Lars Magne Ingebrigtsen
2013-06-24 19:41 ` Ivan Kanis
2013-06-24 19:47 ` Lars Magne Ingebrigtsen
2013-06-25 6:21 ` Ivan Kanis
2013-06-25 19:51 ` Lars Magne Ingebrigtsen
2013-06-25 20:23 ` Ivan Kanis
2013-06-24 16:46 ` Ivan Kanis
2013-06-24 17:39 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.