Sunday, December 24, 2006

Key shortcuts in Enlightenment

Enlightenment is a really cool window manager, with lots of customizability. One thing that I make extensive use of is Key Shortcuts, these are present in other window managers as well, but I'll focus on Enlightenment for this Tip.

To get to the Key Shortcut editor, press the right mouse button on the root window (the background window), and drag down to "Legacy E-Conf Tool". The E-Conf window will popup, select "Shortcuts" from the menu on the left side.

You can bind Key Shortcuts to lots of different functions, some that I use are: 1) I have rebound the numeric keypad "+" and "-" to "Switch focus to previous window" and "Switch focus to next window", this is like "Alt-TAB" in Windows, but is cooler since I can move forward and backward between windows, not just forward.

2) I have 2 desktops with 6 virtual windows each, so I have rebound "CTRL-arrow" to move between virtual windows, and "CTRL-ALT-arrow" to move between desktops. This gives me lots of screen real estate, and makes it easy to move to any area within my virtual desktop. Really powerful and fast since you don't have to use the mouse as much.

3) Coolest: I have "PrtScn" bound to the command "Run ksnapshot", so when I press "PrtScn", I can easily get a snapshot of my desktop. You can bind any other key or key pressed with modifiers bound to any command, so it can get very powerful.

To add to this, in Emacs, I got sick of typing "M-x compile" to compile, so I rebound [F12] to compile with the following:

(global-set-key [f12] 'compile)

Cool, eh?
Grabbed calculator.el off of gnu.emacs.sources. A very cool little mode that makes a one line high window above the modeline that acts as a funky little calculator. Just what I need so that I don't have to use xcalc anymore.
Repeating Searches

To repeat a search that you've already done, press C-s, then use C-p (previous) and C-n (next) to scroll through old things you've searched for.

This works for "M-x tags-search" as well. Tags will be the topic of another tip of the day.
Saving window configurations

First, some terminology: The entire emacs window (Xwindows window) is called a frame. You can divide a frame into multiple subwindows, one command that does this is C-x 2, which divides the frame horizontally into two windows, another is C-x 3, which divides the frame vertically into two windows. This is pretty basic.

But, one thing that always frustrated me was having to recreate these windows after I'd merge windows together with C-x 0.

So, to save and recall the positions of all your emacs windows, use the commands C-x r w and C-x r j.
M-x grep

Something I just found, very useful:

First load up a file in a directory you want to grep in: (For this example, I loaded up /usr/include/socketbits.h)

Then type:

M-x grep

This gives you a prompt Run grep (like this): grep -n -e

Add, first the pattern you want to search for, then the pattern of files you want to look in. Like this:

Run grep (like this): grep -n -e sockaddr_in *

Or, if you want to recursively grep, not case sensitive:

Run grep (like this): grep -rin -e sockaddr_in *

Press return, Emacs will split the buffer in two, and will display the results of the grep in the upper window. Go to one of the lines in the upper window and press C-c C-c, Emacs will load the file you're pointing to and will jump to the line number.
ediff-mode

One of the most amazing modes in Emacs is "ediff-mode". It's a little hard to learn, but is so powerful, once you learn it, it'll scare you.

ediff-mode is used to show the differences between 2 or 3 buffers, files or directories, and can be used to either just look at the differences between these, or can be used to merge changes between these.

This mode is really really useful when you have files that have small differences, and you want to find out what and where these differences are.

To put this in practical terms, recently, I had two different versions of FPC, one that had a bug, and one that didn't. There were lots of changed files in different directories between the two version. A simple "diff" of the files gave an output of about 1400 lines, too many to look at by hand.

So, I used ediff-mode to help me isolate and look at the differences between the two versions.

I started up with the command M-x ediff-directories. This will ask for two directories to compare. After selecting the directories, it asks for a regular expression to filter through, usually, just press >RETURN
< here.

It then pops up a buffer showing the files and directories that are different, scroll down to one of these and press >RETURN
<. Emacs will then divide the window in half, showing the first version of the file in the top window, and the second version of the file in the bottom window. Emacs will also pop up a new tiny frame at the top of the screen in which you can type ediff commands.

The most useful of these commands are p and n, which jump to the previous and next diff regions. When you press these keys in the command frame, ediff will scroll both windows to where the difference region is, and will highlight the region nicely to show you exactly where the differences are.

Other cool commands are V and v which scroll both windows up and down simultaneously, | which divides the windows vertically instead of horizontally, ## which makes ediff ignore whitespace regions, and a and b, which will copy the diff region from either the first window to the second window, or vice versa.

There are so many more commands in this mode, press ? in the little command window to see some of them, and look at the Info documentation C-h i for more.
xkeycaps and xmodmap

Very cool programs, xkeycaps is a program written by Jamie Zawinski, the uber-hacker who created the first Netscape V1.0 for UNIX and was one of the main organizers of Mozilla it shows you your current keyboard layout, and can write a .xmodmap file.

xmodmap allows you to remap any key on your keyboard. For instance, I have remapped my numeric keypad to give the same keycodes as the arrow keys, so that I can use my numeric keypad to scroll in gnome-terminals and Netscape. I have also recently remapped my Caps Lock key to a Control key, so that it's easier to enter control codes into emacs. :)

So now, I have two Control_L keys:

keycode 0x42 = Control_L
keycode 0x25 = Control_L
Emacs : Rectangles

One of the the most powerful, but infrequently used tools in emacs are
Rectangles. From the *info* file (C-h i):
"The rectangle commands operate on rectangular areas of the text: all the characters between a certain pair of columns, in a certain range of lines. Commands are provided to kill rectangles, yank killed rectangles, clear them out, fill them with blanks or text, or delete them. Rectangle commands are useful with text in multicolumn formats, and for changing text into or out of such formats."

"When you must specify a rectangle for a command to work on, you do it
by putting the mark at one corner and point at the opposite corner.
The rectangle thus specified is called the "region-rectangle" because
you control it in about the same way the region is controlled."


I use rectangles all the time, they're really useful for moving columns
around, for deleting irregular areas of text that you'd usually have to
delete one character at a time (e.g. after copying a whole bunch of lines
in perl or HTML), or for removing spaces between space or tab delimited
columns of data.

I also use it a lot when I make graphs in gnuplot, often you need a column
with a series of increasing numbers for the x-axis, so I have a little
program that makes a file with increasing numbers, then cut this column
out and paste it into the file I need graphed.

So, to put this all into practice: To mark one corner of a rectangle,
press C-space. Then, move your cursor to the other corner of the
rectangle you want to work on, and press C-x r k (rectangle kill).
This will kill the rectangle you've just selected and will move it's text
to the kill ring.

Finally, if you just wanted to move the rectangle, and not just remove it,
move your cursor to the place where you want to move the rectangle to and
press C-x r y (rectangle yank).

In pictures:

I start with the following:


1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9


I want to move the 4th column in between rows 7 and 8. To do this, I put
my cursor on the very first "4" (first row) in the above text, then press
C-space. Next I cursor down to the very last "5" (last row), and press
C-x r k.
This gives me the following:


1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9
1 2 3 5 6 7 8 9


Next, I move my cursor to the very first "8" (first row) and press
C-x r y. The result of this is:


1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
1 2 3 5 6 7 4 8 9
Emacs + Shells : Quickies

Here are a bunch of quick keystrokes that make my life easier in both emacs and within my shell. Both bash and tcsh can use these keystrokes, and make life on the command line much more pleasant.

C-a - Go to beginning of the line C-e - Go to end of the line

C-k - Kill (cut) from current cursor position to the end of the line C-y - Yank (paste) what you just killed

C->SPC
< - Set a mark C-w - Kill from previously set mark to current cursor position (can also be yanked back with C-y)

(The above four commands are *very* powerful, and can save you lots of keystrokes, I use it a lot for instance to move a file to a slightly different filename, type say

mv filename

Then go the beginning of "filename" and press C-k, then press C-y >SPC
< C-y

It's almost like magic...)
Unix commands

Two of my most favorite unix commands are "find" and "tail -f". I'll briefly describe how to use them, but for more information, please consult their man pages.

tail -f
tail - Print the last 10 lines of each FILE to standard output. Useful in itself, but not super useful.

But with the "-f" flag (follow file), every few seconds, tail will rescan the file, and if anything new has been added to the file, it'll display that. It's very cool for watching log files, or output files, or anything that you don't want to keep "more"-ing.

But, this weekend, I found the coolest new extension to tail, "--follow". tail used to just watch a file descriptor, so if you were looking at a logfile, and the logfile got rotated, you would be looking at the backed-up log file, and not the current version. So, use "--follow=name", and tail will instead look for the filename instead of the file descriptor.

find
find is an incredibly powerful command, and even though I now use "grep -ri" (recursive case insenstive grep, try it out) for a lot of the things I used to use find for on IRIX, find is still incredibly useful.

First, how to use find in it's most basic context find . -name "*pattern*" -print This will start at the current directory ".", will search for all files that contain the pattern "*pattern*" and will print their filenames.

One of the coolest options to find is "-exec". Here's an example of it's use: find ~/GDEV/seed -name '*.[ch]' -exec grep enum {} \; -print

This will start in the directory "~/GDEV/seed", will find all files that end in either ".c" or ".h" and will print out all occurences of "enum" in these files. For each file that contains "enum", it will also print out it's filename.

Looking at the -exec part of the above command you see

-exec grep enum {} \;

-exec - start the command to exec grep - command to run {} - current file being processed by find \; - end the command to exec

Woah. This is getting pretty cool now. What really is cool is that you can run *any command* with -exec. I use "cp" a lot, but you can use any command you need. Very powerful.

There are *tons* of options to exec, some of my favorite are

-printf -maxdepth -xdev -amin

Use "man find" to find out what these options do.
Saving a position records a place in a buffer so that you can move back there later. Moving to a saved position switches to that buffer and moves point to that place in it.

C-x r >SPC
< R Save position of point in register R (`point-to-register').

C-x r j R Jump to the position saved in register R (`jump-to-register').

To save the current position of point in a register, choose a name R and type C-x r >SPC
< R. The register R retains the position thus saved until you store something else in that register.

The command C-x r j R moves point to the position recorded in register R. The register is not affected; it continues to record the same position. You can jump to the saved position any number of times.

If you use C-x r j to go to a saved position, but the buffer it was saved from has been killed, C-x r j tries to create the buffer again by visiting the same file. Of course, this works only for buffers that were visiting files.
A user of mine needed to do searches on DNA sequences, one of the searches is looking for restriction fragments. I came up with the following to search for the sequence "ACGT", even if the sequence spanned lines:

(C-M-s runs the command isearch-forward-regexp)

C-M-s A[ ]*C[ ]*G[ ]*T

Yeah, it works. It's ugly. Ugly isn't good.

So, did a little search on google and found dna-mode.el (local). Oh wow, it's so cool, a mode for viewing and editting DNA! It works really really nicely. To use it, put dna-mode.el in your load-path and add the following to your .emacs: ;; DNA mode (autoload 'dna-mode "dna-mode" "Major mode for dna" t) (add-to-list 'auto-mode-alist '("\\.\\(fasta\\|fa\\|exp\\|ace\\|gb\\)\\'" . dna-mode)) (add-hook 'dna-mode-hook 'turn-on-font-lock) ; Make isearch prettier (not needed, but nice) (make-face 'isearch) (set-face-background 'isearch "yellow") (setq-default search-highlight t)

NOW! Instead of isearch-forward, run M-x dna-isearch-forward. This isearch will ignore padding characters, newlines, and other cruft.

This mode also has a really nice font-lock mode, makes looking at fasta files more pleasant. The above code snippet will automatically fontify DNA files.

Also very nice in the mode is: (dna-complement-region), this complements the DNA in your current region.

You can also delete columns (dna-column-delete), insert padding characters (dna-column-insert-pad), go forward (dna-forward-base) and backward (dna-backward-base) one base at a time. Another very cute feature is (dna-guess-format), which will try to guess the format (e.g. fasta) of the sequence you are looking at.

So cool. So cool.
A user of mine needed to do searches on DNA sequences, one of the searches is looking for restriction fragments. I came up with the following to search for the sequence "ACGT", even if the sequence spanned lines:

(C-M-s runs the command isearch-forward-regexp)

C-M-s A[ ]*C[ ]*G[ ]*T

Yeah, it works. It's ugly. Ugly isn't good.

So, did a little search on google and found dna-mode.el (local). Oh wow, it's so cool, a mode for viewing and editting DNA! It works really really nicely. To use it, put dna-mode.el in your load-path and add the following to your .emacs: ;; DNA mode (autoload 'dna-mode "dna-mode" "Major mode for dna" t) (add-to-list 'auto-mode-alist '("\\.\\(fasta\\|fa\\|exp\\|ace\\|gb\\)\\'" . dna-mode)) (add-hook 'dna-mode-hook 'turn-on-font-lock) ; Make isearch prettier (not needed, but nice) (make-face 'isearch) (set-face-background 'isearch "yellow") (setq-default search-highlight t)

NOW! Instead of isearch-forward, run M-x dna-isearch-forward. This isearch will ignore padding characters, newlines, and other cruft.

This mode also has a really nice font-lock mode, makes looking at fasta files more pleasant. The above code snippet will automatically fontify DNA files.

Also very nice in the mode is: (dna-complement-region), this complements the DNA in your current region.

You can also delete columns (dna-column-delete), insert padding characters (dna-column-insert-pad), go forward (dna-forward-base) and backward (dna-backward-base) one base at a time. Another very cute feature is (dna-guess-format), which will try to guess the format (e.g. fasta) of the sequence you are looking at.

So cool. So cool.
As a humble priest in the order of Emacs, I try to do everything I can to convert users from the dark side to the light. One such occasion occurred recently, and I was asked "Can emacs use the Windows keybindings for cut, copy, paste? (C-x, C-c, C-v)". Of course, this is heresy, but instead of calling for a jihad, I simply said "Of course it can!". A quick web search later, and I had found CUA-mode. Here is a local link to the .el file. To activate it, add the following lines to your .emacs file:
 ;; CUA mode (load "cua-mode") (CUA-mode t) 
This mode is interesting, since it doesn't just rebind C-x, C-c and C-v, you can still use these important keys for running your favorite emacs commands, instead it uses complex waits to see if you really wanted to run a command, rather than cut, copy or pasting.

Cool, but it's still heresy! C-k, C-y, C-x r k, these are the commands of the faithful! Long live the Jihad! :)
To reread your .emacs file, type:

M-x load-file ~/.emacs

To make a function which does this:
 defun nu-source () "Reread ~/.emacs." (interactive) (load-file "~/.emacs")) 
