Category Archives: org

On this page:

When I blog with Emacs and when I blog with other tools

English: org-mode logo: http://orgmode.org/wor...

English: org-mode logo: http://orgmode.org/worg/org-faq.php#unicorn (Photo credit: Wikipedia)

I would love to be able to write all of my blog posts within Emacs. I like the outline tools and simple markup of Org Mode. Org Mode and org2blog are invaluable when I’m writing a post with lots of code or keyboard commands, because it’s easy to set up syntax highlighting or add teletype text. Here’s an interesting self-referential example of org2blog’s power that uses #INCLUDE to include the Org blog post source in the post itself.

If I expect that a post will have lots of images, I tend to use Windows Live Writer because it takes care of resizing and aligning images, linking to the original size. Because it uses my blog’s stylesheet, I can get a sense of how the text will flow around it. I can quickly draw an idea in Autodesk Sketchbook Pro, copy and paste it into Windows Live Writer, and then resize it until it feels balanced on the page. Sometimes I draft a post in Emacs and then open it in Windows Live Writer or ScribeFire so that I can add images.

Org Mode also supports images, but it’s not as easy to resize things there. If I wrote a function that used ImageMagick to save the clipboard image to a file, resize it to the appropriate dimensions, and link it to the full-size image, maybe that would do the trick. Still, that sounds like it would be a fair bit of work. Maybe someday. Hmm – any chance someone reading this blog happens to already have that snippet handy? =)

If I need to edit an existing post, I either use the WordPress web interface or I use ScribeFire. That way, I don’t have to fill in the post publishing date again.

It’s a bit of a patchwork system of different tools, but it does the job. What’s your workflow like?

Helping someone get started with Emacs and Org Mode through Org2Blog and LaTeX; troubleshooting steps

Update 2013-08-30: By the way, here’s the link to Christopher Olah’s first post using org2blog. Neato!

The LaTeX logo, typeset with LaTeX

The LaTeX logo, typeset with LaTeX (Photo credit: Wikipedia)

Org2Blog is an awesome geek-friendly way of writing posts and publishing them to a WordPress-based blog. When Christopher Olah told me that he’d gotten convinced to try Org Mode thanks to the enthusiastic recommendations from Michael Nielsen and me, we figured that getting him sorted out with taking notes in Org and publishing them through Org2Blog to his WordPress.com-hosted blog would be an excellent way to start – especially with inline images and LaTeX.

Chris has promised to write a blog post about what he’s learned, but he’ll probably find these notes useful. Here’s what we ran into when getting org2blog working on Ubuntu.

Need to install the files and set up the load paths

We downloaded the following and added them to an ~/.elisp directory

We also set up his ~/.init.d/emacs.el to load the libraries, set the blog list, and load ido-mode and icomplete-mode.

Emacs / Org too old

Metaweblog and Org2blog didn’t work well with Emacs 23 and Org 6. We upgraded to Emacs 24 with apt-get install emacs24 in order to get Org 7.

Can’t find library org

It turns out that you also need to apt-get install emacs24-el in order to include those libraries.

Org still too old for org2blog

We were having some problems with the version detection of org2blog, so we replaced the org2blog he downloaded with the version I forked at https://github.com/sachac/org2blog , which I’ve been using with Org 7.

Then we tested it with org2blog/wp-post-subtree, and that worked. Inline images with org-toggle-inline-images worked too, yay!

Next step: viewing LaTeX fragments, since Chris does a lot of math.

dvipng required

org-preview-latex-fragment wanted dvipng to be installed, so we apt-get install dvipng.

LaTeX fragment preview showed blank images

We looked at the *Messages* buffer and found that the .tex files in /tmp could not be rendered by dvipng because marvosym.sty could not be found. We fixed that with apt-get install texlive-fonts-recommended.

(Doing this on my own, I found that I also needed apt-get install texlive-latex-extra .)

… and then we could see and publish LaTeX fragments, which was awesome. =D

WordPress.com double-interpreted LaTeX fragments

Chris was having problems with LaTeX fragments when org-export-with-LaTeX-fragments was set to dvipng. It turns out that WordPress.com also interprets LaTeX, so it was getting confused by the alt tags. To solve this, use M-x customize org-export-with-LaTeX-fragmentsand choose Leave math verbatim. Then the LaTeX fragments are passed to WordPress, which renders them as PNGs.

