A Few of my Org Mode Customizations13 Jul 2015
Org mode is already a part of my life. It’s only natural I’d like to perform various customizations to my liking. Fortunately customizability is exactly
Emacs’ core philosophy which means I get to do it with freedom. The following are just a few of them which I think might be helpful to others.
Paste rich format text from web pages into
When I first started to use
Org mode there was a glaring deficit to me, which is the inability to paste any formatted text from web pages. If everything pasted becomes plain, much of the original information would be lost, and this would be a great hindrance for anybody wanting to use
Org mode exclusively. Luckily this is
Emacs where everything is possible. After I posed the question on StackExchange, user @mankoff was quick to come up with a solution using
pandoc. Note that this version of code is tested on OS X, but for other systems the difference should only be the utility to call in order to retrieve text from system clipboard, which in this case is
There are actually a couple of points worthy of further attention. First is that
pandoc automatically hard-wraps its output at 70 characters per line. I normally just soft-wrap my notes so I added the option
--no-wrap command there.
Then note that
pandoc automatically uses Non-breaking space instead of normal space when converting formatted inline text(bold, italics, code etc.), which is not recognized by
orgmodeby default. Non-breaking space has to be added to
org-emphasis-regexp-components in order for those texts to be formatted correctly in
orgmode. The following is my code for that. There seems to be two space characters each line because non-breaking space looks exactly the same as normal space as rendered here, but Emacs recognizes it with a underline.
With this function copy-and-pasting in
Org mode supports rich format text as other note-taking apps.
Set non-monospace font for normal notes
Nobody likes to read normal notes in monospace. But the source code snippets better be aligned. Is there a way to achieve both? Definitely. The
variable-pitch-mode in Emacs is built just for that.
- Remember to first set
variable-pitchface in your configuration. Just
variable-pitchwould do. I use
Helvetica Neueas I think it’s easiest on the eyes when you stare at it all day. It’s easy to change when you want. The following code was added by
customizeafter I set the font:
- Add hook to turn on
variable-pitch-modewhen the target major modes are enabled. Note I set
org-codeetc. to be
fixed-pitchso that they’re still monospace.
There is a nice post offering a more detailed configuration and claiming to preserve more font attributes such as org table coloring. However for general purposes the simpler configuration should suffice.
Monospace together with normal font:
Hiding Text-Formatting Markers
This is probably more of a matter of personal taste but I don’t really like seeing text-formatting markers all around. Why display
/text/ when you can just have text. Turns out there’s a nice option in
org-hide-emphasis-markers which helps exactly in that. Just
M-x customize-variable and then set
t. I didn’t remember seeing this option when I was reading org manual and only stumbled upon it later, so I thought listing it out might help.
Inserting timestamp for each note.
One potentially useful feature of normal note-taking apps is the ability to have the notes timestamped automatically. In
Org mode one possible way of doing so is to utilize
org-insert-heading-hook. You can define a function
I am fine with having the timestamp in the header directly. So I just have
There’s another solution in an Org mode mail list discussion which inserts the timestamp into the body:
Automatic pull/push for MobileOrg
Traditionally there’s been open source projects called
MobileOrg to bring org mode’s functionality to your smartphones. Both Android and iOS versions utilize the same interface to interact with Emacs, which requires manually “pushing” and “pulling” changes from Emacs. There are a few timer-interval based auto-sync solutions out there. However, as I normally don’t use my phone to take notes with my laptop on, just simply pulling on Emacs initialization and pushing on shutting down works surprisingly well,
Note: Recently there has been an Android app called Orgzly which directly syncs your
.org files instead of going through the push/pull interface defined for
MobileOrg. I find it more refined and actively developed than the previous
MobileOrg Android. It’s not open-source, but currently it feels a better app and I’ll be using it for now.
Automatically start the next pomodoro with
I was used to automatically starting the next pomodoro when using other apps, as you’ll often forget to do it manually when a break finishes. There was an issue in
org-pomodoro which prevented this from being configured, but now it’s fixed and you can just use
org-pomodoro-break-finished-hook to achieve it:
I’m only starting to have fun with
Org mode so I might find some other interesting customizations later and list them here.