Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions poly-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(define-obsolete-variable-alias 'pm-host/org 'poly-org-hostmode "v0.2")
(define-obsolete-variable-alias 'pm-inner/org 'poly-org-innermode "v0.2")

(defun poly-org-mode-matcher ()
(defun poly-org-mode-src-matcher ()
(when (re-search-forward "#\\+begin_src +\\([^ \t\n]+\\)" (point-at-eol) t)
(let ((lang (match-string-no-properties 1)))
(or (cdr (assoc lang org-src-lang-modes))
Expand All @@ -66,22 +66,30 @@ Used in :switch-buffer-functions slot."
:protect-syntax nil
:protect-font-lock nil)

(define-auto-innermode poly-org-innermode
(define-innermode poly-org-root-innermode
:mode nil
:fallback-mode 'host
:head-mode 'host
:tail-mode 'host
:tail-mode 'host)

(define-auto-innermode poly-org-src-innermode poly-org-root-innermode
:head-matcher "^[ \t]*#\\+begin_src .*\n"
:tail-matcher "^[ \t]*#\\+end_src"
:mode-matcher #'poly-org-mode-matcher
:mode-matcher #'poly-org-mode-src-matcher
:head-adjust-face nil
:switch-buffer-functions '(poly-org-convey-src-block-params-to-inner-modes)
:body-indent-offset 'org-edit-src-content-indentation
:indent-offset 'org-edit-src-content-indentation)

(define-innermode poly-org-latex-innermode poly-org-root-innermode
:mode 'latex-mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually no longer sure about this change. It looks like there is little support from org for latex chunks so most of configuration options cannot be reused. Also, shouldn't head be of body type here?

Copy link
Author

@jethrokuan jethrokuan Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same fashion as src chunks, latex chunks are typically edited by entering the indirect buffer environment with C-c ', so I thought equivalent treatment would make sense.

most of configuration options cannot be reused

what kind of configuration options?

Also, shouldn't head be of body type here?

honestly not sure what each of them entail, but this had worked for me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I thought equivalent treatment would make sense.

I see. Ok. If latex is a first class environment in org then yes.

most of configuration options cannot be reused
what kind of configuration options?

Object's slots like head-mode, regexp etc. So it doesn't make much sense to inherit the latex from org src.

I will play with this as soon as I can. I am having limited computer access these weeks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it doesn't make much sense to inherit the latex from org src.

I don't think I had made it inherit from the org-src ones.

I will play with this as soon as I can. I am having limited computer access these weeks.

np, take your time.

:head-matcher "^[ \t]*\\\\begin{.*}\n"
:tail-matcher "^[ \t]*\\\\end{.*}\n")

;;;###autoload (autoload 'poly-org-mode "poly-org")
(define-polymode poly-org-mode
:hostmode 'poly-org-hostmode
:innermodes '(poly-org-innermode)
:innermodes '(poly-org-src-innermode poly-org-latex-innermode)
(setq-local org-src-fontify-natively nil)
(make-local-variable 'polymode-move-these-minor-modes-from-old-buffer)
(push 'org-indent-mode polymode-move-these-minor-modes-from-old-buffer))
Expand Down