While taking notes, writing blogs and managing knowledge base with org-mode, I need to insert source code blocks quite frequently, so I wrote an Elisp function to help me to do it.
Table of contents:
- An example of org-mode source code block
- Keyboard shortcut
- Synatx Highlighting
An example of org-mode source code block
This is an Elisp source code block (foldable) in org-mode:
In order to reduce the keystrokes, I wrote this Elisp function:
eval it and press
M-x org-insert-src-block, then type in the wanted Emacs major mode for the block, for example, emacs-lisp.
org-src-fontify-natively to enable syntax highlighting in the source code blocks (you may need to revert-buffer to reload the org file).
org2blog makes use of the export engine of org-mode to convert org files into HTML. The source blocks are also syntax highlighted in the generated HTML files.
- Delete the file corresponding to the current buffer
- Alarm for Breaks
- Insert source code block in org-mode
- Edit current file as root
- Getting rid of mouse
My site is free of ads and trackers. Was this post helpful to you? Why not