One thing I sometimes miss about the text editor Brief, which I stopped using a decade ago, is being able to move between windows easily by pressing a function key and then an arrow key to switch to a window in that direction.
In emacs I only knew how to move between windows using `other-window', mapped to C-x o and that only cycles around the windows, and if you have a few windows open and possibly you're also editing the mini-buffer, that's quite a round trip.
I just learned about `M-x windmove-default-keybindings', which binds a set of commands that do exactly the kind of directional movement I'm talking about (`windmove-right', `windmove-up' and so on) to the cursor keys (with shift key held).
Tuesday, September 8, 2009
Tuesday, September 1, 2009
Handful of emacs tips
keep-lines
flush-lines
These handy functions prompt you for a regular expression and will either remove every line that does not contain that expression (keep) or remove the ones that do (flush).
finder-list-keywords
This function shows all the keywords used in the packages within emacs. In other words you can find a lot of stuff in emacs that you never knew was there.

flush-lines
These handy functions prompt you for a regular expression and will either remove every line that does not contain that expression (keep) or remove the ones that do (flush).
finder-list-keywords
This function shows all the keywords used in the packages within emacs. In other words you can find a lot of stuff in emacs that you never knew was there.

Wednesday, August 26, 2009
Simple budget forecasts in emacs
When I first moved from England to North America one of the things I found hard to get used to was getting paid every two weeks instead of monthly. This means that some of your bills are monthly, some are biweekly, and occasionally I had more or less money than I expected as they got out of sync.
I've been using a simple elisp program I wrote to let you manage your upcoming bills, weekly budget items like groceries, and your regular income. It runs through a period of dates you supply, and a list of incomes and expenses, and produces a csv file and a buffer that contains the output of the forecast. It shows the highest and lowest balance of the period too, so you can spot if you will go over drawn, and also see peaks when it's a good time to move money to savings.
The code is hosted on google code as emacs-easy-budget and is also released as GPL v3. Hope somebody finds it useful.
Wednesday, June 17, 2009
1337 on StackOverflow

I noticed today that my StackOverflow reputation is 1337. What an incredibly geeky way to begin Wednesday!
Wednesday, May 27, 2009
Linux: Looking at files changed recently
This is really handy (on Linux and Cygwin) when you're working on a project that may not be in source control and you want to see what you changed recently.
I made this blog post, when it seems a trivial use of find, because I don't think the man page covers it well.
This command finds all files modified in the last 60 minutes:
find . -type f -cmin -60
I made this blog post, when it seems a trivial use of find, because I don't think the man page covers it well.
This command finds all files modified in the last 60 minutes:
find . -type f -cmin -60
Thursday, May 14, 2009
Linking MingW32 with psapi
Here's something I came across that didn't have a good answer when I googled. If you get link errors with MingW32 like:
undefined reference to `GetProcessMemoryInfo@12' or
c:/justinhj/mem.cpp:55: undefined reference to `EnumProcesses@12'
Then you are not linking with the library psapi, and you need it.
To do this just add -lpsapi to your command line. It needs to be last in the list of libraries too!
undefined reference to `GetProcessMemoryInfo@12' or
c:/justinhj/mem.cpp:55: undefined reference to `EnumProcesses@12'
Then you are not linking with the library psapi, and you need it.
To do this just add -lpsapi to your command line. It needs to be last in the list of libraries too!
Writing quick C++ programs in emacs without a makefile

Cheetah by Storm Crypt
Often when programming in C++ (or many other languages) it's desirable to write a quick program, usually a console application, to test something quickly. Working in developer studio, it takes an amount of fiddling and clicking large enough that you may not want to bother.
Working in emacs and MingW32 (or Microsoft's CL.exe) I can quickly create a CPP file, and then compile it. To compile a program though you need to either write a makefile, or build up a complex g++ command line.
Rather than do either of those I make a helloworld.cpp file which can be built like this:
g++ helloworld.cpp -g -o helloworld.exe
So I hit
M-x compile
then type in the above to compile and link it.
However there's a better way. You can add the compile command as the first line of the file as a file local variable.
// -*- compile-command:"g++ helloworld.cpp -g -o helloworld.exe"; -*-
Now I can hit the compile and it works right away, between sessions. No makefile or project settings in sight, and now there are minimal barriers involved in creating a simple test program beyond copy and pasting the file.
Subscribe to:
Posts (Atom)