Hope that helps!

Emacs: How I organize my Org files

Michael Jones wanted to know how I organized my Org Mode files. Here’s how I do things!

Org Mode for Emacs is an outliner that lets you add a little structure to plain text files. Not only can you use it to move around, hide, and show sections of your outline, but you can also:

  • schedule tasks and mark them as complete,
  • add hyperlinks and formatting,
  • estimate effort and track time,
  • export to HTML and other formats,
  • and even include code that you can run in-line.

I started with a single Org Mode file (appropriately called organizer.org), but I’ve gradually fleshed this out into a number of files. My goals for organizing my files this way are to be able to:

image

  • Publish some files while keeping other files private,
  • Add or remove groups of tasks from my agenda, or focus my agenda/search on the current file,
  • Simplify processing my weekly review (categorizing accomplishments/tasks),
  • Get a quick overview of important things, and
  • Have file-specific options, like columns.

I often use Org agenda custom commands to jump around. For example, one agenda command lists projects, and pressing RET on an agenda line will take me to that project. I also use org-capture to take a note from anywhere, and I use org-goto to navigate my files. For jumping to a specific file, I use ido-find-file.

I use several Org Mode files. The six files below have a little more than 1.3MB of text in total – tiny! – but they help me tremendously. I also have lots of other Org files like my Emacs configuration and my blog index (I often use Org for publishing), but these are my main files.

Personal tasks and notes: organizer.org

This is the catch-all for any tasks or notes that don’t belong to the files below. Here’s the rough structure:

  • Quick notes: Tidbits that might not make it into their own blog posts, but which can be included in weekly reviews
  • Reference: Hours, license keys, etc.
  • Open loops: Anything I need to check on every so often
  • Projects: High-level things I’m focusing on
  • Financial goals: Things to save up for
  • Someday/maybe: Projects to do someday
  • Weekly review: Divided by year
  • Monthly review: More summaries
  • Plans: Personal plans
  • 2011, 2012, 2013…: I use org-capture to quickly jot down notes. The datetree option automatically files them by day, which makes older ones easier to archive.
  • Tasks: A bucket for miscellaneous tasks

Anything to do with business: business.org

I organize these by the types of tasks I focus on and the notes I want to keep.

  • Earn
    • Clients
    • Leads
  • Build
    • Projects
    • Research
    • Business ideas
    • Blog
    • Delegation
    • Planning
    • Business hygiene (accounting, etc.)
    • Learning
  • Connect
    • Meetups
    • Hangouts
    • Other
  • Reference
  • Tasks

Relationships: people.org

I organize these by relationships so that I can remember who’s out there.

  • Family
  • Extended family
  • Canada friends
  • Hacklab
  • Barkada
  • Letters
  • Meetups
  • Bloggers
  • Family friends
  • Other tasks

Regular tasks: routines.org

I organize these by frequency and omit the tasks from my weekly review. This also contains my “In case of…” scenarios and my backup documentation.

  • Every day
  • Once a week
  • Once a month
  • Once a quarter
  • Once a year
  • When…

Outline for future blog posts: sharing/index.org

I organize this by topic. See http://sach.ac/outline for the published version

Decision review: decisions.org

I organize these by status. I also use org-choose markers (ex: CHOSEN, MAYBE) inside the categories, but the headings make it easier to review.

  • Pending
  • Current
  • For review
  • Someday / maybe
  • Archive

Personal finance: ledger.org

I use John Wiegley’s command-line Ledger program to manage my finances. My financial data is in separate ledger-mode files, and I use an Org file with org-babel to make it easier for me to answer some questions about my finances. For example:

  • Given my average monthly expenses and the amount of money I’ve set aside, how long can I sustain my early-retirement experiment?
  • Am I ahead or behind in terms of household contributions?
  • What did I spend on last month?
  • Are my virtual envelopes balanced?

How do you organize your Org files or outlines?

Everyone’s got different ways of organizing outlines, and people also also change over time. How do you organize yours?

How to present using Org-mode in Emacs

