phillord / lentic

Create views of the same content in two Emacs buffers
183 stars 12 forks source link

Lentic and Markdown files #38

Open lionel- opened 8 years ago

lionel- commented 8 years ago

Hello,

Is there an easy way to use lentic with Markdown files and, say, R code chunks?

I had a look at lentic-org.el and it is intimidating. It suggests that making lentic compatible with markdown will take some work right?

phillord commented 8 years ago

I am afraid markdown isn't supported at the moment. It doesn't fall into any of the syntax families that I do support and it's not that easy because of the implicit start/end of code chunks.

lentic-org.el is without a doubt the most complex of the transformations that I support (because I do things with ";;; Headers:" comments), so it's not necessarily a good indication of how hard it would be.

I'd love to support markdown, but so far I have only got as far as adding a file to the examples directory!

Phil

Lionel Henry notifications@github.com writes:

Is there an easy way to use lentic with Markdown files and, say, R code chunks?

I had a look at lentic-org.el and it is intimidating. It suggests that making lentic compatible with markdown will take some work right?

lionel- commented 8 years ago

Since org-mode is much more advanced than markdown-mode, I ended up writing a org-R lentic transformation. I use a combination of:

Lots of moving parts but it works. I prefer the markdown syntax but hopefully the org-mode features will be worth it (still learning it). Hopefully this setup will scale better than polymode, which proved a bit unstable with large documents (though that should be fixed once the move from indirect buffers has been made).

phillord commented 8 years ago

Lionel Henry notifications@github.com writes:

Since org-mode is much more advanced than markdown-mode, I ended up writing a org-R lentic transformation.

I'd be interested in seeing that (I'd like to know how hard it was, which is hopefully not very!) and also incorporating into lentic.

I use a combination of:

  • org-mode and lentic to write the document and edit the code
  • a custom ox-ravel to translate the org document to scholdoc markdown
  • knitr to weave the R blocks
  • scholdoc to transform the markdown to pdf

Lots of moving parts but it works. I prefer the markdown syntax but hopefully the org-mode features will be worth it (still learning it).

I've ended up going the same way; org-mode is not a particularly great syntax to my mind, but the Emacs support for editing is very good; it's competitive with auctex now.

Hopefully this setup will scale better than polymode, which proved a bit unstable with large documents (though that should be fixed once the move from indirect buffers has been made).

I use lentic upto 3k loc on my netbook and it is fine. I tend not to write source files bigger than that anyway.

Phil

lionel- commented 8 years ago

I'd be interested in seeing that

It was straightforward.

(require 'lentic)
(require 'lentic-chunk)

(defun lentic-org-r-oset (conf)
  (lentic-m-oset
   conf
   :this-buffer (current-buffer)
   :comment "# "
   :comment-stop "#\\\+BEGIN_SRC R.*"
   :comment-start "#\\\+END_SRC"
   :sync-point t))

;;;###autoload
(defun lentic-org-r-init ()
  (lentic-org-r-oset
   (lentic-unmatched-uncommented-chunk-configuration
    "lb-org-to-r"
    :lentic-file
    (concat (file-name-sans-extension (buffer-file-name)) ".r"))))

;;;###autoload
(defun lentic-r-org-init ()
  (lentic-r-org-oset
   (lentic-unmatched-commented-chunk-configuration
    "lb-org-to-r"
    :lentic-file
    (concat (file-name-sans-extension (buffer-file-name)) ".org"))))

(add-to-list 'lentic-init-functions 'lentic-org-r-init)
(add-to-list 'lentic-init-functions 'lentic-r-org-init)

I use lentic upto 3k loc on my netbook and it is fine.

The experience of using lentic with my current 1k file is very pleasant, barring the undo granularity problem (also I've found a few quirks here and there, but it's not always easy to reduce them to reproducible examples). Thanks for lentic!

phillord commented 8 years ago

Lionel Henry notifications@github.com writes:

I use lentic upto 3k loc on my netbook and it is fine.

The experience of using lentic with my current 1k file is very pleasant, barring the undo granularity problem

Yes, unfortunately that's nasty to fix. I'm about half-way through, but it's a core emacs change (i.e. it cannot be fixed in lentic).

(also I've found a few quirks here and there, but it's not always easy to reduce them to reproducible examples).

Yes, I have some of these also. Reproducible examples are half the problem, to be honest. After that the fix is often not too hard.

Thanks for lentic!

Glad you find it useful.