You can add support to highlight fenced code blocks exactly like in Markdown mode, as several comments have already suggested. However, if you're using orgmode already, you have far more powerful and flexible features already built in.
Orgmode comes with markup for code blocks:
* My Org File
** Code blocks
#+begin_src elisp
(defun my-function ()
"This is my special function."
(interactive)
(message "Hello from Emacs"))
#+end_src
By default, the text in the src block has syntax highlighting applied according the code language of the block, in this case it's elisp:
You can modify the way this appears with themes, or by directly modifying the faces (org-block
being one of the basic ones).
Similarly, inline code snippets in org mode are marked up as:
Here's a bit of inline code: ~x = x + 1~
The default colouring for this is:
This just scratches the surface. Org-mode provides a lot of features for working with inline code, and especially code blocks. If you're writing documents with included code snippets, you should consider using the features org mode already provides.
Working with Source Code (org manual)
Markup for inline code (org manual)
M-x describe-face org-block
and customize at will (but I have not tested anything).(defface my-code-face '((t :foreground "black" :background "gray")) "Your code face.")
and then use font-lock-keywords(font-lock-add-keywords 'org-mode '(("```.+```" . 'my-code-face)))
- someone with more regexp experience in emacs would have to help me out for a regexp over multiple lines. You might also be able to do this with org emphasis markers.(defface my-code-face '((t :foreground "aquamarine")) "Your face.")
and(font-lock-add-keywords 'org-mode '(("`+\\(.+?\\)`+" 1 'my-code-face)))
Also check out: emacswiki.org/emacs/AddKeywords