I keep my Emacs init files on Dropbox – that way I only have to maintain one set of files no matter how many machines I run Emacs on. My local .emacs file simply loads the init files on Dropbox.
One minor problem is that Dropbox can have a different path according to the operating system.
This is easily resolved using the system-type variable. For my set up, I’m only interested in whether I’m running on a ‘gnu/linux or a ‘windows-nt system.
The following code sets the path of my Dropbox folder and then uses the format function to append the appropriate init files to that location. The individual files are then loaded. I’ve split my .emacs file across several files for tidiness and convenience. Even so, it still manages to degenerate into a mess when I’m not watching it.
1: (if (eq system-type 'windows-nt)
2: (setq dot-emacs-files "c:/Users/username/Dropbox/emacs")
3: (setq dot-emacs-files "~/Dropbox/emacs")
6: (load (format "%s/%s" dot-emacs-files "packages-dot-emacs.el"))
7: (load (format "%s/%s" dot-emacs-files "org-dot-emacs.el"))
8: (load (format "%s/%s" dot-emacs-files "common-dot-emacs.el"))
9: (load (format "%s/%s" dot-emacs-files "elisp.el"))
Sending email from Emacs is remarkably easy for Linux users. The following works for >=Emacs 24; it assumes you have a Gmail account.
1) Open Emacs and hit C-x m to bring up the unsent mail buffer
2) Write a test email and hit C-c C-c to send
3) At the prompts, choose SMTP and then enter smtp.googlemail.com for server.
4) Enter username and password
5) Say yes to save password to ~/.authinfo authentication file.
6) And that's it. It really is that easy.
If you follow the above process you will see that the following are added to your .emacs file
1: '(send-mail-function (quote smtpmail-send-it))
2: '(smtpmail-smtp-server "smtp.googlemail.com")
3: '(smtpmail-smtp-service 25))
If you’ve saved the password you’ll see that the following has been written to the ~/.authinfo file.
machine smtp.googlemail.com login username port 25 password mypassword
If you’re worried about having that information stored as plaintext, Emacs will read from a ~/.authoinfo.gpg file, if you have GPG installed.
Recently, Gmail has updated its security policies to only accept logins from secure apps. You may have to disable this setting in order to access the account. Given this, and also how much is attached to a Gmail account nowadays, you may want to set up a spare Gmail account just for the purposes of sending email.
Setting up Emacs to read Gmail via Gnus isn’t that much harder. However, given the multimedia nature of so many emails nowadays, I don’t find this feature very useful anymore.
What I do find useful is being able to send emails from Emacs. This means I can quickly fire off an email without leaving the editor and thus breaking my workflow.
You can find out more about sending and reading email at http://www.emacswiki.org/emacs/CategoryMail
Like many people, I’ve had problems installing org-mode using elpa, resulting in the well known error
Invalid function: org-with-silent-modifications
This is usually due to not following the installation instructions:
When installing from ELPA, please do so from a fresh Emacs session where no org function has been called.
I’ve encountered this problem a few times on Windows installations, each time through forgetting the above advice. The solution was straightforward, go to (home)/emacs.d/elpa and delete the org file, temporarily rename the .emacs file so that you’re restarting Emacs to a completely fresh session (or start a fresh emacs without any customization with
emacs -q -thanks to iNecas). After that org-mode installs without a hitch.
And then I tried to do the same on Linux. Same error, same attempted solution. This time it didn’t work. I wasted half on hour on this until I tried a complete reboot of the PC. This time it worked. The lesson is, when it says fresh Emacs session, it means a completely fresh Emacs session.
Due to the interest in my post on Writing Tools, I’ve published an HTML document on my Emacs writing setup.
If you want to know how I plan and plot stories, you may find the document interesting. You’ll probably find it more interesting if you use Emacs yourself.
A Note on Emacs
I think of Emacs as a text editors’ tool. As I spend most of my life working with text, either programming or writing, I want to do it as efficiently as possible.
It first struck me when I was editing my novel Divergence just how inefficient I was being in pressing the arrow key and waiting for the cursor to get to where I wanted. That got me thinking about the time spent deleting text, transposing words, moving around paragraphs… I realised there must be a quicker way.
And then I remembered Emacs.
It makes sense for someone who spends most of their time manipulating text to learn a group of obscure key combinations. It saves time and increases productivity. Learning to use Emacs properly reminds me of playing Jazz on the piano. I’ve learnt all those chords and runs and fills so that I can use them without thinking when I’m improvising. Likewise, I’ve practised using Emacs key strokes such as M-f, M–M-c and C-M-<Space> so often I use them without thinking when editing. I rely on M-/ to complete words, and I can’t do without M-h and C-e to select and move around text.
I practice using Emacs because it makes me a more productive writer. If you’re interested, I’ve written up some of those tips and exercises on my Emacs Workout.
Emacs works straight out of the box on Ubuntu however, at the time of writing, Ubuntu 12.04 still only comes with org-version 6.33. It’s worth installing the latest version. The installation instructions are on the org-mode site http://orgmode.org/manual/Installation.html, but they’re not quite complete.
Install the latest version of Org-Mode
- Download the org-mode files and copy to a suitable location (I put them in the Ubuntu One folder so they’re easily shared between PCs)
- sudo apt-get install texinfo. This is the missing step that ensures the next part works correctly
- Navigate to the org-8.x folder and sudo make autoloads and then sudo make install
- Finally, add (add-to-list ‘load-path “/usr/share/emacs/site-lisp/org”) to your .emacs file
Some of the Unity keybindings overwrite those of standard org-mode. I get particularly frustrated not being able to use S-M-<UP> to sort lines. The following sorts this out:
- sudo apt-get install compizconfig-settings-manager
- Launch compiz-config-settings-manager
- Dash Home -> CompizConfig Settings Manager-> Scale(icon) under Windows Management Category -> Bindings(tab) -> Initiate Windows Picker -> change to <Shift><Super>Up or similar
Alt and Alt Gr
I don’t make use of the way Ubuntu distinguishes between these two keys, and I prefer to set the Alt Gr key to act just like the Alt. For one thing, it makes it easier on the hands to type M-f and M-b when moving forward and backwards through words (something I do a lot when editing) . Making this change on Ubuntu 12.04 is easy
- Open Keyboard Layout from the dash. Choose Options, Alt/Win Key behaviour and select Alt and Meta are on Alt Keys
Note you you can also swap the Ctrl and Caps lock this way if you prefer.
For older versions of Ubuntu, the Keyboard Layout preferences are found on a tab in Keyboard in System Settings
Installing Emacs on Windows
- Download a copy of Emacs for Windows from here: http://ftp.gnu.org/gnu/emacs/windows/ Emacs comes as a zip file looking something like this: emacs-24.3-bin-i386.zip 18-Mar-2013 22:43 47M
- Unzip the folder to a suitable location, e.g. C:/Program Files
- That’s it. There is no other installation required.
- To launch Emacs, run the runemacs.exe file in the emacs-XX.X\bin\ folder
- You will now have a functioning copy of Emacs.
Follow this link to my Emacs Tutorial
…You’ll probably find, however, that not all features are present. Follow the steps below to add the remaining features.
If you’re looking for how to get Ediff or the spell checker to work in Windows, you’ve come to the right place.
Ispell (Spell Checker) on Windows Emacs
- Download Ispell: http://www.filewatcher.com/m/ispell.zip.352502-0.html
- M-x customize-variable and enter exec-path to include the path to ispell.exe
- Copy english.hash to emacs home folder. (You can find the path to your home folder by pasting the following into Emacs: (getenv “HOME”) and pressing C-x C-e after the final bracket.)
M-x flyspell to turn on flyspell mode, which underlines misspelled words. Click with the centre mouse button on the misspelled word for a menu suggested changes.
I like to add the following to my .emacs file. It maps the menu select option to the right mouse button.
(eval-after-load “flyspell” ‘(define-key flyspell-mode-map [down-mouse-3] ‘flyspell-correct-word))
Cygwin is “a collection of tools which provide a Linux look and feel environment for Windows.”
Installing Cygwin is the easiest way to enable all those extra features in Emacs
- Go to http://cygwin.com/ and run the setup.exe file on the website
- Install the default set of packages
- If you want to be able to use org-mode to export to ODT documents in Windows, you’ll need to install zip and unzip from the archive package.
- On Emacs, set exec-path to c:\cygwin\bin (or to wherever you installed Cygwin) (If you don’t know how to set exec-path, the easiest way is M-x customize-variable, enter exec-path and then insert the path in one of the fields. Don’t forget to save the changes)
- Add c:\cygwin\bin to your Windows path and restart the machine
Done. Emacs should now by fully working on your Windows machine.