Forráskód Böngészése

Add `xwwp-browse-url-orther-window`.

The `xwidget-webkit-browse-url` just update the current xwidget-webkit buffer
but does not bring it to the front. This methods will also bring it to the front
using `swith-to-buffer-other-window`.
Damien Merenne 6 éve
szülő
commit
56c4db77f6
2 módosított fájl, 25 hozzáadás és 0 törlés
  1. 7 0
      README.md
  2. 18 0
      xwwp.el

+ 7 - 0
README.md

@@ -18,6 +18,13 @@ with your backend of choice and I'll have a look at what can be done. Or better,
 fork and create a pull request, most of the needed code is already there, it
 just needs to be hooked.
 
+## Browse url in other window
+
+The `xwidget-webkit-browse-url` just update the current xwidget-webkit buffer
+but does not bring it to the front (at least on MacOS), which is what you would
+expect. The `xwwp-browse-url-orther-window` method will also bring it to the
+front using `swith-to-buffer-other-window`.
+
 ### How to install
 
 Sorry, no melpa as of now. Should be added quite soon.

+ 18 - 0
xwwp.el

@@ -143,6 +143,24 @@ and a Lisp function to call it."
          (script (mapconcat #'cdr (cdr namespace) "\n")))
     (xwwp-html-inject-script xwidget (format "--xwwp-%s" (symbol-name ns-name)) script)))
 
+;;;###autoload
+(defun xwwp-browse-url-other-window (url &optional new-session)
+  "Ask xwidget-webkit to browse URL.
+NEW-SESSION specifies whether to create a new xwidget-webkit session.
+Interactively, URL defaults to the string looking like a url around point."
+  (interactive (progn
+                 (require 'browse-url)
+                 (browse-url-interactive-arg "xwidget-webkit URL: "
+                                             ;;(xwidget-webkit-current-url)
+                                             )))
+  (or (featurep 'xwidget-internal)
+      (user-error "Your Emacs was not compiled with xwidgets support"))
+  (when (stringp url)
+    (if new-session
+        (xwidget-webkit-new-session url)
+      (progn (xwidget-webkit-goto-url url)
+             (switch-to-buffer-other-window (xwidget-buffer (xwidget-webkit-current-session)))))))
+
 ;; Local Variables:
 ;; eval: (mmm-mode)
 ;; eval: (mmm-add-group 'elisp-js '((elisp-rawjs :submode js-mode