this-month-in-org/2021-05-31-async.txt

292 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2024-01-09 18:20:48 +00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MAY 2021
Asynchronous code execution
TEC
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2021-05-31
Async Babel sessions have landed
════════════════════════════════
Jack Kamm has made a fantastic contribution to Org: `ob-comint.el' now
supports asynchronous output from source blocks /with full support for
sessions/ 🎉.
2024-01-12 05:40:29 +00:00
If you havent used sessions before, youre in for a treat! By simply
2024-01-09 18:20:48 +00:00
assigning a named session to a source code block, e.g. `:session foo',
the same process will be reused for any other code blocks that specify
the `foo' session. To do this for a certain language across the entire
document, you can set the header argument property, i.e.
┌────
│ #+property: header-args:lang :session foo
└────
Along with the asynchronous process communication in `ob-comint.el',
we have an implementation for *Python*, and we should see support for
*R* and *Ruby* in the not-too-distant future 😍.
2024-01-10 17:36:58 +00:00
To use this, just add the `:async' parameter to a python
2024-01-12 05:40:29 +00:00
block. Instead of Emacs freezing until it completes execution, youll
2024-01-10 17:36:58 +00:00
see a placeholder inserted which is replaced by the result when it is
ready.
2024-01-09 18:20:48 +00:00
[emacs-jupyter] allowed for asynchronous code execution (with
2024-01-12 05:40:29 +00:00
sessions), but its great to have a solution that doesnt require
2024-01-09 18:20:48 +00:00
Jupyter kernels, and is part of Org.
[emacs-jupyter] <https://github.com/nnicandro/emacs-jupyter>
Font lock for inline export snippets
════════════════════════════════════
2024-01-12 05:40:29 +00:00
Now, this isnt necessarily a significant change, but I dont think
many people know about this feature so Ill take the opportunity to go
2024-01-09 18:20:48 +00:00
over it 🙂.
If you want to include a snippet of HTML/LaTeX etc. when exporting to
that format, you can use a `#+begin_export html' block which simply
2024-01-12 05:40:29 +00:00
includes the enclosed content verbatim. This doesnt really work for
2024-01-09 18:20:48 +00:00
small inline snippets though — but never fear, Org has /inline/ export
snippets which simply follow the form `@@format:content@@'. For
example:
┌────
│ I love using Org to export to @@html:<abbr title="Hyper Text Markup Language">HTML</abbr>@@ @@latex:\LaTeX{}@@ documents.
└────
which will export to HTML as,
┌────
│ I love using Org to export to <abbr title="Hyper Text Markup Language">HTML</abbr> documents.
└────
and then in LaTeX will be,
┌────
│ I love using Org to export to \LaTeX{} documents.
└────
2024-01-12 05:40:29 +00:00
isnt that neat!
2024-01-09 18:20:48 +00:00
2024-01-12 05:40:29 +00:00
Now youll find the `@@' parts using the comment face and the
`format:' bit using the Org tags face. Its a small change, but it
makes it easier to see whats going on.
2024-01-09 18:20:48 +00:00
No mode-specific syntax highlighting yet, but that may come in the
future 😉.
`#+plot' your `#+results'
═════════════════════════
2024-01-12 05:40:29 +00:00
Org-plot has been getting some more love as of late (see [last months
post]), and that hasnt stopped yet. This month theres been a fairly
minor change that Im quite a fan of. If you have a source block that
2024-01-09 18:20:48 +00:00
produces a table of `#+results', you can now put a `#+plot' statement
immediately above to get a visualisation of those results!
┌────
│ #+begin_src python
│ # pretend this is some profound source of information
│ return [[i, i^3 - 4*i^2 - 2*i] for i in range(5)]
│ #+end_src
│ #+plot: ind:1
│ #+RESULTS:
│ | 0 | 1 |
│ | 1 | -2 |
│ | 2 | 7 |
│ | 3 | 8 |
│ | 4 | 13 |
└────
As usual, this relies on `gnuplot' being present. You can read more
about it in the [manual].
2024-01-12 05:40:29 +00:00
[last months post] <file:2021-04-30-export-plot.org>
2024-01-09 18:20:48 +00:00
[manual] <https://orgmode.org/manual/Org-Plot.html>
Fancier LaTeX verses
════════════════════
With the use of `verse.sty' you can now export fancier verses from
Org, as verse blocks now support four new attributes:
`:lines' for the numbering interval.
`:center' which can be set to `t' and works as long as,
• `:versewidth', the longest line in the verse as a text string is
set.
You can also easily add arbitrary LaTeX code to be included with
`:latexcode'.
┌────
│ #+latex_header: \usepackage{verse}
│ #+latex: \poemtitle{A Dream Within a Dream}
│ #+attr_latex: :lines 3 :center t
│ #+attr_latex: :versewidth Through my fingers to the deep,
│ #+begin_verse
│ Take this kiss upon the brow!
│ And, in parting from you now,
│ Thus much let me avow —
│ You are not wrong, who deem
│ That my days have been a dream;
│ Yet if hope has flown away
│ In a night, or in a day,
│ In a vision, or in none,
│ Is it therefore the less /gone?/
│ /All/ that we see or seem
│ Is but a dream within a dream.
│ I stand amid the roar
│ Of a surf-tormented shore,
│ And I hold within my hand
│ Grains of the golden sand —
│ How few! yet how they creep
│ Through my fingers to the deep,
│ While I weep — while I weep!
│ O God! Can I not grasp
│ Them with a tighter clasp?
│ O God! can I not save
│ /One/ from the pitiless wave?
│ Is /all/ that we see or seem
│ But a dream within a dream?
│ #+end_verse
└────
<file:figures/org-verses-example-poem-dream-within-dream.png>
Easy zero-width spaces with Org
═══════════════════════════════
Occasionally you may run into annoyances when you wish to have two
different Org elements right next to each other (no space) — for
2024-01-12 05:08:14 +00:00
example, *emph*asising part of a word or putting a currency symbol
2024-01-09 18:20:48 +00:00
immediately before an inline source block.
2024-01-12 05:40:29 +00:00
The best solution to this in Org is zero-width spaces. As such, Ive
2024-01-09 18:20:48 +00:00
found it rather nice adding insertion of a zero-width space to the
`org-mode-map' in my config. Perhaps some of you might find this
solution useful too 🙂.
┌────
│ (define-key org-mode-map (kbd "M-SPC M-SPC")
│ (lambda () (interactive) (insert "\u200b")))
└────
2024-01-12 05:40:29 +00:00
Should you want to keep zero-width spaces out of exports, thats easy
2024-01-09 18:20:48 +00:00
enough to accomplish with an [export filter].
┌────
│ (defun +org-export-remove-zero-width-space (text _backend _info)
│ "Remove zero width spaces from TEXT."
│ (unless (org-export-derived-backend-p 'org)
│ (replace-regexp-in-string "\u200b" "" text)))
│ (add-to-list 'org-export-filter-final-output-functions #'+org-export-remove-zero-width-space t)
└────
[export filter]
<https://orgmode.org/manual/Advanced-Export-Configuration.html>
2024-01-12 05:40:29 +00:00
Orgs repos have moved
2024-01-09 18:20:48 +00:00
══════════════════════
`contrib/' is now at <https://git.sr.ht/~bzg/org-contrib> for Org
9.5, and it will be available on Non-GNU ELPA.
Worg is now at <https://git.sr.ht/~bzg/worg>
Org itself is moving to Savannah
Other improvements
══════════════════
Add support for `HHhMM' date formats (e.g. `13h20') _Gustavo Barros_
Make tangling faster /and/ more robust _Sébastien Miquel_
2024-01-12 05:40:29 +00:00
Allow importing tables from files that /dont/ end in `.txt',
2024-01-09 18:20:48 +00:00
`.tsv', or `.csv' _Utkarsh Singh_
Add an SVG-specific post-export `ob-plantuml' step:
`org-babel-plantuml-svg-text-to-path' for running Inkscape
text-to-path replacement _Nick Daly_
Refactor JavaScript in `ox-html' _Anthony Carrico_
Set `org-html-head-include-scripts' to `nil' by default (was `t')
_Bastien Guerry_
Remove LaTeX-environment type `#+results' _TEC_
New capture templates parameter, `:refile-targets' _Richard Garner_
Merge `org-speed-commands-default' and `org-speed-commands-user'
into a new variable, `org-speed-commands' _Bastien Guerry_
URL recognition regex now handles up to two levels of nested
brackets, and is tested _Ihor Radchenko_
2024-01-10 17:36:58 +00:00
Cache parent heading positions for faster movement up
buffers. Significantly improves Org queries involving inheritance
(~15-50x improvement) _Ihor Radchenko_
2024-01-09 18:20:48 +00:00
New command `org-refile-reverse' bound to `C-c C-M-w' _Adam Spiers_
Allow inline tasks to be dragged up/down _Bastien Guerry_
LaTeX export, allow arbitrary `:float' values _Thomas S. Dye_
Org attach git, new option `org-attach-git-dir' to use the
attachment dir as a git repository _Juan Manuel Macías_
Use a write-back buffer in Org src _Sébastien Miquel_
Add the `:environment' and `:options' LaTeX attributes to Quote
blocks _Juan Manuel Macias_
Surround LaTeX `:options' attribute with curly braces when it
contains square braces _Markus Huber_
Recognise the specific contributions of Kyle Meyer, Ihor Radchenko,
and TEC in the manual _Bastien Guerry_
Improve test coverage _Ihor Radchenko, Kévin Le Gouguec_
A bikeshed of new maintainers
• New maintainer for `ox-html' — TEC
• New `ob-ledger' maintainer — Eric S Fraga
• New `ob-awk' maintainer — Tyler Smith
• New `ob-calc' maintainer — Tom Gillespie
• New `ob-asymptote' and `ob-coq' maintainer — Luc Pellissier
General code cleanup _Bastien Guerry_
Documentation improvements _Bastien Guerry, Eric S Fraga, Samim
Pezeshki, Nicolar Goaziou_
Bugfixes
════════
Make `ob-gnuplot' work on remote systems _Ihor Radchenko_
Stop `M-x org-toggle-link-display' from affecting emphasis markers
_Bastien Guerry_
Inserting a heading before a headline _Bastien Guerry_
Perform `org-entry-put' in a read-only buffer _Ihor Radchenko_
Emacs 24 compatibility for `ob-C' and `org-agenda-show-new-time'
_Kyle Meyer_
2024-01-12 05:40:29 +00:00
Maintain Orgs keybindings when `visual-line-mode' active _Bastien
2024-01-09 18:20:48 +00:00
Guerry_
Keep track of start of region beginning in `org-table-wrap-region'
_Bastien Guerry_
Ensure correct visibility when unfolding subtree _Bastien Guerry_
Corner case in `org--backwards-paragaph-once' _Bastien Guerry_
Some byte compiler silencing _Kyle Meyer_
Make tags filtering case-sensitive _Bastien Guerry_
`C-c C-c' on a `#+plot' line can no longer cause an error _Bastien
Guerry_
Ensure consistent position-translation in `org-src' by using point
for position instead of column _TEC_
Prevent `ob-sql' from getting stuck on an error _Ivan Sokolov_
Make `org-columns' respect `global-visual-line-mode', and simplify
tag scanning _Nick Savage_
2024-01-12 05:40:29 +00:00
Dont fontify `::' in headlines as description item _Ihor Radchenko_
2024-01-09 18:20:48 +00:00
Handle a few corner-cases in `ob-R' _Jeremie Juste_
Many fixes to `org-indent-line' _Bastien Guerry_
Make headline numbering consistent with TOC _Mingkai Dong_
Allow read-only tangling again, and ensure the correct filename is
used _Sébastien Miquel_
Fix edge case when converting durations to minutes _Nicolas Goaziou_
Make org-refile work in non-file-visiting buffers _Bastien Guerry_
Be more rigorous in `org-sort-remove-invisible' _Nicolas Goaziou_
2024-01-12 05:40:29 +00:00
Dont update checkbox stats when heading has `todo' `COOKIE_DATA'
2024-01-09 18:20:48 +00:00
_Bastien Guerry_
2024-01-12 05:40:29 +00:00
Dont recognise a lone `:END:' to be forming a drawer _Nicolas
2024-01-09 18:20:48 +00:00
Goaziou_
Allow new footnotes in empty table cells _Nicolas Goaziou_