From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ricardo Wurmus Newsgroups: gmane.emacs.devel Subject: [PATCH 14/15] xwidget: Bind "beginning-of-buffer" and "end-of-buffer" Date: Mon, 24 Oct 2016 18:41:00 +0200 Message-ID: <20161024164101.26043-15-rekado@elephly.net> References: <20161024164101.26043-1-rekado@elephly.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1477328473 9261 195.159.176.226 (24 Oct 2016 17:01:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Oct 2016 17:01:13 +0000 (UTC) Cc: Ricardo Wurmus To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 24 19:01:05 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byic3-0006xA-5Y for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 19:00:39 +0200 Original-Received: from localhost ([::1]:48261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byic5-0001iK-F9 for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 13:00:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byiMg-0000vn-9z for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:44:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byiMf-0003uD-F1 for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:44:46 -0400 Original-Received: from sender163-mail.zoho.com ([74.201.84.163]:21478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byiMf-0003th-6m for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:44:45 -0400 Original-Received: from localhost (89.204.138.233 [89.204.138.233]) by mx.zohomail.com with SMTPS id 14773274785911017.0292571340955; Mon, 24 Oct 2016 09:44:38 -0700 (PDT) X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161024164101.26043-1-rekado@elephly.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 74.201.84.163 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:208728 Archived-At: * lisp/xwidget.el: Rebind "beginning-of-buffer" and "end-of-buffer" to "xwidget-webkit-scroll-top" and "xwidget-webkit-scroll-bottom", respectively. (xwidget-webkit-scroll-top, xwidget-webkit-scroll-bottom): New procedures. --- lisp/xwidget.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 871b729..8aa0584 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -129,8 +129,8 @@ Interactively, URL defaults to the string looking like a url around point." ;; (define-key map [remap move-beginning-of-line] 'image-bol) ;; (define-key map [remap move-end-of-line] 'image-eol) - ;; (define-key map [remap beginning-of-buffer] 'image-bob) - ;; (define-key map [remap end-of-buffer] 'image-eob) + (define-key map [remap beginning-of-buffer] 'xwidget-webkit-scroll-top) + (define-key map [remap end-of-buffer] 'xwidget-webkit-scroll-bottom) map) "Keymap for `xwidget-webkit-mode'.") @@ -172,6 +172,19 @@ Interactively, URL defaults to the string looking like a url around point." (xwidget-webkit-current-session) "window.scrollBy(-50, 0);")) +(defun xwidget-webkit-scroll-top () + "Scroll webkit to the very top." + (interactive) + (xwidget-webkit-execute-script + (xwidget-webkit-current-session) + "window.scrollTo(pageXOffset, 0);")) + +(defun xwidget-webkit-scroll-bottom () + "Scroll webkit to the very bottom." + (interactive) + (xwidget-webkit-execute-script + (xwidget-webkit-current-session) + "window.scrollTo(pageXOffset, window.document.body.clientHeight);")) ;; The xwidget event needs to go into a higher level handler ;; since the xwidget can generate an event even if it's offscreen. -- 2.10.1