xwidget-plus.el 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ;;; xwidget-plus.el --- Improve xwidget usability
  2. ;; Author: Damien Merenne
  3. ;; URL: https://github.com/canatella/xwidget-plus
  4. ;; Created: 2020-03-11
  5. ;; Keywords: convenience
  6. ;; Version: 0.1
  7. ;; Package-Requires: ((emacs "25.3"))
  8. ;; This file is NOT part of GNU Emacs.
  9. ;;; Commentary:
  10. ;; This package augment the xwidget-webkit browser to make it more usable.
  11. ;;; License:
  12. ;; This program is free software; you can redistribute it and/or modify
  13. ;; it under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation; either version 3, or (at your option)
  15. ;; any later version.
  16. ;;
  17. ;; This program is distributed in the hope that it will be useful,
  18. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;; GNU General Public License for more details.
  21. ;;
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  24. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  25. ;; Boston, MA 02110-1301, USA.
  26. ;;; Code:
  27. ;;; User customizable variable
  28. ;;
  29. ;;; Code:
  30. (require 'xwidget-plus-common)
  31. (require 'xwidget-plus-follow-link)
  32. ;; Bring the window to front when summoning browse
  33. ;;;###autoload
  34. (defun xwidget-plus-browse-url (url &optional new-session)
  35. "Ask xwidget-webkit to browse URL.
  36. NEW-SESSION specifies whether to create a new xwidget-webkit session.
  37. Interactively, URL defaults to the string looking like a url around point."
  38. (interactive (progn
  39. (require 'browse-url)
  40. (browse-url-interactive-arg "xwidget-webkit URL: "
  41. ;;(xwidget-webkit-current-url)
  42. )))
  43. (or (featurep 'xwidget-internal)
  44. (user-error "Your Emacs was not compiled with xwidgets support"))
  45. (when (stringp url)
  46. (if new-session
  47. (xwidget-webkit-new-session url)
  48. (progn (xwidget-webkit-goto-url url)
  49. (switch-to-buffer-other-window (xwidget-buffer (xwidget-webkit-current-session)))))))
  50. ;; Local Variables:
  51. ;; eval: (mmm-mode)
  52. ;; eval: (mmm-add-classes '((elisp-js :submode js-mode :face mmm-code-submode-face :delimiter-mode nil :front "--js \"" :back "\" js--")))
  53. ;; mmm-classes: elisp-js
  54. ;; End:
  55. (provide 'xwidget-plus)
  56. ;;; xwidget-plus.el ends here