I set org-mode Babel to open rhtml block with web-mode.
(add-to-list 'org-src-lang-modes '("rhtml" . web))
And I have configure company-robe for completing for Rails code in erb
engine.
(defadvice company-robe (before web-mode-set-up-ac-sources activate)
"Set `robe-mode' based on current language before running `company-robe'."
(if (equal major-mode 'web-mode)
(let ((web-mode-cur-language (web-mode-language-at-pos)))
(if (string= web-mode-cur-language "erb")
(unless robe-mode (robe-mode))
(if robe-mode (robe-mode -1))
))))
The upper advice work correctly in normal file index.html.erb
file.
But web-mode can't recognize engine correctly in Org-mode babel block.
When I run (web-mode-language-at-pos)
, it shows html
.
The author of web-mode suggest me to use web-mode-set-engine
.
(web-mode-set-engine "erb")
Here the original question I asked in web-mode issues: https://github.com/fxbois/web-mode/issues/678
My problem is the org edited src buffer's major-mode is web-mode
, but I want to set web-mode-engine
to erb
. The only identity in src block is this:
#+BEGIN_SRC rhtml
#+END_SRC
I checked out Org-mode source code, found some functions relative with this.
org-src-construct-edit-buffer-name (org-buffer-name lang)
org-babel-expand-src-block
org-babel-get-src-block-info
(it should return a list: (language body header-arguments-alist switches name indent block-head) )
I tried to run (nth 0 (org-babel-get-src-block-info))
in opened src buffer which is opened by [C-c ']
.
But only get nil
.
org-babel-get-src-block-info
will return information when run in the org buffer with point within the src block. The commandorg-babel-view-src-block-info
also is useful.