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.

## An example of org-mode source code block

This is an Elisp source code block (foldable) in org-mode:

## org-insert-src-block

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.

## Synatx Highlighting

Set variable 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.