Maneuvering the Xemacs BufferYou are sitting in your cubicle admiring the perfect weather outside, waiting for your boss to bring in the new client. Everything is going just swell. Then it happens. A glitch occurs in the space-time continuum. The vortex rips through your masterful work and the work of an infinite number of quantum copies of you in parallel universes. Bits of code are scattered through the infinite universes. Your binary is wrecked beyond repair. The code is intermixed with the less sophisticated work of your Dopplegangers in parallel worlds. Your boss had told you if anything goes wrong with the demo, she'll wave her magic wand and turn you into a frog and revoke the health insurance clause from your contract. A frog? How are you going to get home? Nevermind that. What are you going to tell your wife about the the family health insurance plan? You know how she gets. You can hear footsteps and chatter in the hall. Oh my God, they're here! It's over. You can feel the sheer panic tearing through your body. What are you going to do? Calm down. You've been training for this your whole life. You are an Xemacs wizard. A few brief keystrokes and you can repair the entire source in just seconds. First you note that you cannot use the mouse. You're ssh'd into a remote machine through the console. It's going to have to be done using only command keys. You quickly scan your eyes over the buffer and observe the damage. Then you lay out a plan of attack to maneuver the buffer and fix the text. Your cursor is located at the red brace. The highlighted text needs to be repaired. (Also, note the missing text in main, which, unfortunately, does not appear highlighted in my browser.) #include <stdio,h> char *helloworld(void); int main(void) { puts(helloworld()) char *helloworld(boid) { return "hello world"; } /* Print 'hello world' to stdout. */ The following sequence of keystrokes will get you from the opening brace to just beyond the only statement in main. It takes only a handful of keys to get there, repair the semicolon, return statement, and right brace.
#include <stdio,h> char *helloworld(void); int main(void) { puts(helloworld()); return 0; } char *helloworld(boid) { return "hello world"; } /* Print 'hello world' to stdout. */ Next, you need to change boid to void. You have no idea what the programmer who typed boid was thinking, but it doesn't matter. It takes only three keys to get there and three more to correct the problem.
#include <stdio,h> char *helloworld(void); int main(void) { puts(helloworld()); return 0; } char *helloworld(void) { return "hello world"; } /* Print 'hello world' to stdout. */ The comment at the end needs to be moved to the top. For now, you just need to move the text to the kill ring. You can get there in three strokes. Mark the start of the text. Move to the end in two strokes. And cut with just two more strokes. It's just two remaining strokes to return to the start of the buffer.
#include <stdio,h>
char *helloworld(void);
int main(void)
{
puts(helloworld());
return 0;
}
char *helloworld(void)
{
return "hello world";
}
/*
Print 'hello world' to stdout.
*/
They're entering the room, but you're nearly done. Move to the end of the line. Backup to the semicolon which should be a period. Just delete the last few characters; it will only take a fraction of a second to retype them. Finally, move to the next line and yank the text back from the kill ring. You're done. But there's still a half second before the client meets you. So you kill a few lines to remove superfluous whitespace.
#include <stdio.h> /* Print 'hello world' to stdout. */ char *helloworld(void); int main(void) { puts(helloworld()); return 0; } char *helloworld(void) { return "hello world"; } Recompile. Success! You will not be a frog today. I frequently use the arrow keys instead of C-p, C-n, C-b, C-f to move around in the buffer. Our hero went the other route, but using arrow keys is OK if they're supported. I also compile in a terminal window instead of Xemacs. You can do this quickly by typing Alt-Tab and then the up key, followed by <RET>, assuming you just ran a compile. |