A story about the new features coming in Emacs 21. Mmmmm, Emacs 21, more filling, still tastes great. Hmmm, I don't know about some of the changes though, like changing the "+" and "-" signs in speedbar mode to folder icons... One thing that I really really want is for a transparent background window in X (real X, not an Eterm running emacs -nw). I have some sweet white backgrounds at home. This new version is almost there, since you can run color in a terminal window, but still not quite as good. Grey90 will remain my background color choice.
When using C-s to search, try pressing C-w to jump the point position ahead a word at a time. Sweet! (Thanks for this to cfjell)
gud mode in emacs rocks (M-x gdb). I'm trying to find a way to do sort of what ddd does, by having a data display buffer within emacs. GDB has the -epoch option, which looks like it almost does this, but looks like it was abandoned in 1991. Hmmm. It would be very nice to have this display buffer in emacs, and would be nice to have a better gdb interaction mode. Hmmm...
C-x v v is my good friend now. I can check code into CVS anytime I want in Emacs, and the more the better, because you can find and get back those transient code changes that sometimes happen...
Do you use M-x gdb? If you're a C or C++ coder, you should check it out. Originally written by ESR, gud.el is a pretty nifty little lisp file that will act as an interface to GDB to help you debug your programs.

Sweet things like:



The ==> shows you where you are stepped to in the code. Would be nice to have breakpoints show up as well.
ISWITCH! We all need this

