Merge branch 'master' into xwidget
[emacs.git] / lisp / emacs-parallel / parallel-xwidget.el
blob7e23863d6ebeccc49bd938e1185739407f6d4c51
1 ;;; parallel-xwidget.el ---
3 ;; Copyright (C) 2013 Grégoire Jadi
5 ;; Author: Grégoire Jadi <gregoire.jadi@gmail.com>
7 ;; This program is free software: you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License as
9 ;; published by the Free Software Foundation, either version 3 of
10 ;; the License, or (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ;;; Commentary:
22 ;;; Code:
24 (require 'parallel)
25 (require 'browse-url)
27 (defgroup parallel-xwidget nil
28 "Browse the web in another emacs instance with XWidget."
29 :group 'emacs)
31 (defvar parallel-xwidget--task nil)
33 (defcustom parallel-xwidget-config nil
34 "Parallel configuration."
35 :type 'alist
36 :group 'parallel-xwidget)
38 (defun parallel-xwidget--init ()
39 (setq parallel-xwidget--task
40 (parallel-start (lambda ()
41 (require 'xwidget))
42 :graphical t
43 :continue-when-executed t
44 :config parallel-xwidget-config)))
46 (defun parallel-xwidget-browse-url (url &optional new-session)
47 "Browse URL in another Emacs instance."
48 (interactive (browse-url-interactive-arg "xwidget-webkit URL: "))
49 (unless (and parallel-xwidget--task
50 (eq 'run (parallel-status parallel-xwidget--task)))
51 (parallel-xwidget--init))
52 (parallel-send parallel-xwidget--task
53 (lambda (url new-session)
54 (xwidget-webkit-browse-url url new-session))
55 (url-tidy url) new-session))
57 (provide 'parallel-xwidget)
59 ;;; parallel-xwidget.el ends here