Exporting selection instead of whole document

Is it possible to export a selection to latex instead of the whole file?

As a workaround, this is what I am doing (I am reading the content from the clipboard in the python file):

(tm-define (export-current-selection-to-latex)
  (let ((temp (clipboard-get-export)))
    (clipboard-set-export "latex")
    (clipboard-copy "primary")
    (clipboard-set-export temp)
    (system "python ~/clean_latex.py &"))

I do not know of a default way.

This said, your code looks nice (I do not understand the double call to clipboard-set-export, I am judging from the parts that I do understand). I think it would make for a nice article for the TeXmacs blog; TeXmacs is made for extensibility.

I think one would need to explain what the code does line by line and add a shortcut and a menu item, then the article would be ready, and I think @mgubi would like it as well.

“Copy to -> LaTeX” does not work?

1 Like

I understood that he wants the selection onto a file in one step. But maybe you are right, that he would be happy with pasting and saving.

I should have made my question more clear. I meant exporting a selection as latex to a file, so that I can map that to a keybinding.

If I get it correctly, what you want is

(texmacs->generic (selection-tree) "latex-snippet")