Line-wrapping in Emacs

It’s been a while, but I’m back to Org-Mode again.  This time I’m using it as a convenient and simple way to draft my paper on source levels (exporting to LaTeX).  And of course, since it’s been a while, I’m constantly having to look things up that I’m certain I knew before.  Like line-wrapping.

To use line wrapping where lines are split on the spaces between words (instead of splitting at the screen width regardless of where you are in a word) is much better on the eyes.  To do that, it’s:

cmd-M Visual-Line-Mode

Hey, presto!

And if you don’t want to have to type that in every time, just put the following line in your .emacs file:

(global-visual-line-mode 1) ; 1 for on, 0 for off.

AND… because I love to see what Google Images will kick back, the exact search terms “line wrapping in emacs 23” gave me this:

To a certain friend of mine (you know who you are):  I tried using Bing, but there was nothing nearly this exciting or totally unrelated as this.  Sorry.  Next time!

Emacs encryption

I finally figured out how to encrypt an emacs file – ooooh.  Now I can put all of my secrets into org-mode, and no one will ever know, mua-ha-ha!

Emacs encryption can be done using EasyPG, which comes with Emacs2.3.  So the first thing I did was upgrade to Emacs2.3 from 2.2 using Fink.  A quick aside:  I mistakenly installed the x11 version and kept thinking I had totally broken something because I was impatient when I didn’t immediately see emacs pop up in the terminal.  I also installed GnuPG from fink.

After that it’s easy – just add a .gpg extension onto the file, so something like  When you open it in Emacs, it recognizes that it’s really an org file, and when you go to save it, you just need to give a password to re-open it.  Don’t forget that password!! Here’s what it looks like:

And that’s it.

Auto-commenting Latex files in Aquamacs

Yet another reason why I love Aquamacs… I love being able to do this in Matlab (Ctrl-T/Ctrl-R), but it always bugged me that I couldn’t figure out how to do this quickly while editing scripts in Emacs.  I still don’t know how to do it in plain old Bash emacs, but I did find out how to do it in Aquamacs:

ctrl-c ;

This toggles between commenting and uncommenting. I still haven’t checked to see if I can do the same thing in Aquamacs with Python files. I suspect there’s a way. (actually I suspect there’s a way in command line emacs as well, I just haven’t found it).

Org-mode for meeting notes

I couldn’t include this in the main post about the meeting, because it’s really an aside. Anyone who used to read my old blog probably knows that I have recently fallen in love with Emacs Org-mode. It’s wonderful 🙂 I’ve found yet another great reason to love it – taking notes in meetings! I took more than 500 lines of notes in Org-mode. It was included in my main Org-mode log book. But it turns out that people actually wanted to have my copy of the notes (I didn’t say much during the meeting, but too a TON of notes). And I’m pretty sure most people wouldn’t have appreciated an Org-mode file as much as I would. Or even an unformatted flat text file for that matter. So I just extracted the relevant portion into a new Org-mode file, then exported to latex using:

M-x org-export-as-latex

Then, just to make things look at teeny bit nicer, I stuck this at the top of the page:

#+TITLE: Whale Meeting Notes
#+AUTHOR: Michelle Weirathmueller

Then I just ran pdflatex, and immediately had a really nicely formatted document, including a linked table of contents. Beautiful. I love when things like this make my life easier – and also makes it easier for the poor souls who might actually want to sift through the 20-odd pages of notes.

Org-mode deadlines and scheduling

I like how Org-mode is simple enough that I didn’t have to know much to get a lot out of it.  But it’s also nice to slowly learn new things as I go.  For example, I just learned about setting deadlines and scheduling.

To insert a deadline, use:

C-c C-d

This tells Org-mode to list the task (probably a TO-DO item, but doesn’t have to be) in the agenda for that date.

Using the command

C-c C-s

Tells Org-mode that you are planning to start working on the task on a certain date. In the agenda view, this task gets forwarded every day until it is completed.

Installing Emacs on Windows

I tend to do everything I possibly can on Linux, but once in a while, I need to figure it out on Windows (*cringe). For example, today I am going to install Emacs on Windows. I quite literally have no clue how to do this, but a quick Google search turned up this page, which describes it in painful detail.

LaTeX-ing again

Here I am, sitting indoors during a snowstorm, blundering my way through my raytracing script.  Ah, Snell’s law and optics.  What fun!  Anyhow, I realized that it was the perfect opportunity to practice some LaTeX skills.  I’ll be able to describe the theory of what I’m doing in my script.  Not that it’s anything complicated, but it’s enough for me to be able to practice some TeX-style math notation.  Sweet.