You can do pretty much everything in Emacs, so why not give presentations too? Org-mode is an extensible outliner and Swiss Army knife for the Emacs text editor. Because it’s a great way to organize information, people have written a number of packages for presenting information from Org.

Here are some options for preparing and giving presentations using Org-mode, along with some guidance on what to use when. It may be a good idea to browse through the examples and create a small test presentation using the systems that catch your eye. If you choose your system before drafting your presentation, that can save you a lot of time, since the approaches differ in terms of the code you’ll need to add to your Org file.

Presenting outside Emacs

Do you need to distribute your presentation to non-Emacs users, or do you want to minimize the risk of getting your Emacs configuration confused? You can export your presentation to a number of formats.

Export to Beamer (LaTeX) and generate a PDF: Use this if you need to distribute your presentation as a PDF. You will need to install LaTeX, which could be a bit heavy-weight. Beamer is a slide package for LaTeX, and Org can export an outline to LaTeX code. Check out Writing Beamer presentations in Org-mode for sample screenshots and a tutorial.

Export to HTML and use S5: Light-weight browser-based slideshows are becoming more popular. They can be distributed as ZIPs or .tar.gz, or uploaded to web servers. See the section in the Org tutorials for Non-Beamer Presentations: S5. Here are some sample presentations.

Presenting within Emacs

Presenting within Emacs allows you to edit your presentation, execute code, or do all sorts of other interesting things. And it doesn’t have to be plain text – Org allows you to include inline images. (Microsoft Windows users may need to install additional libraries – see StackOverflow for tips.)

There are several ways to present from Org-mode. They tend to differ on:

  • the markup you need to add to your slides
  • the keyboard shortcuts to help you navigate between slides

so you can choose the one you feel the most comfortable with.

Org-present is simple and defines very few keyboard shortcuts: left for previous slide, right for next slide, C-c C-= or C-c C– to adjust text size, and C-q to quit. This makes it easy to edit your presentation as you go along. You’ll need to edit your ~/.emacs file to include some code. See the documentation in org-present.el for details.

EPresent is a bit more complex. It supports converting LaTeX into images, so you can embed pretty equations. The epresent keybindings include “n” for next and “p” for previous, so don’t use this if you’re planning to edit your presentation on the fly.

Org-presie takes a different approach by showing the outline instead of focusing on just one slide. When you press SPC, the previous headline’s content is hidden, and the next one’s content is expanded. It’s good for always giving people a sense of where they are in your presentation.

And then sometimes you may want to write your own. For my presentation at Emacs Conference 2013, I wanted to be able to:

  • allow me to indicate various headings as slides so that I can organize an outline of slides (why should they all have to be top-level?),
  • for each slide
    • automatically execute pre-written Emacs Lisp code (for animations and demonstrations!), OR
    • display images that fit the full height or width of the window, OR
    • display text if I don’t specify code or images
  • and have globally-set keyboard shortcuts so that I can go forward, backward, or re-do a slide no matter where I am in Emacs (and with AutoHotkey, even when I’m in a non-Emacs window)

You can find my code at https://gist.github.com/sachac/5278905

Emacs and Org-mode are wonderfully customizable, so you can probably build something that works just the way you want to work. Enjoy!

Rediscovering Emacs features, or what to do after you get carried away installing packages

A kid in a candy store – that’s me with M-x list-packages, EmacsWiki pages, Planet Emacsen, and other sources of Emacs goodness. Because Emacs has so much functionality and people keep adding stuff to it, it’s easy to forget about the cool goodies in configuration files and the Emacs codeverse. It’s important to practise and review, though, because there are all sorts of great keyboard shortcuts and commands that could make Emacs even better if I could just drill them into my brain.

Spaced repetition is a great technique for prioritizing and learning things. Emacs Org has an org-drill module that implements flashcards for Org headings that are tagged with :drill:. I’ve been using this to prepare for the Canadian citizenship exam, and that’s been working out well. So I started creating an emacs-drill.org file with headings for the things I’m interested in learning, such as multiple-cursor-mode and ace-jump-mode…

… And then I remembered, hey, my Emacs configuration is one big Org file (thanks to the joys of literate programming) so why don’t I just stick the :drill: tag onto the relevant snippets and run M-x org-drill there?

This might actually work out. =)

