============================================================================ RSemacs - Richard Shiao's Emacs Customization README.txt ============================================================================ --------------------------------- Contents --------------------------------- 1. About 2. Install 3. Customize 4. Uninstall 5. Features 6. Notes 7. Credits 8. Copyright --------------------------------- 1. About --------------------------------- RSemacs is a collection of files that you can use to customize Emacs. It is currently tested with GNU Emacs version 21.2. It consists of the following files: - RS_program.el - settings for program behavior - RS_colors.el - settings for color coding text - RS_keys.el - settings for keyboard and mouse key bindings Changes them to be more like the PC, but not really, since most emacs keyboard shortcuts are retained. - RS_keys_fullPC.el - attempts to go more fully PC with keyboard shortcuts, but there are some workarounds neccessary. See notes below for details. - RS_keys_fullPC_local.el - local redefinitions for settings in RS_keys_fullPC, which loads this file automatically. You do not need to manually load this file. For details about the settings that each file changes, please open that file and read its comments. The comments describe how to use or change the settings. They also may explain what conventions the settings follow (or break). You can install just all RSemacs files, or select just a few. --------------------------------- 2. Install --------------------------------- 1. Place the RSemacs directory in your home directory. On Unix, this is ~. On the PC, you can find out where your home directory is by opening and saving the file ~/.emacs. Search for .emacs and you'll probably find it in a place like C:\ 2. Open your .emacs file, which should be under your home directory ("~/.emacs"). If it doesn't exist, create a new text file called ".emacs" and put it in your home directory. 3. After the last line of your .emacs file, add these lines: (load-file "~/RSemacs/RS_program.el") (load-file "~/RSemacs/RS_colors.el") (load-file "~/RSemacs/RS_keys.el") (load-file "~/RSemacs/RS_keys_fullPC.el") 4. For components you do not want to install, just comment out the line. For example, if you want everything but the extra PC bindings that overwrite default emacs shortcuts, you would use: (load-file "~/RSemacs/RS_program.el") (load-file "~/RSemacs/RS_colors.el") (load-file "~/RSemacs/RS_keys.el") ;; (load-file "~/RSemacs/RS_keys_fullPC.el") Notice the semicolons on the last line. That's how you comment out code in Emacs Lisp. Also, you do not need to load RS_keys_fullPC_local since that is just a helper file used by RS_keys_fullPC. 5. Save your .emacs file and restart Emacs. --------------------------------- 3. Customize --------------------------------- These files contain settings that work for me, but you may wish to tweak some settings to meet your own needs. To do so, read the comments and adjust the values of the settings accordingly. If you create your own files, you can install them the same way as described above. --------------------------------- 4. Uninstall --------------------------------- 1. Open your .emacs file 2. Delete or comment out the lines you don't want anymore (see above). 3. Save your .emacs file and restart Emacs. --------------------------------- 5. Features --------------------------------- This section lists the features of RSemacs. It is broken up into three parts, one for each file. Asterisks denote features that I'm still working on. If you figure out how to implement them, let me know. =) ------------------------------- 5.1 - RS_program.el ------------------------------- - Debugging on error - Version check - Setting home directory - Append user's own lisp directory to load path - Silent the bell - Confirm Emacs exit - Text mode - Set kill ring - Turn on auto save - Set auto save character interval - Settings for backup files and versions - Transient-Mark mode - Auto-Fill mode - Set width for automatic newline insertion - Long lines go off screen to the right - Scroll down 1 line at a time rather than a huge section - Context lines setting, if you want to scroll by huge section or page - Keep cursor on same line of screen (though not of the file as I'd like) - Don't add more lines when scrolling past end of buffer - Resize mini-buffer automatically - Substitute yes/no responses to y/n - Specify tab width - Substitute tabs with spaces - Search is not case-sensitive * Enable Abbreviations - End files with a newline character - Format window and icon bar titles - Show name of current function in modeline - Show column number in modeline - Clock - Saving the Emacs Desktop, Opens files from last session upon starting. (Note: You must first enable this feature by using "Alt-x", then "desktop-save") ------------------------------- 5.2 - RS_colors.el ------------------------------- - Enable Font Lock Mode - Show matching parentheses on cursor-over too - Colors for specific faces, along with directions for setting your own ------------------------------- 5.3 - RS_keys.el ------------------------------- Note: There are a lot of keyboard shortcut bindings listed here, but read through them carefully and you'll see there are some useful functions! Note: These shortcuts imitate PC style shortcuts, but precede them with C-c. It is Emacs convention to use C-c as custom user-defined shortcuts. That way, your default Emacs shortcuts are still operational. Example: "Cut" is Ctrl-c, then x. It's not simple Ctrl-x as it is in PCs. This way, all commands that begin with Ctrl-x still work. For instance, to open files, it's still Ctrl-x Ctrl-f. Also, you could still use the default emacs shortcut for "Cut", which is Ctrl-w. Note: If you want to go fully PC, you should load RS_keys_fullPC.el after you load this file. That file overwrites some settings in this file. - Complete Listing: PC-style key bindings and selection - Ctrl-c n - New file / Open file - Ctrl-c o - Open file / New file - Ctrl-c s - Save file - Ctrl-c w - Close current buffer - Ctrl-c q - Quit Emacs - Ctrl-c z - Undo - Ctrl-c x - Cut - Ctrl-c c - Copy - Ctrl-c v - Paste - Ctrl-c a - Select All - Ctrl-c f - Find, Find Again - Delete key - delete forward (included in pc-mode) - Shift-arrow - select regions of text (included in pc-mode) - Ctrl-arrow - skip over whole words or paragraphs (included in pc-mode) - Ctrl-Backspace - delete whole word (included in pc-mode) Other keyboard shortcuts - Shift-Tab - completes abbreviated words - Ctrl-PgUp - scrolls other buffer up - Ctrl-PgDn - scrolls other buffer down - Ctrl-Tab - switches between buffers (see function) - Ctrl-i - Indent regions - Ctrl-e - Center line Function keys - f1 - Help - Shift f1 - Man - f2 - Save Buffer * - Shift f2 - Save All Buffers - f3 - Open - Shift f3 - Open .emacs - f4 - Close Buffer * - Shift f4 - Save All and Quit - f5 - Compile - f6 - Next Error - Shift f6 - First Error - Ctrl f6 - Previous Error - f7 - GoTo Line - f8 - Comment Region - Shift f8 - Uncomment Region - f9 - Indent Region - f10 - One Window - Shift f10 - Two Windows (Top and Bottom) - Ctrl f10 - Two Windows (Left and Right) - f11 - Switch Window * - f12 - Start/End Keyboard Macro - Shift f12 - Name Last Keyboard Macro - Ctrl f12 - Call Last Keyboard Macro Disabled keys - Disable S-backspace (not implemented, but maybe longer needed?) Mouse Bindings - Drag scroll bar with Mouse-1 - Select from completion list with Mouse-1 - Select from Buffer Menu with Mouse-1 - Show Context-Sensitive Menu with Mouse-2 ------------------------------- 5.4 - RS_keys_fullPC.el ------------------------------- - This file is intended to go fully PC style for the keyboard shortcuts. - It extends the features in RS_keys.el so you should load that file first, before loading this one. - This file basically rids the extra Control-c before the PC shortcuts (found in RS_keys.el). Thus, we have the following true PC Style key bindings: - Ctrl-n - New file / Open file - Ctrl-o - Open file / New file - Ctrl-s - Save file - Alt-s - Save As... - Ctrl-w - Close current buffer - Ctrl-q - Quit Emacs - Ctrl-z - Undo - Ctrl-y - Redo (currently disabled. get package, then uncomment) - Ctrl-x - Cut - Ctrl-c - Copy - Ctrl-v - Paste - Ctrl-a - Select All - Ctrl-r - Replace string - Ctrl-f - Find, Find Again - Alt-f - Find Backwards, Find Again Backwards - However, the result of these assignments is that some default Emacs shortcuts are no longer accessible. If you never use those shortcuts, then you have nothing to worry about anyway. But if you do (like Ctrl-x 1 to go to one window), then some reassignment is needed, since Ctrl-x is already taken by "Cut". - Here are the reassignments: Function Old Emacs Shortcut New PC Style Shortcut - New C-x C-f Ctrl-n - Open C-x C-f Ctrl-o - Save C-x C-s Ctrl-s - Close C-x k Ctrl-w - Quit C-x C-c Ctrl-q - One Window C-x 1 Ctrl-1 - Split Windows Top/Bottom C-x 2 Ctrl-2 - Split Windows Left/Right C-x 3 Ctrl-3 - Go to beginning of line C-a Home - Suspend C-z (ignored) - Forward one character C-f Right Arrow - If you use other commands, you can add reassigments in the code. - Known Bugs (still being debugged): - These key bindings all work when in Text mode. But there are some inconsistencies when you use other modes, like C and Java mode. Specifically, some PC-bindings revert to their Emacs defaults. For example, Ctrl-c is supposed to be "Copy". But in Java mode, Ctrl-c is used to precede other shortcuts, so it's no longer tied to "Copy". - The "clipboard" doesn't quite work like it does in Notepad. Almost does. But when you select text with the mouse, that stuff goes into the kill ring (not a clipboard). Thus, any pasting thereafter won't work like it does in Notepad. - I think these bugs should be pretty easy to fix, but I just haven't around to them. If you figure out how to fix them, please let me know. - Lastly, this extension is mainly for those PC users who have to / want to use Emacs, but don't want to use the default Emacs shortcuts. This file does a pretty good job of accommodating PC bindings. However, as stated in the Emacs Tutorial, maybe you actually want to learn the Emacs shortcuts, as that can result in smoother and faster typing. So yeah, it's a toss up; either you: 1) Use PC bindings because that's what you're used to. You keep just one convention whether you work with Emacs or other PC applications. Or... 2) Take time to learn Emacs shortcuts and the idea is that you'll be more efficient in your typing. But then, when you switch to PC applications, you'll need to switch your frame of reference. You'll need to juggle two different conventions. ------------------------------- 5.5 - RS_keys_fullPC_local.el ------------------------------- - This file is loaded automatically, within RS_keys_fullPC. You do not need to manually load this file. However, you do need to make sure all your global definitions appear here as well (word for word, except for using "local-set-key" instead of "global-set-key"). In addition, you need to make sure you add the appropriate "add-hook" commands at the bottom of RS_keys_fullPC. - The settings in RS_keys_fullPC apply globally, but will be overwritten when you load local settings for different modes like C-mode, Java-mode, etc. For example, in Java mode, Control-c is used to for other stuff, so it's no longer tied to "Copy" as you'd expect. - To fix that, we redefine keybindings locally for those modes using the keyword "local-set-key". - If you run into additional issues with local modes overwriting your global settings, don't forget to check back here and make sure you added a local redefinition. --------------------------------- 6. Notes --------------------------------- Customizing: In addition to using a .emacs file, you can use Options/Customize menu to change settings like colors and user personal information Help: F1 (or C-h if it was not overwritten) Mode Help: C-h m Look under the Help/Manuals menu for detailed information. The FAQ file is a useful place to start. Macros: Start with F12. Type macro. Finish with F12. M-x name-last-kbd-macro to name macro. M-x call-last-kbd-macro to execute. M-x insert-kbd-macro followed by the name to insert the key sequence equivalent into your code for your .emacs file. (This is very useful if you are unfamiliar with the key binding syntax). Compiling: Byte compile .el files to make emacs load faster. Select "Byte Compile This File" under the Emacs-Lisp menu. Compile it as .NameOfFile.elc and then put (load-file "~/.NameOfFile.elc") in your normal .emacs file (where NameOfFile is any name you choose). To Do: - Get hook to work for HTML mode - Fix mouse selection so that it does not automatically put stuff in the "clipboard" (kill ring). - Fix redo with C-y. - Keep cursor where it is when scrolling. - Add a key to toggle PC-style bindings. Problem right now, is how to deal with hooks already added to the local modes. - Fix the 4 starred items. --------------------------------- 7. Credits --------------------------------- Here is a basic list of where some of my ideas came from. Much thanks! Ingo Koch - This person maintains a whole website devoted to .emacs files. It's current and useful. Check it out at: www.dotemacs.de Great resource! Oleg Alexandrov - good information about key bindings, isearch reassignment, and adding hooks for local modes. I recommend this site. It would have helped me out a lot if it existed when I was just starting out learning how to customize .emacs files. Steve Ackermann - where I learned of the simple two line setting that enables PC style selection and bindings. However, not all PC shortcuts were included so I added them. Steve Dodd - useful mouse and keyboard bingdings. Young-il Choo - wrote the funcion for Control-Tab swithching between buffers. Very convenient. As a side note, I also see it all over the place in many different people's files. Some people tried to pretend they wrote it themselves, even with the function still named with its real author's initials: "yic-next-buffer". Haha. Jayakrishnan Nair - Debug-on-error and writing progress messages to the Message buffer. I don't use it, but it's nice to know it's there if I ever want to. Jason Rumney - Bind Mouse-2 to a pop-up menu. Cool... I don't use mouse-2 to paste anyway. Additional settings from class.emacs, made for EECS @ UC Berkeley And James Chung, who, if I recall correctly, was the person through which I found out about the existence of the .emacs file and what it's for. That was way back in CS61B. =P Spring 2000. man, time flies. --------------------------------- 8. Copyright --------------------------------- (c) Copyright 2000, 2001, 2002, 2003 Richard Shiao. I made these files for personal use, but I think other people will find them useful as well, so I'm sharing them. +-------------------------------------------------------+ | Feel free to use, modify, and distribute these files, | | as long you include this block of text so that others | | can refer to the originals if they need. To see the | | original files (RSemacs, created 2000-06-01), visit: | | http://www.geocities.com/IntroToEECS/ | +-------------------------------------------------------+