From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Add command to browse xwidget history Date: Mon, 15 Nov 2021 13:15:54 +0800 Message-ID: <87a6i62e45.fsf@yahoo.com> References: <87a6i62e45.fsf.ref@yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18682"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 15 06:17:28 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmUMy-0004gp-Al for ged-emacs-devel@m.gmane-mx.org; Mon, 15 Nov 2021 06:17:28 +0100 Original-Received: from localhost ([::1]:45356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmUMx-0008Ir-5u for ged-emacs-devel@m.gmane-mx.org; Mon, 15 Nov 2021 00:17:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmULh-0007Vj-70 for emacs-devel@gnu.org; Mon, 15 Nov 2021 00:16:09 -0500 Original-Received: from sonic302-20.consmr.mail.ne1.yahoo.com ([66.163.186.146]:34328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmULa-0002d1-CK for emacs-devel@gnu.org; Mon, 15 Nov 2021 00:16:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636953361; bh=udnyJw4J51KeFYUgllvFmNSEg0tfhMX7mkJx97NycVg=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=TOdpaWwt974LinaZxOTqaWQIwNjZaqEUZyrzuP4uw2OpfckhwATsmjcYi7TAykv6zG/z0opHgKwJ3LSu394qNtpdKatmXacovawk2UfKdweunx9Fa8HFQKB2zB56/AWewGoF8uKRcp51a9VzBgHQ14zbnlYKHBRkenHCXZBo5X/KaNaCgNvdixOhoMhq7xruk2bvtj7stwQAOeZqF7uh0gBvUIhj+1PPCo6XkBmZX91zI6xKE7fwCKAKx0aDcNrZE5zlvbKezoBaeJqJQGu3oB88s5Lbfay9dQHVSvz2ljdv1fmmg4L+leYtpC4OBRkhyx0opjlhO4Vzb7dkJOeDDw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636953361; bh=rAVzPXyDS4/5ex187jk3Gwsilbv9CPy0guW4lNTXdVa=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=cV9R99alQVF0Yyh2HogzxzyHh+/V7j3Tu4xTk4pCpZ2qUcfZhQrj3XupEIWKc7fS1GXv/6+glmfaU9vSRLM9NSps29dZkwuN6OBHc2S7+jsdJvwMmWo4c8khSdHPCINAb58V+NmZtKYdfGFfO795qkCBaWaNVDtlpC285Fvs3e3tHbuuv4M0G+X3eu2YKfKa3mTDeobuO84D+A8L5wtPSt9fZveas7cTDayhaZ41wAd6SxeN2qAi0RJ6a6jZ6cU1LSBfD7/SbMciDfZLXS7AYJyRTXZRXaltJPcsIqLFKVFLX8pB63FQaOujBn8GEz8J3A+lzIXL1BX0rDav8JZo8A== X-YMail-OSG: GKFTlJ8VM1kTzJFuvCLYTneuhthHuZWYB9RwGm1kiGKQC7Q_0SJEr9MPfM8_sqF mHmKZXeRV3UxQaaI44vvnXr0evSKsWYRWMxABa6fhVGgAi7eCzk84j9hP9dRFJtLIBW5R99BFBxp vKCRGy7ZPnwksiatlzDpUrrkk6ts1v_ivfFjzSb.rm9rnT98h6dLzcL7J0eehp5PW_ckEEF15Y0g McXqRrx3UDg.XbrK2LrwxuRqAgeil06b1jSVsTJu7HBuxqQrtB7qsCVnDdDLk1JGGrj0Vhv_16ki cQ5X1xPZALik_c.Ah6M5b9qhnlkXpIsPaYJzTkT74LJcxE4caQVevNdg3d4QYm81M9eDkmZ2kBBW pTPnl82NSY7G1wWqAWcP5_rfE6BkEDRtPh2KbqYI46rHqxPZJd5EMwiffPmegO.nFkLnna.w5dTW qNphN1sq18LiR3fzzTZZVStkia9DlIQfqYBqpBTk6l_FSuhUx2Y45luT6ZjQxbymzfh02PBQADl3 4VEkiQ8rRbb8hfQVez2zIk_fI08myyNwuhPsdHG154WG8_4I0iNKMxj3viFW25puKpCIR5b6C0Bv Wolpbo8RwWJC4gVpO17eRUrvd.7ORG_ASnKnWiaiIEnLZcXU11ip33VH0Q88msadnB_e9fR2iNZJ KY5tUiCOyKWMX66RTGXDrEb_yuuXhH5S.4IuqjZplop17D5QeUcMISo600XCGhsftC0izpANzAm_ wF0dbCRLYfG5Rroasu8o5YeIbuK7wrSt1joY5_9HHrn84_3MGST0a9u4AGGfT_TVIMRyGFVhGUyq 5dQ2LpPJf7sUd.GTWBZASTkF.JD8ceTfxwAMvHJuW6 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 15 Nov 2021 05:16:01 +0000 Original-Received: by kubenode501.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID b8a18825c7fc36d12cd8f97f56813881; Mon, 15 Nov 2021 05:15:57 +0000 (UTC) X-Mailer: WebService/1.1.19306 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.186.146; envelope-from=luangruo@yahoo.com; helo=sonic302-20.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:279464 Archived-At: --=-=-= Content-Type: text/plain I added a command that lets you browse the history of the current xwidget, but I'm not sure the documentation for it is detailed enough. Please let me know if this is OK to push, and if not, how I can improve it. Thanks in advance. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-command-to-browse-xwidget-history.patch >From 3e867ae768292ecb855095d49cd2f35ab6c77ce9 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 15 Nov 2021 13:12:45 +0800 Subject: [PATCH] Add command to browse xwidget history * doc/emacs/misc.texi (Embedded WebKit Widgets) * etc/NEWS: Document `xwidget-webkit-browse-history'. * lisp/xwidget.el (xwidget-webkit-mode-map): Bind "H" to xwidget-webkit-browse-history. (xwidget-webkit-import-widget): Set last session buffer correctly. (xwidget-webkit-browse-history): New command. (xwidget-webkit-history--session): New variable. (xwidget-webkit-history--insert-item) (xwidget-webkit-history-select-item) (xwidget-webkit-history-reload): New functions. (xwidget-webkit-history-mode): New major mode. --- doc/emacs/misc.texi | 8 ++++++ etc/NEWS | 6 +++++ lisp/xwidget.el | 64 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 3d423d7675..74542d46eb 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -3011,6 +3011,14 @@ Embedded WebKit Widgets To leave incremental search, you can type @kbd{C-g}. +@findex xwidget-webkit-browse-history +@cindex history of webkit buffers + The command @code{xwidget-webkit-browse-history} displays a buffer +containing a list of pages once loaded by the current WebKit buffer, +and lets you navigate to those pages by hitting @kbd{RET}. + +It is bound to @kbd{H}. + @node Browse-URL @subsection Following URLs @cindex World Wide Web diff --git a/etc/NEWS b/etc/NEWS index 312fc18f4f..cda29650c0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -486,6 +486,12 @@ This mode acts similarly to incremental search, and allows to search the contents of a WebKit widget. In xwidget-webkit mode, it is bound to 'C-s' and 'C-r'. ++++ +*** New command 'xwidget-webkit-browse-history'. +This command displays a buffer containing the page load history of +the current WebKit widget, and allows you to navigate to various +points in history. + --- *** On X11, the WebKit inspector is now available inside xwidgets. To access the inspector, right click on the widget and select "Inspect diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 485d995f41..7e784aa0cf 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -55,6 +55,7 @@ (declare-function delete-xwidget-view "xwidget.c" (xwidget-view)) (declare-function get-buffer-xwidgets "xwidget.c" (buffer)) (declare-function xwidget-query-on-exit-flag "xwidget.c" (xwidget)) +(declare-function xwidget-webkit-back-forward-list "xwidget.c" (xwidget &optional limit)) (defgroup xwidget nil "Displaying native widgets in Emacs buffers." @@ -194,6 +195,7 @@ xwidget-webkit-mode-map (define-key map "e" 'xwidget-webkit-edit-mode) (define-key map "\C-r" 'xwidget-webkit-isearch-mode) (define-key map "\C-s" 'xwidget-webkit-isearch-mode) + (define-key map "H" 'xwidget-webkit-browse-history) ;;similar to image mode bindings (define-key map (kbd "SPC") 'xwidget-webkit-scroll-up) @@ -228,6 +230,7 @@ nil ["Back" xwidget-webkit-back t] ["Forward" xwidget-webkit-forward t] ["Reload" xwidget-webkit-reload t] + ["History" xwidget-webkit-browse-history t] ["Insert String" xwidget-webkit-insert-string :active t :help "Insert a string into the currently active field"] @@ -396,6 +399,9 @@ xwidget-webkit-callback (when (or (string-equal (nth 3 last-input-event) "load-finished") (> (length title) 0)) + (when (get-buffer "*Xwidget WebKit History*") + (with-current-buffer "*Xwidget WebKit History*" + (revert-buffer))) (with-current-buffer (xwidget-buffer xwidget) (setq xwidget-webkit--title title) (force-mode-line-update) @@ -775,6 +781,7 @@ xwidget-webkit-import-widget (callback #'xwidget-webkit-callback) (buffer (get-buffer-create bufname))) (with-current-buffer buffer + (setq xwidget-webkit-last-session-buffer buffer) (save-excursion (erase-buffer) (insert ".") @@ -821,6 +828,15 @@ xwidget-webkit-current-url (let ((url (xwidget-webkit-uri (xwidget-webkit-current-session)))) (message "URL: %s" (kill-new (or url ""))))) +(defun xwidget-webkit-browse-history () + "Display a buffer containing the history of page loads." + (interactive) + (setq xwidget-webkit-last-session-buffer (current-buffer)) + (let ((buffer (get-buffer-create "*Xwidget WebKit History*"))) + (with-current-buffer buffer + (xwidget-webkit-history-mode)) + (display-buffer buffer))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun xwidget-webkit-get-selection (proc) "Get the webkit selection and pass it to PROC." @@ -1059,6 +1075,54 @@ xwidget-webkit-isearch-yank-kill (concat xwidget-webkit-isearch--string (current-kill 0))) (xwidget-webkit-isearch--update)) + +(defvar-local xwidget-webkit-history--session nil + "The xwidget this history buffer controls.") + +(defun xwidget-webkit-history--insert-item (item) + "Insert specified ITEM into the current buffer." + (let ((idx (car item)) + (title (cadr item)) + (uri (caddr item))) + (push (list idx (vector title uri)) + tabulated-list-entries))) + +(defun xwidget-webkit-history-select-item () + "Navigate to this line's history item." + (interactive) + (let ((id (tabulated-list-get-id))) + (xwidget-webkit-goto-history xwidget-webkit-history--session id)) + (xwidget-webkit-history-reload)) + +(defun xwidget-webkit-history-reload (&rest ignored) + "Reload the current history buffer." + (interactive) + (setq tabulated-list-entries nil) + (let* ((back-forward-list + (xwidget-webkit-back-forward-list xwidget-webkit-history--session)) + (back-list (car back-forward-list)) + (here (cadr back-forward-list)) + (forward-list (caddr back-forward-list))) + (mapc #'xwidget-webkit-history--insert-item back-list) + (xwidget-webkit-history--insert-item here) + (mapc #'xwidget-webkit-history--insert-item forward-list)) + (tabulated-list-print t nil)) + +(define-derived-mode xwidget-webkit-history-mode tabulated-list-mode + "Xwidget Webkit History" + "Major mode for browsing the history of an Xwidget Webkit buffer. +Each line describes an entry in history." + (setq truncate-lines t) + (setq buffer-read-only t) + (setq tabulated-list-format [("Title" 50 nil) ("URL" 100 nil)]) + (setq tabulated-list-entries nil) + (setq xwidget-webkit-history--session (xwidget-webkit-current-session)) + (xwidget-webkit-history-reload) + (setq-local revert-buffer-function #'xwidget-webkit-history-reload) + (tabulated-list-init-header)) + +(define-key xwidget-webkit-history-mode-map (kbd "RET") + #'xwidget-webkit-history-select-item) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar xwidget-view-list) ; xwidget.c -- 2.31.1 --=-=-=--