I was thinking of doing some kind of idle-timer hook, but I actually don’t mind manually triggering it. Besides, I’m experimenting with John Wiegley’s org-agenda display paired with winner-mode to save my window configuration.

Come to think of it, it might be good to add a random Emacs keybinding to the org-agenda display. I’ve installed keywiz, so I can reuse some of the code from that:

(use-package keywiz)
(defun sacha/load-keybindings ()
  "Since we don't want to have to pass through a keywiz game each time..."
  (setq keywiz-cached-commands nil)
  (do-all-symbols (sym)
    (when (and (commandp sym)
               (not (memq sym '(self-insert-command
                                digit-argument undefined))))
      (let ((keys (apply 'nconc (mapcar
                                 (lambda (key)
                                   (when (keywiz-key-press-event-p key)
                                     (list key)))
                                 (where-is-internal sym)))))
        ;;  Politically incorrect, but clearer version of the above:
        ;;    (let ((keys (delete-if-not 'keywiz-key-press-event-p
        ;;                               (where-is-internal sym))))
        (and keys
             (push (list sym keys) keywiz-cached-commands)))))))
  (sacha/load-keybindings)
  ;; Might be good to use this in org-agenda...
  (defun sacha/random-keybinding ()
    "Describe a random keybinding."
    (let* ((command (keywiz-random keywiz-cached-commands))
         (doc (and command (documentation (car command)))))
      (if command
          (concat (symbol-name (car command)) " "
                  "(" (mapconcat 'key-description (cadr command) ", ") ")"
                  (if doc
                      (concat ": " (substring doc 0 (string-match "\n" doc)))
                    ""))
"")))

… and a minor adjustment to org-agenda-custom-commands…

(defun sacha/org-agenda-with-tip (arg) (org-agenda-list arg) (let ((inhibit-read-only t)) (insert (sacha/random-keybinding) “\n”))) (setq org-agenda-custom-commands `((“a” “Agenda” sacha/org-agenda-with-tip) (“T” todo-tree “TODO”)
;; more here; see my config file
)))

… and now I see a random Emacs keybinding every time I review my to-do list.

agenda-tip

If you find yourself forgetting to revisit the nifty Emacs snippets you’ve added to your configuration, add reminders for yourself. Make yourself some flashcards with org-drill.el or flashcard.el and give that a try, or integrate reminders into your workflow. Have fun!

Emacs Org: Task-related keyboard shortcuts for the agenda

I really love the way you can tweak Emacs’ keyboard shortcuts and functionality to fit the way you want to work. Here are three keyboard shortcuts I’ve added to my Org agenda to make it even easier to work with tasks.

x: Mark the current task as done. Same as typing t x, but somehow it feels like it has more oomph as a single-character shortcut.

X: Mark the current task as done and create a new task at the same level, taking advantage of the task template I’d previously created in org-capture-templates.

N: Create a new note or task at the current position.

Make it easy to mark a task as done

(defun sacha/org-agenda-done (&optional arg)
  "Mark current TODO as done.
This changes the line at point, all other lines in the agenda referring to
the same tree node, and the headline of the tree node in the Org-mode file."
  (interactive "P")
  (org-agenda-todo "DONE"))
;; Override the key definition for org-exit
(define-key org-agenda-mode-map "x" 'sacha/org-agenda-done)

Make it easy to mark a task as done and create a follow-up task

  (defun sacha/org-agenda-mark-done-and-add-followup ()
    "Mark the current TODO as done and add another task after it.
Creates it at the same level as the previous task, so it's better to use
this with to-do items than with projects or headings."
    (interactive)
    (org-agenda-todo "DONE")
    (org-agenda-switch-to)
    (org-capture 0 "t"))
;; Override the key definition
(define-key org-agenda-mode-map "X" 'sacha/org-agenda-mark-done-and-add-followup)

Capture something based on the agenda position

(defun sacha/org-agenda-new ()
  "Create a new note or task at the current agenda item.
Creates it at the same level as the previous task, so it's better to use
this with to-do items than with projects or headings."
  (interactive)
  (org-agenda-switch-to)
  (org-capture 0))
;; New key assignment
(define-key org-agenda-mode-map "N" 'sacha/org-agenda-new)

Check out my Emacs configuration for other ideas.