If you’re an Emacs user, you are likely already an org-mode user, org-mode is where it’s at; but … if you’re new to Emacs or Emacs org-mode, read on dear reader, read on.

Org-mode provides an incredible amount of functionality, from turning documents into websites, downloading images from the net, to clocking your time.

A Few Things You Can Do With Org-mode

  • Organize any code into foldable sections that can be output into other files
  • Simplify Latex
  • Use org-tables with excelish functionality directly in emacs
  • Use open ai in emacs
  • Write HTML emails (with mu4e)
  • Export buffer contents to HTML and print to pdf in the browser
  • Create a custom calender with notes and reminders
  • Access org notes from your phone
  • Use timestamps in org-notes to remind you on your phone
  • Query your notes like a database
  • Edit Google docs with CSS
  • Create slides
  • Manage contacts
  • Manage multiple code files from within the same document
  • Track your time
  • And much more …

Here’s a screen shot of the many sections of org related code in the ‘poseidon’ editor configuration.

An image of the headings for the org-mode section of the Emacs Poseidon text editor.

What follows is the code from the org-mode primary section.

Much of the rest of the code is cool, but also task specific. For example, in org-mode you can write documents with a css-like styling that outputs to odt format, which itself inputs to Google Docs.

That’s super cool, it means you can style your Google Docs with CSSish styling.

You can always contact and request more information if you’re keen. Time is short, however.

Open Use Package

