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: Re: Add command to browse xwidget history Date: Mon, 15 Nov 2021 20:58:35 +0800 Message-ID: <871r3hpock.fsf@yahoo.com> References: <87a6i62e45.fsf.ref@yahoo.com> <87a6i62e45.fsf@yahoo.com> <83zgq5shkh.fsf@gnu.org> 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="11286"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 15 14:01:15 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 1mmbbm-0002ef-6i for ged-emacs-devel@m.gmane-mx.org; Mon, 15 Nov 2021 14:01:14 +0100 Original-Received: from localhost ([::1]:46212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmbbl-00027m-5K for ged-emacs-devel@m.gmane-mx.org; Mon, 15 Nov 2021 08:01:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmbZP-0008Eo-T9 for emacs-devel@gnu.org; Mon, 15 Nov 2021 07:58:47 -0500 Original-Received: from sonic301-31.consmr.mail.ne1.yahoo.com ([66.163.184.200]:39592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmbZN-0005yo-C5 for emacs-devel@gnu.org; Mon, 15 Nov 2021 07:58:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636981124; bh=+B6x7trEwc5ptZOFYMV8tAa1++ZMNcqCfl2AMvIEMh8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=cz1WJ+KyNxkxXjbQ46dZ9SEC6QBQhSiwDPdqo6AvPmgK2Yog1kPHeq9w2WJ3+xDr5Bwb/qgufxemxJQ8mDlsD9p6W2mb4lYx9sSuiwO40Q1X8g0JCHRkDHbhEbxUxB3oqjfLWmgm320EIIcXp5Y5dSgDCc7xEctf7+JSpZ/uJ2EZoAW7WaR0Jdr8Fdbqln36UPIQpL27pLfYZ/WtwHhhURSonT7A9nuFtyoHizS8qqVk7KKeZE5cQYeOXUnC3ble/xvsIIKrvBlVUHcU4KPpMdL4J4CMNjkABcXJupVDfs8x4Enbs1Jm+w0CLmOxxrrft2feSKKWnpxBWnUrPmgIkg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636981124; bh=T+rF8eRn2fL3vxsrfQ6gGRd9lQpyIPDNGcrmlLQhLrn=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ISfHWemLX9SHr/MV9ptZzQoFZ1+PgTMktIpeO8MDAP449ILsN+6NCgv2c2W8Ghl+0GCNVXNhQ5E6TSATfwdP56/6Tgj3XdqV2dagXo7xqX2GfyQLLSDSAFZOEunPoYcfa7mvJKmXPIL+plRtye1rHFyxF3N/mrFSrXSr4Xdy8TB9ipy3nrl3tU5mA0yWZhkHU5YcC26bRykPPqsP6mfB/e1B0i9vL0hTRLRmHKwFcXTfus5aGOCCprVmBvt2m02Fb/JwwdkkHdf8QIYarf+JiMNb+BBlV7adm7iDMWF4xV88FTIREVhYvvf8r74S8Qi8epBruyPMo0AdFpveSteorA== X-YMail-OSG: K4jQVdQVM1lSEUNIEypWZ0x9ram4IoFk1xRU0GM9I29mUcBY7DoOXcGik8sRk87 3jp7nHC63QbMVdoZ9fPMSJvQHmpoUJO0eoVDYVhXYPgQ1qAcAzshC7NLx8aqRUKK5LsWcaWa_KKi KRYsymX6gj7vH4HOVeZRztl8W4KuY1e6cP5q2x.ljzFS5re4wMrI6g0GuHUjd3bP058mcGkKUM.P 9EjdSiDQlBPkcNgIJJTbag3iER_kCeWXGXjWf0ORvGnnWhWzBcA6D0Xj39zWCwSYynQZjjiRfzjP BGTZI0NgArZtatYOmCIOzSmkfNIJa4D9O0S1nCzR0XYkONTwYod0kYcvxBohPN077hVevEzLQI._ om7klDnXoH_MgQj3V2dFaNrPL5YtCb2I5vzv0vGgK0qTe1sx7J6jfw090vLYIHkCSn4QX66NJQ9M Ax6R9buk_2w28xL_UKtwP.nlt5RQpCfAzccEDyb_HFjNxp51FPleLIr7c6RoYS8kNZex7_uzw4Br BFGai8sJON6ve0sPThWOk9iBpNkfkjgN58Iawe3ncPmDRdGsvPFNiWNGiw.F2Jt4G4gc9rliu7xS m6KwqrmDm5UPbymwNaZJi1zWnWYo4JwunjMwTtY.70kPKAUfMAfKiN4_xcjTHyVLTlg53B9pOmXg NYiGoxhaHYcl6j.t.1aCYzyq4rkC8Ajh599lPOj_D4L.pSAnWrPjWjaNvhgOkIfHr5TlwLKTTFBZ WXksLTuBaCXDth9Ke_1aTZTGNJOFlsGJRpaq6yAIcjyg0dFUA40k9M_rB6pBwfLkEPuM_TV7vXj8 ev0xuL5x1HcT.X4SuUMEDLEfbsk2XHLFaLixgOADVm X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Mon, 15 Nov 2021 12:58:44 +0000 Original-Received: by kubenode509.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 03ce974c345ce19cac85366c57cdc67a; Mon, 15 Nov 2021 12:58:38 +0000 (UTC) In-Reply-To: <83zgq5shkh.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 15 Nov 2021 14:56:46 +0200") 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.184.200; envelope-from=luangruo@yahoo.com; helo=sonic301-31.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:279498 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > The documentation LGTM, but it is customary in Emacs to have mouse > support in such list buffers, and also show tooltips when the mouse > hovers over an item. Compare with "M-x proced", for example. Yes, I added that support on my side, but forgot to send a patch. Here it is, thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-command-to-browse-xwidget-history.patch >From b52851272fdbb17a9ed59b0a03dfdf9d3725e97b 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 | 5 +++ lisp/xwidget.el | 77 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 3d423d7675..1f2c852fac 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 previously 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..d52461909f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -486,6 +486,11 @@ 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 it. + --- *** 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..7031769c26 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-let ((buffer (get-buffer "*Xwidget WebKit History*"))) + (with-current-buffer buffer + (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,67 @@ 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.") + +(define-button-type 'xwidget-webkit-history 'action #'xwidget-webkit-history-select-item) + +(defun xwidget-webkit-history--insert-item (item) + "Insert specified ITEM into the current buffer." + (let ((idx (car item)) + (title (cadr item)) + (uri (caddr item))) + (setq tabulated-list-entries + (push (list idx (vector (list (number-to-string idx) + :type 'xwidget-webkit-history) + (list title :type 'xwidget-webkit-history) + (list uri :type 'xwidget-webkit-history))) + tabulated-list-entries)))) + +(defun xwidget-webkit-history-select-item (pos) + "Navigate to the history item underneath POS." + (interactive "P") + (let ((id (tabulated-list-get-id pos))) + (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 (nreverse forward-list)) + (xwidget-webkit-history--insert-item here) + (mapc #'xwidget-webkit-history--insert-item back-list) + (tabulated-list-print t nil) + (goto-char (point-min)) + (let ((position (line-beginning-position (1+ (length back-list))))) + (goto-char position) + (setq-local overlay-arrow-position (make-marker)) + (set-marker overlay-arrow-position position)))) + +(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 [("Index" 10 nil) + ("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 --=-=-=--