From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like Date: Thu, 19 Feb 2015 17:55:53 -0500 Message-ID: <878uftfr46.fsf_-_@udel.edu> References: <87r3tmymcp.fsf@udel.edu> <87y4ntyhqu.fsf@mail.linkov.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1424386643 20711 80.91.229.3 (19 Feb 2015 22:57:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Feb 2015 22:57:23 +0000 (UTC) To: 19902@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 19 23:57:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1YOa1v-0003bC-5I for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Feb 2015 23:57:11 +0100 Original-Received: from localhost ([::1]:58426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa1u-0001S7-He for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Feb 2015 17:57:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa1q-0001RB-P2 for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:57:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOa1m-0003S2-KN for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:57:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa1m-0003Ry-Gu for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YOa1l-0004A4-TY for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:57:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Feb 2015 22:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.142438656815936 (code B ref -1); Thu, 19 Feb 2015 22:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Feb 2015 22:56:08 +0000 Original-Received: from localhost ([127.0.0.1]:49007 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YOa0t-00048x-RV for submit@debbugs.gnu.org; Thu, 19 Feb 2015 17:56:08 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39951) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YOa0r-00048o-SX for submit@debbugs.gnu.org; Thu, 19 Feb 2015 17:56:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOa0q-00034H-Bo for submit@debbugs.gnu.org; Thu, 19 Feb 2015 17:56:05 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa0q-00034D-7o for submit@debbugs.gnu.org; Thu, 19 Feb 2015 17:56:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa0o-0001Ot-LT for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:56:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOa0i-000336-8f for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:56:02 -0500 Original-Received: from mail-qg0-f42.google.com ([209.85.192.42]:61049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOa0h-00032O-TS for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 17:55:56 -0500 Original-Received: by mail-qg0-f42.google.com with SMTP id z107so10324334qgd.1 for ; Thu, 19 Feb 2015 14:55:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=XMBR6TUG9cyRYdE3avsEHw4wIEpqW7RI0pcxQnUwjpM=; b=U5VxE26trcc1QqVTE+vEygCPO53JXwRPQKAIh1dc9uEPrJBIvoM6zQyf7AteQ3YrXb +KxjY6FunGdqKTjyl7qgnAdCfV80fS4odc3UtCLDWPD1s/LthCPQTaIAbBMgpbkZVUqo ruyIA+TZTTEV9XwH10xHQDSXHmvHgrwinwOWNChGXAIXJgZT7S20VpgnmPnAovfQlkSN 8fvcJfrVuWTfh+vBrIAmiZNSQcFxX4jmC193XOcHR6bG3I/ZIMs9jh2MJ3ILD3CICHr8 V9mF5lFqlMUvUdot5Gl8kb0Ya7NlGpVy8knni0rJlw0gvWkQXWWqvHRMzd3Fympa1Lf9 I6xQ== X-Gm-Message-State: ALoCoQnRvmbugiSDSUxeaysyj/ar4RHv2Ri6Z0mBY1trEoeT7jgbfShY0TCYnxDsUv9kxKFzLixX X-Received: by 10.140.238.2 with SMTP id j2mr17224722qhc.5.1424386554650; Thu, 19 Feb 2015 14:55:54 -0800 (PST) Original-Received: from holos (c-73-163-124-41.hsd1.md.comcast.net. [73.163.124.41]) by mx.google.com with ESMTPSA id q5sm20764764qat.6.2015.02.19.14.55.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 14:55:54 -0800 (PST) In-Reply-To: <87y4ntyhqu.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 19 Feb 2015 21:03:12 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99621 Archived-At: --- Both `C-u M-x eww RET' and `G' (eww-goto-url) in eww prompt for URL using `eww-suggest-uris'. A little argument shuffling had to happen. I think I properly handled the possible uses of `eww' and `eww-goto-url' interactively and in lisp. Regarding the bookmark/info binding, the whole inspiration to this change is to make the eww interface more info-like. Info is a good manual browser, and eww benefits from assimilating features from info to be a good web browser. Between the familiar M-n, eww's "S" command, and the new behavior of `M-x eww', eww's flow has improved. Eww is now a nice tabbed web browser, where each tab's history doesn't get clobbered every time M-x eww is invoked, and one doesn't have to switch-buffer or similar to find an existing eww session. I also have never felt compelled to cycle through my bookmarks, so I am not troubled by losing the bookmark bindings. lisp/ChangeLog | 13 +++++++++++++ lisp/net/eww.el | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3d15b40..fa2f252 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2015-02-19 Mark Oteiza + + * net/eww.el (eww): New behavior. Pops to an existing buffer, + otherwise creates a new one. The buffer name is controlled by + numeric prefix. A non-numeric prefix always prompts for a URL. + (eww-goto-url): New function. Assumes the previous role of `eww', + now accepting an optional `buffer' argument + (eww-read-string): New function. Wrapper for `read-string' + used by `eww' and `eww-goto-url'. + (eww-setup-buffer): Accept `buffer' argument. + (eww-mode-map): Replace existing bindings for M-n and M-p with + a binding of M-n to `clone-buffer'. + 2015-02-19 Dima Kogan * autorevert.el (auto-revert-buffers-counter) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index b7ee065..37df68e 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -239,17 +239,41 @@ This list can be customized via `eww-suggest-uris'." (push uri uris))))) (nreverse uris))) +(defun eww-read-string () + (let* ((uris (eww-suggested-uris)) + (prompt (concat "Enter URL or keywords" + (if uris (format " (default %s)" (car uris))) + ": "))) + (read-string prompt nil nil uris))) + ;;;###autoload -(defun eww (url) +(defun eww (&optional url buffer) + "Enter eww, the Emacs Web Wowser. +Optional argument URL specifies the target to navigate; +the default is `eww-search-prefix'. + +In interactive use, a non-numeric prefix argument directs +this command to read URL from the minibuffer. + +A numeric prefix argument of N selects an eww buffer named \"*eww*\"." + (interactive + (let ((name (if (numberp current-prefix-arg) + (format "*eww*<%s>" current-prefix-arg) + "*eww*"))) + (list (if (or (not (get-buffer name)) + (and current-prefix-arg (not (numberp current-prefix-arg)))) + (eww-read-string)) + name))) + (if (and (get-buffer buffer) (or (not current-prefix-arg) (numberp current-prefix-arg))) + (pop-to-buffer-same-window (or buffer "*eww*")) + (eww-goto-url url (or buffer "*eww*")))) + +(defun eww-goto-url (url &optional buffer) "Fetch URL and render the page. If the input doesn't look like an URL or a domain name, the word(s) will be searched for via `eww-search-prefix'." (interactive - (let* ((uris (eww-suggested-uris)) - (prompt (concat "Enter URL or keywords" - (if uris (format " (default %s)" (car uris)) "") - ": "))) - (list (read-string prompt nil nil uris)))) + (list (eww-read-string))) (setq url (string-trim url)) (cond ((string-match-p "\\`file:/" url)) ;; Don't mangle file: URLs at all. @@ -278,7 +302,7 @@ word(s) will be searched for via `eww-search-prefix'." (when (or (plist-get eww-data :url) (plist-get eww-data :dom)) (eww-save-history)) - (eww-setup-buffer) + (eww-setup-buffer buffer) (plist-put eww-data :url url) (plist-put eww-data :title "") (eww-update-header-line-format) @@ -531,8 +555,8 @@ See the `eww-search-prefix' variable for the search engine used." (mailcap-view-mime "application/pdf"))) (goto-char (point-min))) -(defun eww-setup-buffer () - (switch-to-buffer (get-buffer-create "*eww*")) +(defun eww-setup-buffer (buffer) + (switch-to-buffer (get-buffer-create (or buffer "*eww*"))) (let ((inhibit-read-only t)) (remove-overlays) (erase-buffer)) @@ -624,7 +648,7 @@ the like." (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) (define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead! - (define-key map "G" 'eww) + (define-key map "G" 'eww-goto-url) (define-key map [?\t] 'shr-next-link) (define-key map [?\M-\t] 'shr-previous-link) (define-key map [backtab] 'shr-previous-link) @@ -648,8 +672,7 @@ the like." (define-key map "b" 'eww-add-bookmark) (define-key map "B" 'eww-list-bookmarks) - (define-key map [(meta n)] 'eww-next-bookmark) - (define-key map [(meta p)] 'eww-previous-bookmark) + (define-key map [(meta n)] 'clone-buffer) (easy-menu-define nil map "" '("Eww" -- 2.3.0