From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Use special-mode in eww list modes Date: Mon, 12 Oct 2015 19:42:10 +0000 Message-ID: References: <87wpuu5cur.fsf@udel.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e015376043831e70521ed8724 X-Trace: ger.gmane.org 1444678972 26754 80.91.229.3 (12 Oct 2015 19:42:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Oct 2015 19:42:52 +0000 (UTC) To: Mark Oteiza , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 12 21:42:52 2015 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 1Zlizh-0001Fy-TN for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 21:42:50 +0200 Original-Received: from localhost ([::1]:58245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlizc-0006j6-C6 for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 15:42:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlizJ-0006iZ-FN for emacs-devel@gnu.org; Mon, 12 Oct 2015 15:42:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlizH-00022l-Qj for emacs-devel@gnu.org; Mon, 12 Oct 2015 15:42:25 -0400 Original-Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:33284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlizH-00022N-JT for emacs-devel@gnu.org; Mon, 12 Oct 2015 15:42:23 -0400 Original-Received: by obbbh8 with SMTP id bh8so114132961obb.0 for ; Mon, 12 Oct 2015 12:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=q+L0le3Ux6gZkiVgsnz1THq1bZPKAYXNM0VDopQwHDc=; b=00aqAMO0YJC8gS/7G3QhPqIXgWCFzJZRm1IpmIhdiytxeQOjz7CFfpxP9ALo7GdM3T SsHthUwhSNQjrgieGZI5Y0IJ5JoeNgk3OQaS1jeLWE5G2BqiJlKv/q2geHicopPdqrDq V4R+EAg/0zrAQbvW2YUIUV9X2ixywT2FrxayYMKV/oIQFRjudTovxywjFl1uAnvqq2l4 zvVvfXB5mQM2PEcaX5eb35ZT7sVt8NrNZzWb9j8npJ78WR+pGNJ7vUPHFdaiqyYvgUMv UQI3YRrNhxZirFYTAGE+u3WhB17YGBdqXOPg/sg7A2UuU/OtSESqj8amocpN653c1j1p S2oQ== X-Received: by 10.182.126.169 with SMTP id mz9mr4603776obb.63.1444678943123; Mon, 12 Oct 2015 12:42:23 -0700 (PDT) In-Reply-To: <87wpuu5cur.fsf@udel.edu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22a 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:191382 Archived-At: --089e015376043831e70521ed8724 Content-Type: text/plain; charset=UTF-8 I like that idea, cleans up the code a bit. On Sat, Oct 10, 2015 at 11:00 PM Mark Oteiza wrote: > > * lisp/net/eww.el (eww-bookmark-mode, eww-history-mode) > (eww-buffers-mode): Derive from special-mode and remove redundant > setting of buffer-read-only. > (eww-mode-map): Remove redundant keymap parent setting. > (eww-bookmark-mode-map, eww-history-mode-map, eww-buffers-mode-map): > Remove redundant keymap suppressions and mappings. > --- > > Alternatively, I think it would make sense to use tabulated-list-mode > for these listing buffers, except the bookmark mode, since there is > fancy stuff in there for manipulating bookmarks. > > lisp/net/eww.el | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) > > diff --git a/lisp/net/eww.el b/lisp/net/eww.el > index d44890f..bda4e0c 100644 > --- a/lisp/net/eww.el > +++ b/lisp/net/eww.el > @@ -627,7 +627,6 @@ the like." > > (defvar eww-mode-map > (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 [?\t] 'shr-next-link) > @@ -1583,8 +1582,6 @@ If CHARSET is nil then use UTF-8." > > (defvar eww-bookmark-mode-map > (let ((map (make-sparse-keymap))) > - (suppress-keymap map) > - (define-key map "q" 'quit-window) > (define-key map [(control k)] 'eww-bookmark-kill) > (define-key map [(control y)] 'eww-bookmark-yank) > (define-key map "\r" 'eww-bookmark-browse) > @@ -1601,13 +1598,12 @@ If CHARSET is nil then use UTF-8." > :active eww-bookmark-kill-ring])) > map)) > > -(define-derived-mode eww-bookmark-mode nil "eww bookmarks" > +(define-derived-mode eww-bookmark-mode special-mode "eww bookmarks" > "Mode for listing bookmarks. > > \\{eww-bookmark-mode-map}" > (buffer-disable-undo) > - (setq buffer-read-only t > - truncate-lines t)) > + (setq truncate-lines t)) > > ;;; History code > > @@ -1670,8 +1666,6 @@ If CHARSET is nil then use UTF-8." > > (defvar eww-history-mode-map > (let ((map (make-sparse-keymap))) > - (suppress-keymap map) > - (define-key map "q" 'quit-window) > (define-key map "\r" 'eww-history-browse) > ;; (define-key map "n" 'next-error-no-select) > ;; (define-key map "p" 'previous-error-no-select) > @@ -1684,13 +1678,12 @@ If CHARSET is nil then use UTF-8." > :active (get-text-property (line-beginning-position) > 'eww-history)])) > map)) > > -(define-derived-mode eww-history-mode nil "eww history" > +(define-derived-mode eww-history-mode special-mode "eww history" > "Mode for listing eww-histories. > > \\{eww-history-mode-map}" > (buffer-disable-undo) > - (setq buffer-read-only t > - truncate-lines t)) > + (setq truncate-lines t)) > > ;;; eww buffers list > > @@ -1795,8 +1788,6 @@ If CHARSET is nil then use UTF-8." > > (defvar eww-buffers-mode-map > (let ((map (make-sparse-keymap))) > - (suppress-keymap map) > - (define-key map "q" 'quit-window) > (define-key map [(control k)] 'eww-buffer-kill) > (define-key map "\r" 'eww-buffer-select) > (define-key map "n" 'eww-buffer-show-next) > @@ -1812,13 +1803,12 @@ If CHARSET is nil then use UTF-8." > :active (get-text-property (line-beginning-position) > 'eww-buffer)])) > map)) > > -(define-derived-mode eww-buffers-mode nil "eww buffers" > +(define-derived-mode eww-buffers-mode special-mode "eww buffers" > "Mode for listing buffers. > > \\{eww-buffers-mode-map}" > (buffer-disable-undo) > - (setq buffer-read-only t > - truncate-lines t)) > + (setq truncate-lines t)) > > ;;; Desktop support > > -- > 2.6.0 > > > > --089e015376043831e70521ed8724 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I like that idea, cleans up the code a bit.

On Sat, Oct 10, 2015 at 11:00 PM Mar= k Oteiza <mvoteiza@udel.edu>= wrote:

* lisp/net/eww.el (eww-bookmark-mode, eww-history-mode)
(eww-buffers-mode): Derive from special-mode and remove redundant
setting of buffer-read-only.
(eww-mode-map): Remove redundant keymap parent setting.
(eww-bookmark-mode-map, eww-history-mode-map, eww-buffers-mode-map):
Remove redundant keymap suppressions and mappings.
---

Alternatively, I think it would make sense to use tabulated-list-mode
for these listing buffers, except the bookmark mode, since there is
fancy stuff in there for manipulating bookmarks.

lisp/net/eww.el | 22 ++++++----------------
=C2=A01 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index d44890f..bda4e0c 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -627,7 +627,6 @@ the like."

=C2=A0(defvar eww-mode-map
=C2=A0 =C2=A0(let ((map (make-sparse-keymap)))
-=C2=A0 =C2=A0 (set-keymap-parent map special-mode-map)
=C2=A0 =C2=A0 =C2=A0(define-key map "g" 'eww-reload) ;FIXME: = revert-buffer-function instead!
=C2=A0 =C2=A0 =C2=A0(define-key map "G" 'eww)
=C2=A0 =C2=A0 =C2=A0(define-key map [?\t] 'shr-next-link)
@@ -1583,8 +1582,6 @@ If CHARSET is nil then use UTF-8."

=C2=A0(defvar eww-bookmark-mode-map
=C2=A0 =C2=A0(let ((map (make-sparse-keymap)))
-=C2=A0 =C2=A0 (suppress-keymap map)
-=C2=A0 =C2=A0 (define-key map "q" 'quit-window)
=C2=A0 =C2=A0 =C2=A0(define-key map [(control k)] 'eww-bookmark-kill) =C2=A0 =C2=A0 =C2=A0(define-key map [(control y)] 'eww-bookmark-yank) =C2=A0 =C2=A0 =C2=A0(define-key map "\r" 'eww-bookmark-browse= )
@@ -1601,13 +1598,12 @@ If CHARSET is nil then use UTF-8."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :active eww-bookmark-kill-ring]))
=C2=A0 =C2=A0 =C2=A0map))

-(define-derived-mode eww-bookmark-mode nil "eww bookmarks"
+(define-derived-mode eww-bookmark-mode special-mode "eww bookmarks&qu= ot;
=C2=A0 =C2=A0"Mode for listing bookmarks.

=C2=A0\\{eww-bookmark-mode-map}"
=C2=A0 =C2=A0(buffer-disable-undo)
-=C2=A0 (setq buffer-read-only t
-=C2=A0 =C2=A0 =C2=A0 =C2=A0truncate-lines t))
+=C2=A0 (setq truncate-lines t))

=C2=A0;;; History code

@@ -1670,8 +1666,6 @@ If CHARSET is nil then use UTF-8."

=C2=A0(defvar eww-history-mode-map
=C2=A0 =C2=A0(let ((map (make-sparse-keymap)))
-=C2=A0 =C2=A0 (suppress-keymap map)
-=C2=A0 =C2=A0 (define-key map "q" 'quit-window)
=C2=A0 =C2=A0 =C2=A0(define-key map "\r" 'eww-history-browse)=
=C2=A0;;=C2=A0 =C2=A0 (define-key map "n" 'next-error-no-sele= ct)
=C2=A0;;=C2=A0 =C2=A0 (define-key map "p" 'previous-error-no-= select)
@@ -1684,13 +1678,12 @@ If CHARSET is nil then use UTF-8."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :active (get-text-property (line-beginni= ng-position) 'eww-history)]))
=C2=A0 =C2=A0 =C2=A0map))

-(define-derived-mode eww-history-mode nil "eww history"
+(define-derived-mode eww-history-mode special-mode "eww history"=
=C2=A0 =C2=A0"Mode for listing eww-histories.

=C2=A0\\{eww-history-mode-map}"
=C2=A0 =C2=A0(buffer-disable-undo)
-=C2=A0 (setq buffer-read-only t
-=C2=A0 =C2=A0 =C2=A0 =C2=A0truncate-lines t))
+=C2=A0 (setq truncate-lines t))

=C2=A0;;; eww buffers list

@@ -1795,8 +1788,6 @@ If CHARSET is nil then use UTF-8."

=C2=A0(defvar eww-buffers-mode-map
=C2=A0 =C2=A0(let ((map (make-sparse-keymap)))
-=C2=A0 =C2=A0 (suppress-keymap map)
-=C2=A0 =C2=A0 (define-key map "q" 'quit-window)
=C2=A0 =C2=A0 =C2=A0(define-key map [(control k)] 'eww-buffer-kill)
=C2=A0 =C2=A0 =C2=A0(define-key map "\r" 'eww-buffer-select)<= br> =C2=A0 =C2=A0 =C2=A0(define-key map "n" 'eww-buffer-show-next= )
@@ -1812,13 +1803,12 @@ If CHARSET is nil then use UTF-8."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :active (get-text-property (line-beginni= ng-position) 'eww-buffer)]))
=C2=A0 =C2=A0 =C2=A0map))

-(define-derived-mode eww-buffers-mode nil "eww buffers"
+(define-derived-mode eww-buffers-mode special-mode "eww buffers"=
=C2=A0 =C2=A0"Mode for listing buffers.

=C2=A0\\{eww-buffers-mode-map}"
=C2=A0 =C2=A0(buffer-disable-undo)
-=C2=A0 (setq buffer-read-only t
-=C2=A0 =C2=A0 =C2=A0 =C2=A0truncate-lines t))
+=C2=A0 (setq truncate-lines t))

=C2=A0;;; Desktop support

--
2.6.0



--089e015376043831e70521ed8724--