Here’s what I’ve got so far, using Emacs.  Easy!  No math yet though.
[sourcecode language=”latex”]
title{Raytrace script – how it works}
author{M. Weirathmueller}
date{1 January 2010}

This document is meant to accompany the my script, in an attempt to describe the theory behind what it’s doing.

The main idea is to read two sound speed profiles, and to compare depths computed by a multibeam echosounder for these profiles.



(incidentally – I just discovered that WordPress source code posting supports LaTeX – fun!)

It was also the first time I’d ever compiled a LaTeX file from the command line. I know, I know, it’s no big deal. But it was new for me!

Created my PDF like this:

pdflatex raytrace.tex

Then looked at it in my PDF viewer like this:
gnome-open raytrace.pdf

gnome-open just opens the file with the default program for that extension. Also – I added an alias to my .bashrc file so that just typing “g file.pdf” works like “gnome-open file.pdf”.

Emacs bug?

Whenever I start emacs from the command line, I get the following error:
(emacs:16341): GLib-WARNING **: g_set_prgname() called multiple times
I can’t figure out what is causing it. I did some google searching, and get the impression that it might be a bug. But if it turns out that I’ve just messed something up, I’d like to know about it so I can fix it! It doesn’t seem to cause any problems, but it’s sort of annoying.

More Emacs and Python

Fun times on Christmas vacation!  What better time to get my Emacs environment working the way I want it?  I’m going too try to keep it really simple this time.  I’m going to get Rope, Pymacs, and Ropemacs to start with, and maybe these will be all I need for now.

First, I create a .emacs file in my home directory.  I will fill it in as I go, and will include the final version when it’s complete.  All that’s in it now is a line that says: (add-to-list 'load-path "~.emacs.d/").  Also create a directory called .emacs.d. I had both of these things before, but deleted them and am starting from scratch because I had issues that I couldn’t solve.

1. Rope:  downloaded from Sourceforge repository (Rope version 0.9.2).  From terminal, ran with build, then install options.  (for help, run –help-commands)

2. Pymacs:  downloaded from Pymacs archives (Pymacs version 23).  From terminal, ran the file with the build and install options again.  I just put my .emacs.d/ directory in my emacs load-path (above), and then put the pymacs.el file in there.  The Pymacs website suggests byte compiling for speed, which isn’t too complicated:  just open emacs, type M-x byte-compile-file RETpymacs.el RET.

3. Ropemacs:  Last time I did this, I used the source repository on Bitbucket, but this time I just downloaded from the Sourceforge site (same as Rope, just scroll down).  I installed the same way as for Rope and Pymacs using the script.

Final .emacs file:
(add-to-list ‘load-path "~.emacs.d/")
(autoload ‘pymacs-apply "pymacs")
(autoload ‘pymacs-call "pymacs")
(autoload ‘pymacs-eval "pymacs" nil t)
(autoload ‘pymacs-exec "pymacs" nil t)
(autoload ‘pymacs-load "pymacs" nil t)
(require ‘pymacs)
(pymacs-load "ropemacs" "rope-")

And that’s it for now…Hopefully this will work for me. Maybe I’ll add Yasnippets eventually, but I don’t think I really have a need for that yet.

Yasnippets troubles

I have been messing with some old Python files that I wrote ages ago (a couple of which were mentioned in a post a couple of days ago about ray tracing) – of course I was using Emacs.  I’ve been getting this error since I configured Emacs for Python using the .emacs file in my home directory.  Every time I open Emacs, I get a buffer telling me that it can’t load the  Yasnippets_bundle.el file.  I have no idea why.  I went back to this website and tried to figure out where I’d gone wrong, but I think I’m going to have to just scrap my .emacs file (but save it, of course!) and start from scratch.  There’s a whole slew of code in my .emacs file that I copied from someone else on the web.  I certainly don’t understand it all, so it’s really no wonder that I can’t figure out why it’s not working!

Some websites that might help me out:

Emacs Python Wiki

EnigmaCurry Blog Post

I guess I’m overlapping somewhat with an earlier post, but I figured it can’t hurt to have things listed twice…Anyway, I hadn’t listed the Emacs Python Wiki before, and I think it looks helpful.

Note:  I had also forgotten to type  Alt+x eval-buffer - I guess this must mean evaluating the buffer, but I don’t know why I need to run this.  I should probably figure that out.  I did try typing it as the Yasnippets instructions indicate, but it didn’t make the error message go away.

Good news:  trying to solve the Yasnippets problem I had a chance to practice some Emacs and Bash commands – searching, moving around in a file, switching between buffers, etc…

Bad news:  there is a Yasnippets problem.

Conclusion:  Fixing my Emacs/Python issues is on my list.