all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] eww improvements
@ 2013-06-23 16:58 Ivan Kanis
  2013-06-23 18:29 ` Lars Magne Ingebrigtsen
  2013-06-25  6:07 ` Juri Linkov
  0 siblings, 2 replies; 17+ messages in thread
From: Ivan Kanis @ 2013-06-23 16:58 UTC (permalink / raw)
  To: Lars Grunewaldt; +Cc: Emacs Development List

[-- Attachment #1: Type: text/plain, Size: 43 bytes --]

Lars,

I have attached 3 patches for eww.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-allow-entering-keywords-for-search-engine.patch --]
[-- Type: text/x-diff, Size: 1408 bytes --]

From dfb8f81cb0bc5915e2ffb45cd933b018e7f5d37e Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Sun, 23 Jun 2013 18:20:03 +0200
Subject: [PATCH 1/3] allow entering keywords for search engine

---
 emacs/gnus/eww.el |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index ad19758..4fc9fe0 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -43,6 +43,11 @@
   :group 'eww
   :type 'string)
 
+(defcustom eww-search-prefix "https://duckduckgo.com/html/?q="
+  "Prefix URL to search engine"
+  :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)
@@ -90,9 +95,13 @@
 ;;;###autoload
 (defun eww (url)
   "Fetch URL and render the page."
-  (interactive "sUrl: ")
-  (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
-    (setq url (concat "http://" url)))
+  (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)))
+    (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-w-key-launches-external-browser-for-current-page-url.patch --]
[-- Type: text/x-diff, Size: 1731 bytes --]

From 8e1cb8158dee5d7b65a2e04748fb0e47a7023cb2 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Sun, 23 Jun 2013 18:44:40 +0200
Subject: [PATCH 2/3] 'w' key launches external browser for current page url

---
 emacs/gnus/eww.el |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el
index 4fc9fe0..1b028b1 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -48,6 +48,12 @@
   :group 'eww
   :type 'string)
 
+(defcustom eww-external-browser 'browse-url-firefox
+  "Function called to launch external browser.
+It will be used when emacs runs on neither Windows or Mac."
+  :group 'eww
+  :type 'function)
+
 (defface eww-form-submit
   '((((type x w32 ns) (class color))	; Like default mode line
      :box (:line-width 2 :style released-button)
@@ -313,6 +319,7 @@
     (define-key map "p" 'eww-previous-url)
     (define-key map "u" 'eww-up-url)
     (define-key map "t" 'eww-top-url)
+    (define-key map "w" 'eww-browse-with-external-browser)
     map))
 
 (define-derived-mode eww-mode nil "eww"
@@ -819,6 +826,19 @@ appears in a <link> or <a> tag."
 	"?"
 	(mm-url-encode-www-form-urlencoded values))))))
 
+(defun eww-browse-with-external-browser ()
+  "Browse URL with external browser.
+It support Windows and Mac then calls the function specified in
+ `eww-external-browser'."
+  (interactive)
+  (let ((url eww-current-url))
+    (cond ((eq system-type 'windows-nt)
+           (browse-url-default-windows-browser url))
+          ((eq system-type 'darwin)
+           (browse-url-default-macosx-browser url))
+          (t
+           (funcall eww-external-browser url)))))
+
 (provide 'eww)
 
 ;;; eww.el ends here
-- 
1.7.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-C-c-C-c-submit-current-form.patch --]
[-- Type: text/x-diff, Size: 1898 bytes --]

From 885156af074991ab9a003a641ec1e82d46fc8d78 Mon Sep 17 00:00:00 2001
From: Ivan Kanis <ivan@tao>
Date: Sun, 23 Jun 2013 18:50:20 +0200
Subject: [PATCH 3/3] C-c C-c submit current form

---
 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 1b028b1..959fc4d 100644
--- a/emacs/gnus/eww.el
+++ b/emacs/gnus/eww.el
@@ -405,12 +405,14 @@ appears in a <link> or <a> tag."
 (defvar eww-submit-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\r" 'eww-submit)
+    (define-key map [(control c) (control c)] 'eww-submit)
     map))
 
 (defvar eww-checkbox-map
   (let ((map (make-sparse-keymap)))
     (define-key map [space] 'eww-toggle-checkbox)
     (define-key map "\r" 'eww-toggle-checkbox)
+    (define-key map [(control c) (control c)] 'eww-submit)
     map))
 
 (defvar eww-text-map
@@ -418,6 +420,7 @@ appears in a <link> or <a> tag."
     (set-keymap-parent map text-mode-map)
     (define-key map "\r" 'eww-submit)
     (define-key map [(control a)] 'eww-beginning-of-text)
+    (define-key map [(control c) (control c)] 'eww-submit)
     (define-key map [(control e)] 'eww-end-of-text)
     (define-key map [tab] 'shr-next-link)
     (define-key map [backtab] 'shr-previous-link)
@@ -427,6 +430,7 @@ appears in a <link> or <a> tag."
   (let ((map (make-keymap)))
     (set-keymap-parent map text-mode-map)
     (define-key map "\r" 'forward-line)
+    (define-key map [(control c) (control c)] 'eww-submit)
     (define-key map [tab] 'shr-next-link)
     (define-key map [backtab] 'shr-previous-link)
     map))
@@ -434,6 +438,7 @@ appears in a <link> or <a> tag."
 (defvar eww-select-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\r" 'eww-change-select)
+    (define-key map [(control c) (control c)] 'eww-submit)
     map))
 
 (defun eww-beginning-of-text ()
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-06-25 20:22 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-23 16:58 [PATCH] eww improvements Ivan Kanis
2013-06-23 18:29 ` Lars Magne Ingebrigtsen
2013-06-23 21:48   ` Rüdiger Sonderfeld
2013-06-23 21:52     ` Lars Magne Ingebrigtsen
     [not found]       ` <13724493.P5Ma8CTG7m@descartes>
2013-06-24 13:58         ` Lars Magne Ingebrigtsen
2013-06-24  5:24     ` Ivan Kanis
2013-06-24 11:14       ` Rüdiger Sonderfeld
2013-06-24 13:03         ` Ivan Kanis
2013-06-24 13:18           ` Rüdiger Sonderfeld
2013-06-24 17:01             ` Ivan Kanis
2013-06-24 17:40               ` Lars Magne Ingebrigtsen
2013-06-25  6:07 ` Juri Linkov
2013-06-25  6:29   ` Ivan Kanis
2013-06-25 19:26   ` Lars Magne Ingebrigtsen
2013-06-25 20:15     ` Ivan Kanis
2013-06-25 20:20       ` Lars Magne Ingebrigtsen
2013-06-25 20:22       ` Ivan Kanis

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.