unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 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

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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).