2015-12-02 14:23:39 +00:00
#+TITLE : Chrome layer
2015-06-10 16:44:30 +00:00
[[file:img/chrome.png ]]
2016-03-31 02:59:55 +00:00
* Table of Contents :TOC_4_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2017-08-28 21:58:10 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#layer ][Layer ]]
- [[#chrome-extension ][Chrome extension ]]
- [[#configuration ][Configuration ]]
- [[#key-bindings ][Key bindings ]]
2015-06-10 16:44:30 +00:00
* Description
This layer provides some integration with the Google Chrome browser.
2017-08-28 21:58:10 +00:00
** Features:
2017-04-25 15:42:58 +00:00
- Edit text boxes with Emacs using [[https://github.com/stsquad/emacs_chrome ][edit-server ]]
2017-01-13 16:51:35 +00:00
- Write markdown in Emacs and realtime show in chrome using [[https://github.com/mola-T/flymd ][flymd ]]
2015-08-12 20:50:25 +00:00
- gmail message mode uses standard markdown keybindings
2017-01-13 16:51:35 +00:00
2015-06-10 16:44:30 +00:00
* Install
** Layer
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =chrome= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-06-10 16:44:30 +00:00
** Chrome extension
2017-04-25 15:42:58 +00:00
[[https://github.com/stsquad/emacs_chrome ][edit-server ]] is a server that responds to edit requests sent Chrome via the
2015-06-10 16:44:30 +00:00
Google Chrome extension [[https://chrome.google.com/webstore/detail/edit-with-emacs/ljobjlafonikaiipfkggjbhkghgicgoh ][Edit with Emacs ]]. You have to install this extension.
More information can be found on [[http://www.emacswiki.org/emacs/Edit_with_Emacs ][Emacs Wiki ]].
2017-02-01 14:00:43 +00:00
2015-06-10 16:44:30 +00:00
The edit server is configured to start automatically when Spacemacs starts.
* Configuration
Use =edit-server-url-major-mode-alist= to choose a major mode initialization
function based on =edit-server-url= , or fall back to
=edit-server-default-major-mode= that has a current value of =markdown-mode= .
#+BEGIN_SRC emacs-lisp
2015-09-28 06:05:18 +00:00
(defun dotspacemacs/user-config ()
2015-06-10 16:44:30 +00:00
;; Open github text areas as org buffers
;; currently they are opened as markdown
(setq edit-server-url-major-mode-alist
2015-06-10 21:16:01 +00:00
'(("github\\.com" . org-mode))))
2015-06-10 16:44:30 +00:00
#+END_SRC
2015-08-03 23:16:29 +00:00
To change frame defaults (width, height, etc. use =edit-server-new-frame-alist= )
#+BEGIN_SRC emacs-lisp
(add-to-list 'edit-server-new-frame-alist '(width . 140))
(add-to-list 'edit-server-new-frame-alist '(height . 60))
#+END_SRC
2017-02-01 14:00:43 +00:00
If you want Emacs to switch focus to Chrome after done editing, you can utilize
=edit-server-done-hook= .
Emacs cannot control focus of windows for external apps, so you need to use some
sort of command line window manager like =wmctrl= .
2016-04-13 03:31:38 +00:00
The following example works on OS X:
2015-08-03 23:16:29 +00:00
#+BEGIN_SRC emacs-lisp
2016-04-13 03:31:38 +00:00
(add-hook 'edit-server-done-hook (lambda () (shell-command "open -a \"Google Chrome\"")))
2015-08-03 23:16:29 +00:00
#+END_SRC
2017-01-13 16:51:35 +00:00
* Key bindings
| Key Binding | Description |
2017-02-01 14:00:43 +00:00
|-------------+-------------|
2017-01-13 16:51:35 +00:00
| ~SPC a F~ | flymd-flyit |
2017-02-01 14:00:43 +00:00
*Note:* You need to kill all google chrome process before using =flymd-flyit= .