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 v3] Make eww entry point more info-like Date: Wed, 04 Mar 2015 13:52:25 -0500 Message-ID: <87r3t4k32u.fsf_-_@udel.edu> References: <87r3tmymcp.fsf@udel.edu> <87y4ntyhqu.fsf@mail.linkov.net> <878uftfr46.fsf_-_@udel.edu> <20150220233424.GA4368@holos> <878ufr4kkq.fsf_-_@violet.siamics.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1425495208 23071 80.91.229.3 (4 Mar 2015 18:53:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Mar 2015 18:53:28 +0000 (UTC) To: 19902@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 04 19:53:14 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 1YTEPx-0002ox-7Q for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Mar 2015 19:53:13 +0100 Original-Received: from localhost ([::1]:45975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPw-00014I-DV for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Mar 2015 13:53:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPr-00010N-4b for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:53:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTEPm-0002el-9r for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:53:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPm-0002eb-6Q for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YTEPl-0003bK-TJ for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Mar 2015 18:53: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.142549516613821 (code B ref -1); Wed, 04 Mar 2015 18:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Mar 2015 18:52:46 +0000 Original-Received: from localhost ([127.0.0.1]:35255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTEPW-0003aq-5f for submit@debbugs.gnu.org; Wed, 04 Mar 2015 13:52:46 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57120) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTEPT-0003ad-6y for submit@debbugs.gnu.org; Wed, 04 Mar 2015 13:52:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTEPJ-0002aZ-JQ for submit@debbugs.gnu.org; Wed, 04 Mar 2015 13:52:37 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:35682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPJ-0002aT-Gb for submit@debbugs.gnu.org; Wed, 04 Mar 2015 13:52:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPH-0000aI-SE for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:52:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTEPE-0002Zp-IP for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:52:31 -0500 Original-Received: from mail-qc0-f173.google.com ([209.85.216.173]:41345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEPE-0002Zi-DX for bug-gnu-emacs@gnu.org; Wed, 04 Mar 2015 13:52:28 -0500 Original-Received: by qcvx3 with SMTP id x3so10852276qcv.8 for ; Wed, 04 Mar 2015 10:52:27 -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 :content-transfer-encoding; bh=fpAjZCYEPzdTVDqBdENzm+XAT5rtuN5sv+gpxcHIEQ8=; b=D+DoBSiTTDwFM5fBJjkAFTrWzwtMWLORxzQ4Yz67hE8l5p3e6cBLI5bDMVUQuipnvu UZR0X9WIDz1oGnzqWtrd3aaqIImxa9NFdW6JXb7ktUreqLdYP0uTK0RoNEK4pAcDD2IQ zah6VV4QRf2jXpck5svi9QdQOz8PPLtJRubnGA3OoB+sVS0CRxKY+DDkUUUIFkObH3c9 Lx4M7NhX0KgvlsZPKey00LnuQmoLiaMGRm725ZQxrWfoe2uX/sc8BXUcrnU0xs3TeiIQ vo90VWF4coXN8CyjTPyoy3D8yWheGhklsYmB7aZ2GoJkCKapYP7NDaLupgL36crmWMel +yUQ== X-Gm-Message-State: ALoCoQmfd3ESte5m7/0XfncM9U9CYiBRBlVQvVQw4xa4fliuF3mXyDf50vbiP9jUyL6NkvoMNytg X-Received: by 10.140.87.10 with SMTP id q10mr7151511qgd.67.1425495147377; Wed, 04 Mar 2015 10:52:27 -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 z13sm2663738qaq.15.2015.03.04.10.52.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 10:52:26 -0800 (PST) In-Reply-To: <878ufr4kkq.fsf_-_@violet.siamics.net> (Ivan Shmakov's message of "Sat, 21 Feb 2015 10:37:09 +0000") 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:100066 Archived-At: --- Ivan Shmakov writes: > =E2=80=A6 And thus (or buffer =E2=80=A6) is the same as simply =E2=80=98= buffer=E2=80=99 in the > =E2=80=9Ctrue=E2=80=9D branch. > > (if (and buffer (get-buffer buffer) > (or (not current-prefix-arg) (numberp current-prefix-arg))) > (pop-to-buffer-same-window buffer) > (eww-goto-url url (or buffer "*eww*"))) Thanks, change made lisp/ChangeLog | 13 +++++++++++++ lisp/net/eww.el | 48 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cdd4bf8..9fe4d50 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2015-03-04 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-03-04 Filipp Gunbin =20 * autorevert.el (auto-revert-notify-add-watch): diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 577cd41..4b696f7 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -239,17 +239,42 @@ This list can be customized via `eww-suggest-uris'." (push uri uris))))) (nreverse uris))) =20 +(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-ar= g)))) + (eww-read-string)) + name))) + (if (and buffer (get-buffer buffer) + (or (not current-prefix-arg) (numberp current-prefix-arg))) + (pop-to-buffer-same-window buffer) + (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 +303,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 +556,8 @@ See the `eww-search-prefix' variable for the search eng= ine used." (mailcap-view-mime "application/pdf"))) (goto-char (point-min))) =20 -(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 +649,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 instea= d! - (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 +673,7 @@ the like." =20 (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) =20 (easy-menu-define nil map "" '("Eww" --=20 2.3.1