(use-package org


:commands (org-mode Org-Agenda/body Org-Editor/body Org-Central/body org-agenda Org-Table/body org-capture-goto-target  mu4e launch-mu4e mu4e-compose-new mu4e-compose-reply Mu4e-mail/mu4e Mu4e-mail/launch-mu4e Mu4e-mail/mu4e-compose-new Mu4e-mail/mu4e-compose-reply)

Commands that prompt the use-package code in this article to load, if it hasn’t already loaded.


(require 'org-faces)

Init loads code when it encounters it (no need to wait for commands). The themes configuration require org-faces is loaded (themes load after the init.)


:mode ("\\.org\\'" . org-mode)

Any file with .org extension both loads this code and starts in org-mode when opened.

Open Config


Configuration section loads custom code when use-package code loads (after a command).

Default Notes

(setq org-default-notes-file org-notes-p)
(setq org-export-html-postamble nil)

org-notes-p is a path to a file that stores some notes. No preamble shortens up the export process.

Set Leading Stars And Superscripts

(setq org-hide-leading-stars t)
(setq org-use-sub-superscripts '{})

Hiding leading stars is muay importante. Subscripts are useful in some cases.

Org Show Levels Functions

(defun org-show-two-levels ()
  (org-content 2))

(defun org-show-three-levels ()
  (org-content 3))

Showing document fold levels. Goes well in a hydra.

Org Add Pretty Symbols And Ellipsis

(defun org-add-pretty-symbols ()
  "make some word or string show as pretty Unicode symbols"
  (setq prettify-symbols-alist
          ("lambda" . 955) ;
          ("->" . 8594)    ;
          ("=>" . 8658)    ;

(setq org-ellipsis "...")

The ellipsis at the end of each folded header can be stylized, if you wish.

Fontify Heading Line

(setq org-fontify-whole-heading-line t)

More housekeeping.

Org Bullets

(use-package org-bullets
:after org
);end org-bullets

Cool package to customize bullets. There is more you can explore. Remember you can call use-package declarations from within :config sections and on their own.

(defun org-toggle-link-display ()
  "Toggle the literal or descriptive display of links."
  (if org-descriptive-links
      (progn (org-remove-from-invisibility-spec '(org-link))
         (setq org-descriptive-links nil))
    (progn (add-to-invisibility-spec '(org-link))
       (setq org-descriptive-links t))))

Org renders links embedded in org documents with syntax highlighting, you can toggle to see the code with this function.

Function Set Default Company Backends

(defun poseidon-org-mode-hook ()
"company hook for org-mode"
(set (make-local-variable 'company-backends)
         '((company-yasnippet company-ispell company-dabbrev))))

A hook to set the default company backends when in org-mode.

Org Mode Hook

(add-hook 'org-mode-hook (lambda ()
(electric-indent-local-mode -1)
;(global-prettify-symbols-mode 1)
(eldoc-mode -1)
(org-bullets-mode 1)

Turn of auto-indenting, toggle on prettify symbols, toggle off eldoc (buffer functionality reminders), set the previous hook, and toggle the bullets on.

Start Non-indented, Folded, With Images off

(setq org-startup-indented nil)           ;; Indent according to section
(setq org-startup-with-inline-images nil) ;; Display images in-buffer by default
(setq org-startup-folded t) ;; open org files folded
(setq org-indent-mode nil)

Take care of those indentations, the initial folding state, and do not show images by default (much cleaner).

Org Tempo

(require 'org-tempo)

Used in one of Poseidon’s other packages. You can explore it further.

Insert Four Spaces C-i

(defun insert-four()
(insert (make-string 4 ?\s))
);end insert four spaces

All the notable arguments in the world from Silicon Valley’s Richard Hendricks, played by Thomas Middleditch, couldn’t get me to use tabs instead of spaces. In this case, it’s a matter of consistency.

Pulse (flash light) M-e, M-a, C-}, C-{

(defun jib/pulse-area (&rest _)
"Pulse +-5 chars of point."
(pulse-momentary-highlight-region (- (point) 5) (+ 5 (point))))

(defun pulse-area (&rest _)
"Pulse +-5 chars of point."
(pulse-momentary-highlight-region (- (point) 5) (+ 5 (point))))

(dolist (command '(org-forward-sentence org-backward-sentence))
(advice-add command :after #'jib/pulse-area));doesn't work with pulse-area

Poseidon pulses flashes when you jump from word or expression to word or expression with above controls.

Org Clock Sound

(setq org-clock-sound org-clock-p)

org-clock-p is the path to the sound the timer makes when it expires.

Org Emphasis /h2>

(require 'org-habit nil t)

(defun org-add-my-extra-fonts ()
  "Add alert and overdue fonts."
  (add-to-list 'org-font-lock-extra-keywords '("\\(!\\)\\([^\n\r\t]+\\)\\(!\\)" (1 '(face org-habit-alert-face invisible t)) (2 'org-habit-alert-face t) (3 '(face org-habit-alert-face invisible t))) t)
  (add-to-list 'org-font-lock-extra-keywords '("\\(%\\)\\([^\n\r\t]+\\)\\(%\\)" (1 '(face org-habit-overdue-face invisible t)) (2 'org-habit-overdue-face t) (3 '(face org-habit-overdue-face invisible t))) t)
(setq extraFonts 0)
(defun toggleExtraFont ()
((equal extraFonts 0) 
(add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-fonts)
(setq extraFonts 1)
((equal extraFonts 1) 
(remove-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-fonts)
(setq extraFonts 0)
));end toggleExtraFont

More faces configuration.

Package show emphasis markers

(use-package org-appear
:ensure t
:hook (org-mode . org-appear-mode)

Works with the code above it.

Org Babel Do Languages

;org-babel languages support
 '((R . t)
   (ditaa . t)
;   (dot . t)
   (emacs-lisp . t)
   (gnuplot . t)
;   (haskell . nil)
   (latex . t)
   (ledger . t)          
;   (ocaml . nil)
;   (html . t)
;   (javascript . t) ;load ob-javascript
   (js . t)
   (python . t)
   (php . t)
   (css . t)
   ;   (screen . nil)
   (shell . t)
;   (sh . t) ; get ob-sh
   (sql . nil)
;   (sqlite . t)
));end org-babel-do-load-languages
(setq org-babel-R-command org-babel-R-command-p)

(setq org-confirm-babel-evaluate nil)

Processing code from org-src blocks. I think it also gives you syntax support inside the code blocks (and in some cases mode support).

Org Babel Tangle Block

(defun org-babel-tangle-block()
  (let ((current-prefix-arg '(4)))
     (call-interactively 'org-babel-tangle)

Tangle the org-src block. Set the tangle path to a file for output. Doesn’t get much simpler or convenient than that.

Org Babel Tangle Files Same as Block

(defun org-babel-tangle-files-same-as-block()
  (let ((current-prefix-arg '(16)))
     (call-interactively 'org-babel-tangle)

Even better, tangle all src blocks (source code blocks) with the same path into one file, in order. This is one of the primary functions in my coding experience. It allows you to organize complex code into categorized sections and output them from one file.

I call these file generators, and I used them everywhere building this!

  • HTML
  • CSS
  • SCSS
  • JavaScript
  • Hugo
  • Emacs
  • Notes
  • Invoices
  • Contracts
  • Scripts
  • Text
  • Books
  • And anything else

Everything gets a generator file!

Add Modes Inside Src Blocks

(add-to-list 'org-src-lang-modes '(
("html" . web)
("scss" . scss)
("js" . js)

Puts emacs into a mode when you are in a source file. Which gives you snippets, and any mode key-maps and functions. Add shell mode, c++, python, whatever.

CSS Set Default HTML Export Styling

(setq roboto-Gray-HTML "
<meta http-equiv='X-UA-Compatible'content='IE=edge,chrome=1'>
<meta content='width=device-width,initial-scale=1, maximum-scale=1, user-scalable=no'name='viewport'>
font-family:'San Francisco','Roboto','Arial',sans-serif
font-family:'Trebuchet MS',Verdana,sans-serif;
margin:20px 0 10px 0;
margin:30px 0 10px 0;
margin:20px 0;
margin:2% auto 6% auto;
border-right:1px solid #e2e9f0;
border-bottom:2px solid #e2e9f0;
padding:0 115px 150px 115px;
margin:0 -115px;
padding:60px 0;
@media (max-width:1050px){
padding:0 70px 100px 70px;}
h1.title{margin:0 -70px;}
@media (max-width:800px){
padding:0 4% 60px 4%}
margin:0 -5%;
padding:40px 5%}}
border:1px solid #e2e9f0;
overflow:auto;margin:6px 0}
#table-of-contents h2{
#text-table-of-contents ul{
#text-table-of-contents li{list-style-type:none}
#text-table-of-contents a{color:#7c8ca1;font-size:0.95em;text-decoration:none}
table thead{color:#586b82}
table tbody tr:nth-child(even){background:#f9f9f9}
table tbody tr:hover{background:#586b82!important;color:white}
table .left{text-align:left}
table .right{text-align:right}
#text-table-of-contents .tag>span{float:none;margin-left:0}
@media print{@page{margin-bottom:3cm;margin-top:3cm;margin-left:2cm;margin-right:2cm;font-size:10px}

Names a variable and sets it to styling for org-mode export to HTML. Workflow: write a letter, report, note, invoice, etc … and export to HTML. Customize styling above. Print from browser to pdf and send. I usually paste custom configurations into the top of each document from snippets and rarely use the default. Also, Latex and OTF to Google Docs use their own styling.

Initialize the Code Above

(setq org-html-head roboto-Gray-HTML)

What it says.


(require 'ox-html)
(require 'ox-twbs)

Enables additional export options from Org export.

Additional Export Configuration

(setq org-export-allow-bind-keywords t)

Export With Smart Quotes

(setq org-export-with-smart-quotes t)

Converts hyphens to dashes and straight quotes to curly quotes on export.

Include Default HTML Styling on Export

(setf org-html-head-include-default-style nil)

You can set this to include the default org HTML export styling written above. Since I usually use snippets for each document, I disconnected the styling. You can also write a toggle relatively easily.

Include Scripts in HTML Export

(setq org-html-head-include-scripts nil)

What it says.

Set HTML export Doctype

(setf org-html-doctype "html5")

What it says.

Auto Configuration of Tables on Export

(setq org-html-table-default-attributes
      '(:border "0" :cellspacing "0" :cellpadding "6" :rules "none" :frame "none"))

What it says.

Add a Viewport Meta Tag to Export

(setf my-head-extra
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, interactive-widget=resizes-visual\">\n"

Doesn’t matter if you are printing from browser, but if you want to make a web page, you could add anything here. Open graph meta tags, favicons, preloading, scripts, etc…

Set Some Syntax Highlighting for Org-src Blocks

(setq org-src-fontify-natively t)

Nice, syntax highlighting!

Ensure Tab Buttons Works Normally in Src Blocks

(setq org-src-tab-acts-natively t)

Org mode src blocks often indent all of their contents when you press tab inside the block. Don’t let that happen!

Don’t Change Indentation in Org-src Blocks

(setq org-src-preserve-indentation t)

More of the same. Control those pesky indents.

Set an Archive Directory

(setq org-archive-location org-archive-p)

org-archive-p is a path to a file. You can archive sections of any org-document. You should do that if you have the time to organize your millions of searchable org documents full of everything you’ve ever learned.

When Use Org-refile, Add New File

(setq org-refile-use-outline-path 'file)

Refile is not archive. It says ‘hey, create a new document and put this in it.’

Refile Target to Level 1

(setq org-refile-targets '((org-agenda-files :level . 1)))

Also, tag on a level one heading.

Set Info Saved When Archive

(setq org-archive-save-context-info '(time file olpath category todo itags ltags itags))

What it snays.

Archive Every Section Marked ‘DONE’ From Agenda Files Directory

(defun org-archive-done-tasks ()
   (lambda ()
     (setq org-map-continue-from (org-element-property :begin (org-element-at-point))))
   "/DONE" 'file))

Careful! I use the DONE keyword often in headings, because of the distinguishable coloring, which let’s me know which code blocks I’m using in a generator and which ones I’m not. You may want to swap them back and forth during development, so don’t archive done sections.

Archive Any Timestamps Passed

(defun org-archive-passed-timestamps ()
   (lambda ()
     (org-archive-subtree 16)
     (setq org-map-continue-from (org-element-property :begin (org-element-at-point))))
   "/DONE" 'file))

You will have a lot of timestamps. Remove some?

Require the Clock And Set to Persisteant

(require 'org-clock)
(setq org-clock-persist 'history)

While I don’t use the clock that often, I do use it occasionally!

Set Export Timestamp Format

(setq org-export-date-timestamp-format "%d %b  %Y ")

Day, Month, Year. You can change it up.

Remove Key Bindings From Org-mode

(define-key org-mode-map (kbd "M-S-<right>") nil)
(define-key org-mode-map (kbd "M-S-<down>") nil)
(define-key org-mode-map (kbd "M-S-<left>") nil)
(define-key org-mode-map (kbd "M-S-<up>") nil)
(define-key org-mode-map (kbd "C-i") nil) ; remove old binding
(define-key org-mode-map (kbd "C-i") 'insert-four) ; remove old binding
(define-key org-mode-map (kbd "C-<up>") nil) ; remove old binding
(define-key org-mode-map (kbd "C-<down>") nil) ; remove old binding

Org comes with its own key bindings. I use my own, or hydras, so forget them.

:bind [close config section]

("<tab>" . org-cycle)

I almost always use C-i instead of tab. Then I use tabs to cycle folding in an org document.

Close Org use-package

);end-use package org-mode end-org-mode

Closing Notes

Reading World Magazine has yet to go into production. The prototype is now live, I’m working on the business plan and pitch.

In the meantime, and for the next few months, I will be working on Build Hello, which pays the rent.

You can subscribe to the Build Hello newsletters, which is a good time for website owners, and soon to be website owners, to look at hopefully rarish and unusual websites and talk web development.

Subscribe below:

An image encouraging the reader to sign up to the Build Hello newsletter.
An image encouraging the reader to sign up to the Build Hello newsletter.

That’s all for now…