From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Kanis Newsgroups: gmane.emacs.devel Subject: [PATCH] eww improvements Date: Sun, 23 Jun 2013 18:58:31 +0200 Message-ID: <8738s8ix1k.fsf@kanis.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1372006752 14157 80.91.229.3 (23 Jun 2013 16:59:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Jun 2013 16:59:12 +0000 (UTC) Cc: Emacs Development List To: Lars Grunewaldt Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 23 18:59:14 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UqndB-0002kZ-9Y for ged-emacs-devel@m.gmane.org; Sun, 23 Jun 2013 18:59:13 +0200 Original-Received: from localhost ([::1]:38260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqndB-00055B-1R for ged-emacs-devel@m.gmane.org; Sun, 23 Jun 2013 12:59:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uqnd4-00054T-41 for emacs-devel@gnu.org; Sun, 23 Jun 2013 12:59:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uqnd0-0007vN-Qw for emacs-devel@gnu.org; Sun, 23 Jun 2013 12:59:06 -0400 Original-Received: from kanis.fr ([46.19.35.252]:41545 helo=srv2.kanis.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uqnd0-0007uB-FM for emacs-devel@gnu.org; Sun, 23 Jun 2013 12:59:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kanis.fr; s=alpha; h=Content-Type:MIME-Version:Message-ID:Date:cc:Subject:To:From; bh=64LdiZA6ZIy+GxEUczaM/tzs8YLcI1+HmThv8bGH0YI=; b=FiAGUtY5TKVwS4mJSpSIrLRXiXB937G0XoDy1L8ukeSdfOXQ6HATIRsfCagRBiz16Uos7yRIBFckk4VIY0rLdWrbNscWQkra0RI57c1Thp4ddS1eZDktgr0vMVFVymEB; Original-Received: from smtp.comencini.fr ([164.138.25.8]) by smtp.comencini.fr with esmtpsa (TLS1.1:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80.1) (envelope-from ) id 1Uqncr-0003nv-Iy; Sun, 23 Jun 2013 18:58:54 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAAB5QTFRF IBkXUxMTOCwoTC4qcUY8iFxQmmper31txpaJ/v/8aKZ1oAAAAcVJREFUOMt100tu2zAQAFDCXnUZ oAcIqG68LZULVLQBbwuSiffm6AIRRyeotAySJoVu2+FPpJWWC3/4NKOZocSW/yxWfnJ2+Bdwzhj7 8gleWVy7DXC2rkMNr2V/zRbghXIwthf3VbIA9Ffc71vZCSFyCEsBggtNS8ludwvfmhYA0Vn9o4DP zMWxR7+cPWzAYFzwM0ModtdmcDbDS6i/hT7L+RZof5yCXGrYe5jn2YO6BYMjgY+51tCIAqHgBLwR pwLnGuRjAKyBJkuN4yd4U92uCY1vUr2D/c5b8DuxyQwfOHUeaLqDJhnkkuGXbB56h2C1IVBdgncc bBi6feroa9B6jUDojnQPQKupbyXyeeCE1oT7Oqrt+SnfY3mkiyGA/3AmD3H5g32CcBx6hY8pRkwJ 9PpcjRGobUfprFnhAa1vepwcgMOhwG+pdSgKHFU9HAvoAH6XUl7lDUCCq5Qb6GMbVm3Aj++qDYCt wdBc/YHgOFCmS3mjDMRcSE2qY4E3Q3PVIQRQmeodNH4QEbRUFZzW+VotzwX4yTcRTySOML1qjcE5 hTirVqDHkMAP0PjAywp3d18JZtqzvr9zDYD+GaSKtE6Zlr/DLPNFmOcvBAAAAABJRU5ErkJggg== User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 46.19.35.252 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160913 Archived-At: --=-=-= Content-Type: text/plain Lars, I have attached 3 patches for eww. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-allow-entering-keywords-for-search-engine.patch >From dfb8f81cb0bc5915e2ffb45cd933b018e7f5d37e Mon Sep 17 00:00:00 2001 From: Ivan Kanis 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-w-key-launches-external-browser-for-current-page-url.patch >From 8e1cb8158dee5d7b65a2e04748fb0e47a7023cb2 Mon Sep 17 00:00:00 2001 From: Ivan Kanis 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 or 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-C-c-C-c-submit-current-form.patch >From 885156af074991ab9a003a641ec1e82d46fc8d78 Mon Sep 17 00:00:00 2001 From: Ivan Kanis 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 or 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 or 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 or 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 or 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 --=-=-=--