ISWITCH! We all need this emacs package, called iswitch.el, which makes switching buffers with C-x b infinitely faster and more efficient. It uses telepathy and telluric currents to help you decide exactly what buffer you want to look at next. It will shock you, it will amaze you. Now, when you press C-x b to switch buffers, a list of all possible buffers will appear, with the currently active one highlighted in blue. You can move forward and backward through this list with C-s and C-r. Now, if you type a few characters, iswitch mode will only show you files that match that pattern.



Cool, eh?!

So, here download the lisp code and install it. I use the following in my .emacs file


;; iswitch
(autoload 'iswitchb "iswitchb" "Run iswitchb" t)
(setq read-buffer-function 'iswitchb-read-buffer)
(setq iswitchb-default-method 'samewindow)
(iswitchb-default-keybindings)
C-M-l Scroll heuristically to bring

C-M-l Scroll heuristically to bring useful information onto the screen (`reposition-window').

Sweet! Very useful in gud-mode.
Info Mode




hInvoke the Info tutorial.


qQuit Info: reselect previously selected buffer.



Selecting other nodes:


mouse-2


Follow a node reference you click on.


This works with menu items, cross references, and


the "next", "previous" and "up", depending on where you click.


RETFollow a node reference near point, like mouse-2.


nMove to the "next" node of this node.


pMove to the "previous" node of this node.


uMove "up" from this node.


mPick menu item specified by name (or abbreviation).


Picking a menu item causes another node to be selected.


dGo to the Info directory node.


fFollow a cross reference. Reads name of reference.


lMove to the last node you were at.


iLook up a topic in this file's Index and move to that node.


,(comma) Move to the next match from a previous `i' command.


tGo to the Top node of this file.


>Go to the final node in this file.


[Go backward one node, considering all nodes as forming one sequence.


]Go forward one node, considering all nodes as forming one sequence.



Any questions?
A nice trick found on the net to scroll up and down one line in a emacs buffer. Very nice. Binds to the usual scroll-up and scroll-down keys C-v and M-v.

 
; scroll one line at a time
(defun scroll-one-line-up (&optional arg) "Scroll the selected window up (forward in the text) one line (or N lines)." (interactive "p") (scroll-up (or arg 1)))
(defun scroll-one-line-down (&optional arg) "Scroll the selected window down (backward in the text) one line (or N)." (interactive "p") (scroll-down (or arg 1)))
; Bind these functions (substitute your favorite keys for mine)
(global-set-key "\M-v" 'scroll-one-line-up) (global-set-key "\C-v" 'scroll-one-line-down)
As an addendum to the tip of yesterday, I find the following keybinding a little more comfortable:
 (global-set-key "\C-b" 'scroll-one-line-up) (global-set-key "\C-v" 'scroll-one-line-down) 
C-b is usually used to go backward one character, but I like it rebound to this.
Wow. Emacs just "wowed" me again. I'd used the mode terminal.el before, but now just played with it some more and found out how powerful it is. Wow.

To enable terminal mode type M-x terminal-emulator. Emacs will ask you what command you want to run, with a default as your login shell (e.g. tcsh). After you press return, Emacs will make a new buffer named *terminal* that will act just like a normal terminal window. However, this means that you can't use your normal Emacs control characters, ctrl-c will be sent right to the terminal, which is very cool since you can run any console program just like as if you were in a terminal.

So, the trick is the key sequence C-^ which will let you enter extended commands into emacs. The most useful is C-^ ? which will give you a nice help screen. Other useful ones are C-^ o which will switch you to another window in the current frame, another is C-^ b which will allow you to switch to another buffer. (Even more useful with iswitch.el which I talked about a few days ago).

Cool, eh!?!
An even nicer keybinding


 (global-set-key [M-down] 'scroll-one-line-up[) (global-set-key [M-up] 'scroll-one-line-down) 
This rebinds scroll up and down to Meta-down and Meta-up. (This looks reversed, but feels right to the fingers)
 ;; insert the current xmms song into the buffer (defun xmms-current () "xmms-shell" (interactive) (shell-command (concat "perl -MXmms -e current ") 1)) 

(global-set-key [f4] 'xmms-current)
I've just found a cool

I've just found a cool mode, remember.el that is a "mode for remembering data". There are big modes, like Hyperbole and BBDB that help you to remember things, but they're big and complicated. Remember is small and cute and very useful. I have it bound to [f6] and [f7], that respectively open remember mode and remember a region. Once in the remember buffer, press C-c C-c to remember what you've just typed.

Remember.el saves data to a file called .notes in your home directory. Each time you remember something it saves the current time and date, a guessed "title" for the remembrance, and the text you entered. I've also got [f5] bound to "find out what xmms song you are currently listening to and remember it". This rocks, I just press [f5] and it saves what current somafm song I'm listening to, so that I can find it on napster later. Here's my .emacs section to do all this:
 ;; ;; Remember mode ;; (autoload 'remember "remember" nil t) (autoload 'remember-region "remember" nil t)

(define-key global-map [f6] 'remember) (define-key global-map [f7] 'remember-region) (setq remember-use-bbdb nil)

;; insert the current xmms song into the buffer (defun xmms-current () "xmms-shell" (interactive) (shell-command (concat "perl -MXmms -e current ") 1))

(global-set-key [f4] 'xmms-current)

(defun xmms-insert-remember () "xmms-insert" (interactive) (remember) (xmms-current) (remember-append-to-file) (kill-buffer (current-buffer)) (jump-to-register remember-register))

(global-set-key [f5] 'xmms-insert-remember)
ddd is one of the

ddd is one of the coolest debugging front ends around, but I love gud mode in emacs. Which one should I choose?

The answer of course, is BOTH!

M-x gdb

debugger command : ddd --tty

This works very nicely in enlightenment, you can get windows to "remember" where they are supposed to popup, so I have a 1280x1024 emacs window, then in the desktop area just below it, I have a 1280x1024 gdb with just the data display window turned on. It's a thing of beauty.
/usr/bin/ddate

 /usr/bin/ddate 
I love ange-ftp mode in emacs, if you haven't heard about it yet, get thee hither to C-h i!. ange-ftp allows you to access remote files as if they were local on your machine. It uses FTP (and some funky tricks) to do this, using the format:
 /USER@HOST:FILENAME 
You can edit directories with dired, save files, do lots of funky things. However, it uses FTP, which isn't that secure, since FTP sends your password in cleartext over the network. What to do!

Well, get TRAMP(Transparent Remote (file) Access, Multiple Protocol). It feels very similar to ange-ftp, but instead of using FTP, it can use a wide variety of protocols, the most interesting of which is ssh1/ssh2.

To install it, get the .tgz file, uncompress it in your ~/emacs-extras directory, and put the following into your .emacs file:
 ;; ;; Tramp ;; (add-to-list 'load-path "~/emacs-extras/tramp/") (setq tramp-default-method "sm2") (require 'tramp) 
To use it, type:
 C-x C-f /r:hostname:~/filename 
Simple and fun!
I find typing M-x compile to take too long, so I've defined the following two keys to compile and recompile my programs, respectively:
 (global-set-key [f11] 'compile) (global-set-key [f12] 'recompile) 
stty is your friend. stty (man stty) allows you to set your "terminal line settings". When you are using a shell in a window, that window is showing you a terminal.

There are a bunch of important stty settings that should be set, most get set by default. One that sometimes doesn't is
 stty erase ^H 
If you have ever been trying to delete characters on the command line with backspace, or when you try to backspace in less or more, and all you see is a whole bunch of ^H^H^H^H^H, this stty setting isn't set.

Another super cool one that I just found stty very useful for was in the mysql client. I instinctively would press ctrl-C to cancel a command, in the mysql client, this issues the quit command. So, undaunted, I just did the following, which emulates pretty closely the behaviour I really want:
 stty intr ^t stty kill ^c 
This resets the Interrupt signal (intr) to a key I don't use very much, ctrl-t, and sets ctrl-c to kill, which deletes the current line.

Neat, eh?
So, you have a file with really really really long lines, with columnar data and you want to look at this file in a structured manner. What do you do? Start up, emacs, that's what! :)

But, when you start up emacs, it wraps all your lines, and your really really really long lines with columnar data are all wrapped on the screen and you can't see what's going on and you're getting irritated, and more irritated and you start to scream....

Well, just chill out, go do some Yoga.

Then, type the following into emacs:


 M-x set-variable truncate-lines t 
There, better already, isn't it. :).

Then, to scroll backwards and fowards, use the commands M-x scroll-left and M-x scroll-right which are conveniently bound to the keys C-x
< and C-x >.

Ahh, now, isn't that better?
In xemacs, to show the buffer with all the error messages in it:

M-x show-message-log
When you get the pesky problem of having software that installs itself via tar into various libs, here's a tricK:

make a new directory and untar the tar file properly in here, redirecting the file names generated to a temp file.
 tar xvzf archive-name.tgz /usr/sness 
< filenames.tmp

open this file in emacs, and use M-x query-replace to make the file into commands.
 clear ; ps -auwwx | head -1 ; ps -auwwx | grep string

add to your .[t]chsrc
 alias c clear alias cdc cd ; clear 

Saturday, December 9, 2006

There was a recent post on technomancy.us about rinari.el is an interesting mode for interacting with Ruby on Rails projects with Emacs.

I've been playing around with
rhtml-mode.el, and it's making working with the .rhtml files from Rails a bit nicer. Still, the indenting of .rhtml files isn't optimal, it just indents the HTML, not the embedded Ruby code. Still, it's better than standard html-mode for working with .rhtml code, and I think it's worth checking out.

It looks like the rinari rhtml-mode.el is an enhanced version of the old rhtml-mode.