python-cell.el
python-cell.el copied to clipboard
Feature suggestion: Add support for rich comments
This pull request adds code that recognizes blocks starting with if False:
as code cells. This is an attempt at having something similar to rich comments commonly used in Clojure. I currently use this code in my Emacs setup and find it very convenient. But you do not have to accept this PR to your repo, it is just a suggestion in case others could also find use for this code.
The idea is that if False:
prevents the code inside from being evaluated, similar to the (comment ...)
macro in Clojure. In Clojure, it is common to add such comments wrapping code at the end of modules for examples and experiments and editors can be configured to execute the code in those comments when the cursor is placed in the comment. With the code in this pull request, if False
-blocks are recognized as cells and the code wrapped inside those blocks is evaluated when we send the cell to the REPL. But the code is not executed if the module is run normally, e.g. by importing it from another module.
Hi! Thx a lot for your contribution!
if False-blocks are recognized as cells and the code wrapped inside those blocks is evaluated when we send the cell to the REPL
Very nice! I'll test this change in the coming days and will then probably merge it. Thx!
Thanks @thisch for python-cell.el
, I have been using it for years. Feel free to make any changes you like to the code. Or you can ask me to change it, whatever you prefer.