endperform.org

Musings from /dev/random

Browsing Posts tagged life-with-emacs

I’ve finally found what I’ve been looking for as far as notes / organization at work goes. I discovered org-mode for Emacs while I was researching and testing some ways to keep me organized. I had gone the wiki route previously, but I found that the dependency of a database and browser just didn’t suit my “have it when / where I need it” ideals. Sometimes, I have to log into my work machine from home, and forwarding my X display can be painful. Since a lot of the time I was using Lynx to view pages anyway, I figured I would opt for a more text-based approach. I’ll go into how I’m using org-mode, but for further information, please check out the website.

Timesheets
I have to keep track of time I spend working on various things. Usually I used a pad and paper for this, but a lot of the time I don’t want to have to stop, write something down, then jump back. I have a timesheet.org file open in Emacs during the day so that I can switch to the buffer and enter my time. I use one headline per week, and create a table for the time. It works out nicely because now I have one file with my timesheets. I started this about a week or two ago, but I have no plans of entering all of my old time here.

Scripts, Utilities and others
Throughout the course of the day, I’m using a lot of different tools to get my work done. Sometimes I’ll discover something new and helpful and I’ll want to keep the command around for future use. For that, I have a scripts.org file to keep things organized. For customer information, right now I have one big customers file, but I think I’m going to start splitting that out into separate files soon.

The thing I really like about org-mode is being able to collapse the various levels. It keeps the information I don’t need right now out of my way while at the same time keeping everything in text form, so I can read it anywhere. I know I’m not harnessing the full power of this mode, but it fits my needs and perhaps it might fit someone else’s needs out there as well.

I’ve covered some very basic things up to this point, and really, that’s all I’ve needed to use Emacs in my daily workflow. I’ve not really dug deep into any of the special modes available, with the exception of the modes that load based on filetype. For the most part, the modes don’t offer anything special to this newbie, but one thing that annoys me is the auto-indentation. I haven’t had a chance to research the fix for that yet, but by default I don’t want any auto-indentation to occur. I’m sure it’s probably a few simple lines added to my .emacs and I’ll have what I need. Speaking of .emacs, and my cheatsheet, I’ve installed a wiki so I can keep things that evolve, such as my cheatsheet in one place. I’ll work on putting my .emacs online as well shortly, so people can point and laugh at it. :) But, at this point, I can safely say that I can navigate around and edit pretty easily, at a basic level.

What’s next on my Emacs plate? Well, I’d really like to figure out a way to log notes / time spent on tickets at work. Currently the ole pen and pad method are what I use to do this. Ideally I’d like to be able to set something up to ask me for a ticket number and then open a new file based on that. I’m sure there’s a way to script it, I just have to sit down and research it. That would resolve the note portion of the problem, but then comes the time tracking. I suppose I could whip up a small spreadsheet or something to keep it electronic as well, or check out one of the numerous time tracking apps out there, but what would really help is something that would keep everything in one place. There might be something out there, there might not be. I’ll have to search around and find it.

This installment of Life with Emacs doesn’t have much in the way of opinions or what I’m using it for, instead I’ll just be posting the cheatsheet I’ve been keeping in hopes that it might help someone else out. As time goes on, I’ll keep adding to this. For now, I present to you my Emacs cheatsheet:

-- Buffers --
C-x C-f         Open existing (or new) file
C-x C-s         Save buffer
C-x C-w         Save buffer as...
C-x C-c         Exit Emacs

C-x b                   Switch to buffer. Type in the name.
C-x < - or ->    Cycle through buffers
C-x 1           Return to 1 window
C-x 2           Split window into two
C-x o           Switch windows

-- Moving / Editing --
C-a             Beginning of line
C-e             End of line
C-s             Search
M-x string      Find and replace
C-w             Cut
M-w             Copy
C-y             Paste (yank)
C-k             Cut text to end of line

Emacs might be thought of as a programmer’s editor, but it works just as well as a text editor. But Brad, isn’t it a bit overkill to use Emacs for text editing? I’m a fan of getting as much use as I can out of an editor, and what better way than this? The buffers are one of my favorite things about Emacs. Sure, Vim has buffers, too, but I like the navigation in Emacs better. In my work, I deal with support tickets. So, when I take on a ticket, the first thing I’ll do is this C-x C-f 1111111, where 1111111 represents the ticket number I’m working on. Then from that point, as I gather information, I copy things from one window to another into that buffer to keep it handy. Once in a while, I’ll save the buffer with C-x C-s so I don’t risk losing the notes. This is definitely an easy way to keep my notes separated by ticket, and if I happen to be working on multiple tickets, I can switch buffers with C-x b then the buffer name.

By default, Emacs starts you out in a scratch buffer. I keep this open and use it to copy / paste tidbits of information that I might need later in the day, such as commands or even some time tracking. It truly is a scratch buffer in this case, and it works wonders. That’s it for this week. I was going to share my cheatsheet, but sadly I lost it. I’ll have it for next week. For now, I leave you with a summary of commands I used this week. For each of the commands, please note that C is the Control key, and M is the Meta, or ALT, key.

Emacs Commands Used

  • C-x C-f filename – Create a new file called filename. Can include paths. Example: C-x C-f /home/fubar/temp.txt
  • C-x C-s – Save the current buffer
  • C-x b – Switch to buffer. Presents a default buffer name, but type the name of the buffer you want.

I’ve tried a couple of times to try to write a recurring series here, and this is going to be my latest (hopefully not failed) attempt. I present, Life with Emacs, a walk through Emacs through the eyes of someone still trying to learn all of the important keybindings. Each week, I’ll look at a particular task I’ve been using Emacs for, and along with it hopefully provide some other newbies some insight into what I’m going through.

As far as backgrounds in editors go, I’ve pretty much been a GUI / Vim guy for as long as I can remember. I know enough Vim to get in and out of a file relatively quickly, but for any heavy coding, I’ve leaned on an IDE to help me out. I figured I would try out Emacs for a few reasons. One, there’s plenty of Emacs users at work I can bother with questions. Two, there are a lot of potentially useful modes that might actually be able to help me organize myself at work. Finally, I want to break down and learn the ins and outs of one editor, and I’ve chosen Emacs to focus on. Will I stick with it? Time, and my patience, will tell the tale. I plan to use Emacs in place of other editors that I had been using to create scratch notes as I work on things at work, and also plan to use it to do the occasional scripting / web maintenance that I’m tasked to do.

Next week I’ll present the beginnings of my little Emacs cheatsheet and will dive into the first task I’ll look at, which is note-taking in my work environment.



© 2010 endperform.org - Powered by geekery, beer and a warped mind.