Language-Sensitive Editing


The emacs editor has a large collection of feature sets, each specific to a certain variety of text. The feature sets are called Major modes. A buffer can have only one Major mode at any time.

A buffer's Major mode is private to the buffer and does not affect editing in any other buffer. If you switch to a new buffer having a different mode, rules for the new mode immediately take effect. To avoid confusion, the name of a buffer's Major mode appears in the Mode Line of any window viewing that buffer (Figure 7-1 on page 202).

The three classes of Major modes are used for the following tasks:

  • Editing human languages (for example, text, nroff, TeX)

  • Editing programming languages (for example, C, Fortran, Lisp)

  • Special purposes (for example, shell, mail, dired, ftp)

In addition, one Major modeFundamentaldoes nothing special. A Major mode usually sets up the following:

  • Special commands unique to the mode, possibly with their own key bindings. Languages may have just a few special commands, but special-purpose modes may have dozens.

  • Mode-specific character syntax and regular expressions defining word constituent characters, delimiters, comments, whitespace, and so on. This setup conditions the behavior of commands oriented to syntactic units, such as words, sentences, comments, or parenthesized expressions.

Selecting a Major Mode

META-x modename

The emacs editor chooses and sets a mode when a file is called up by matching the filename against a set of regular expression patterns describing the filename and filename extension. The explicit command to enter a Major mode is META-x modename. This command is rarely used except to correct wrong guesses.

A file can define its own mode by including the text * modename * somewhere in the first nonblank line, possibly inside a comment suitable for that programming language.

Human-Language Modes

A human language is meant eventually to be used by humans, possibly after being formatted by some text-formatting program. Human languages share many conventions about the structure of words, sentences, and paragraphs. With regard to these textual units, the major human language modes all behave in the same way.

Beyond this area of commonality, each mode offers additional functionality oriented to a specific text formatter, such as TeX, LaTeX, or nroff. Text-formatter extensions are beyond the scope of this presentation; the focus here is on the commands relating to human textual units (for example, words, sentences, and paragraphs).

Words

As a mnemonic aid, the bindings for words are defined parallel to the character-oriented bindings CONTROL-F, CONTROL-B, CONTROL-D, DELETE, and CONTROL-T.

Just as CONTROL-F and CONTROL-B move forward and backward over characters, META-f and META-b move forward and backward over words. They may start from a position inside or outside the word to be traversed, but in all cases Point finishes just beyond the word, adjacent to the last character skipped over. Both commands accept a numeric argument specifying the number of words to be traversed.

Just as CONTROL-D and DELETE delete characters forward and backward, the keys META-d and META-DELETE kill words forward and backward. They leave Point in exactly the same finishing position as META-f and META-b do, but they kill the words they pass over. They also accept a numeric argument.

META-t transposes the word before Point with the word after Point.

Sentences

As a mnemonic aid, three of the bindings for sentences are defined parallel to the line-oriented bindings: CONTROL-A, CONTROL-E, and CONTROL-K. The META-a command moves backward to the beginning of a sentence, and META-e moves forward to the end of a sentence. In addition, CONTROL-X DELETE kills backward to the beginning of a sentence; META-k kills forward to the end of a sentence.

The emacs editor recognizes the ends of sentences by referring to a regular expression that is kept in a variable named sentence-end. (If you are curious, give the command CONTROL-H v sentence-end RETURN to view this variable.) Briefly, it looks for the characters ., ?, or ! followed by two SPACEs or an end-of-line marker, possibly with close quotation marks or close braces.

The META-a and META-e commands leave Point adjacent to the first or last nonblank character in the sentence. They accept a numeric argument specifying the number of sentences to traverse; a negative argument runs them in reverse.

The META-k and CONTROL-X DELETE commands kill sentences forward and backward, in a manner analogous to CONTROL-K line kill. They leave Point in exactly the same finishing position as META-a and META-e do, but they kill the sentences they pass over. They also accept a numeric argument. CONTROL-X DELETE is useful for quickly backing out of a half-finished sentence.

Paragraphs

The META-{ command moves backward to the most recent paragraph beginning, and META-} moves forward to the next paragraph ending. The META-h command marks the paragraph (that is, puts Point at the beginning and Mark at the end) that the cursor is currently on, or the next paragraph if it is between paragraphs.

The META-} and META-{ commands leave Point at the beginning of a line, adjacent to the first character or last character of the paragraph. They accept a numeric argument specifying the number of paragraphs to traverse and run in reverse if given a negative argument.

In human-language modes, paragraphs are separated by blank lines and text-formatter command lines, and an indented line starts a paragraph. Recognition is based on the regular expressions stored in the variables paragraph-separate and paragraph-start. A paragraph is composed of complete lines, including the final line terminator. If a paragraph starts following one or more blank lines, the last blank line before the paragraph belongs to the paragraph.

Fill

The emacs editor can fill a paragraph to fit a specified width, breaking lines and rearranging them as necessary. Breaking takes place only between words and no hyphenation occurs. Filling can be done automatically as you type or in response to an explicit command.

The META-x auto-fill-mode command toggles Auto Fill mode on and off. When Auto Fill mode is on, emacs automatically breaks lines when you press SPACE or RETURN and are currently beyond the specified line width. This feature is useful when you are entering new text.

Auto Fill mode does not automatically refill the entire paragraph you are currently working on. If you add new text in the middle of a paragraph, Auto Fill mode breaks your new text as you type but does not refill the complete paragraph. To refill a complete paragraph or Region of paragraphs, use either META-q to refill the current paragraph or META-x fill-region to refill each paragraph in the Region between Point and Mark.

You can change the filling width from its default value of 70 by setting the fill-column variable. Use CONTROL-X f to set fill-column to the current cursor position and CONTROL-U nnn CONTROL-X f to set fill-column to nnn, where 0 is the left margin.

Case Conversion

The emacs editor can force words or Regions to all uppercase, all lowercase, or initial caps (the first letter of each word uppercase, the rest lowercase). Refer to Table 7-14.

Table 7-14. Case conversion

Command

Result

META-l (lowercase "l")

Converts word to the right of Point to lowercase

META-u

Converts word to the right of Point to uppercase

META-c

Converts word to the right of Point to initial caps

CONTROL-X CONTROL-L

Converts the Region (between Point and Mark) to lowercase

CONTROL-X CONTROL-U

Converts the Region (between Point and Mark) to uppercase


The word-oriented conversions move Point over the word just converted (just as META-f does), allowing you to walk through text and convert each word with META-l, META-u, or META-c, or skip over words to be left alone with META-f. A positive numeric argument converts that number of words to the right of Point, moving Point as it goes. A negative numeric argument converts that number of words to the left of Point but leaves Point stationary. This feature is useful for quickly changing the case of words you have just typed. Table 7-15 shows some examples.

Table 7-15. Examples of case conversion

Characters and commands

Result

HELLOMETA-META-l (lowercase "l")

hello

helloMETA-META-u

HELLO

helloMETA-META-c

Hello


The word conversions are not picky about beginning in the middle of a word. In all cases, they consider the first word-constituent character to the right of Point as the beginning of the word to be converted.

Text Mode

With very few exceptions, the commands for human-language text units, such as words and sentences, are always turned on and available, even in the programming-language modes. Text mode adds very little to these basic commands but is still worth turning on just to get the TAB key. Use the command META-x text-mode to activate Text mode.

In Text mode TAB runs the function tab-to-tab-stop. By default TAB stops are set every eight columns. You can adjust them with META-x edit-tab-stops, which switches to a special *Tab Stops* buffer. The current stops are laid out in this buffer on a scale for you to edit. The new stops are installed when or if you type CONTROL-C CONTROL-C. Of course, you are free to kill this buffer (CONTROL-X k) or switch away from it (CONTROL-X b) without ever changing the stops.

The tab stops you set with the META-x edit-tab-stops command affect only the interpretation of TAB characters arriving from the keyboard. The emacs editor automatically inserts enough spaces to reach the TAB stop. This command does not affect the interpretation of TAB characters already in the buffer or the underlying file. If you edit the TAB stops and then use them, you can still print the file and the hard copy will look the same as the text on the screen.

C Mode

Programming languages are read by humans but are interpreted by machines. Besides continuing to handle some of the human-language text units (for example, words and sentences), the major programming-language modes address several additional problems:

  • Balanced expressions enclosed by parentheses, brackets, or braces as textual units

  • Comments as textual units

  • Indention

The emacs editor includes Major modes to support C, Fortran, and several variants of Lisp. In addition, many users have contributed modes for their favorite languages. In these modes the commands for human textual units are still available, with occasional redefinitions. For example, a paragraph is bounded only by blank lines and indention does not signal a paragraph start. In addition, each mode has custom coding to handle the language-specific conventions for balanced expressions, comments, and indention. This presentation discusses only C mode.

Expressions

The emacs Major modes are limited to lexical analysis. They can recognize most tokens (for example, symbols, strings, and numbers) and all matched sets of parentheses, brackets, and braces. This is enough for Lisp but not for C. The C mode lacks a full-function syntax analyzer and is not prepared to recognize all of C's possible expressions.[1]

[1] In the emacs documentation the recurring term sexp refers to the Lisp term S-expression. Unfortunately, it is sometimes used interchangeably with expression, even though the language might not be Lisp.

Table 7-16 lists the emacs commands applicable to parenthesized expressions and some tokens. By design the bindings run parallel to the CONTROL commands for characters and the META commands for words. All these commands accept a numeric argument and run in reverse if that argument is negative.

Table 7-16. Commands for expressions and tokens

Command

Result

CONTROL-META-f

Moves forward over an expression. The exact behavior depends on which character lies to the right of Point (or left of Point, depending on which direction you are moving Point).

  • If the first nonwhitespace is an opening delimiter (parenthesis, bracket, or brace), Point is moved just past the matching closing delimiter.

  • If the first nonwhitespace is a token, Point is moved just past the end of this token.

CONTROL-META-b

Moves backward over an expression.

CONTROL-META-k

Kills an expression forward. This command leaves Point at the same finishing position as CONTROL-META-f but kills the expression it traverses.

CONTROL-META-@

Sets Mark at the position CONTROL-META-f would move to but does not change Point. To see the marked Region clearly, give a pair of CONTROL-X CONTROL-X commands to interchange Point and Mark.


Function Definitions

In emacs a balanced expression at the outermost level is considered to be a function definition and is often called a defun, even though that term is specific to Lisp. More generally it is understood to be a function definition in the language at hand.

In C mode a function definition includes the return data type, the function name, and the argument declarations appearing before the { character. Table 7-17 shows the commands for operating on function definitions.

Table 7-17. Function definitions

Command

Result

CONTROL-META-a

Moves to the beginning of the most recent function definition. Use this command to scan backward through a buffer one function at a time.

CONTROL-META-e

Moves to the end of the next function definition. Use this command to scan forward through a buffer one function at a time.

CONTROL-META-h

Puts Point at the beginning and Mark at the end of the current function definition (or next function definition, if between two). This command sets up an entire function definition for a Region-oriented operation such as kill.


Caution: Function indention style

The emacs editor assumes that an opening brace at the left margin is part of a function definition. This heuristic speeds up the reverse scan for a definition's leading edge. If your code has an indention style that puts that opening brace elsewhere, you may get unexpected results.


Indention

The emacs C mode has extensive logic to control the indention of C programs. Furthermore, you can adjust this logic for many different styles of C indention (Table 7-18).

Table 7-18. Indention commands

Command

Result

TAB

Adjusts the indention of the current line. TAB inserts or deletes whitespace at the beginning of the line until the indention conforms to the current context and rules in effect. Point is not moved unless it lies in the whitespace area; in that case it is moved to the end of the whitespace. TAB does not insert anything except leading whitespace, so you can hit it at any time and at any position in the line. If you really want to insert a tab in the text, use META-i or CONTROL-Q TAB.

LINEFEED

Shorthand for RETURN followed by TAB. The LINEFEED key is a convenience for entering new code, giving you an autoindent as you begin each line.

The next two commands indent multiple lines with a single command.

CONTROL-META-q

Reindents all lines inside the next pair of matched braces. CONTROL-META-q assumes that the left brace is correctly indented and drives the indention from there. If you need to adjust the left brace type TAB to the left of the brace before giving this command. All lines up to the matching brace are indented as if you had typed TAB on each one.

CONTROL-META-\

Reindents all lines in the Region (between Point and Mark). Put Point just to the left of a left brace and then give the command. All lines up to the matching brace are indented as if you had typed TAB on each one.


Customizing Indention

Many styles of C programming have evolved, and emacs does its best to support automatic indention for all of them. The indention coding was completely rewritten for emacs version 19; it supports C, C++, Objective-C, and Java. The new emacs syntactic analysis is much more precise and can classify each syntactic element of each line of program text into a single syntactic category (out of about 50), such as statement, string, or else-clause. With the result of that analysis in hand, emacs goes to an offset table named c-offsets-alist and looks up how much each line should be indented from the preceding line.

To customize indention, you must change the offset table. It is possible to define a completely new offset table for each customized style but much more convenient to feed in a short list of exceptions to the standard rules. Each mainstream style (GNU, K&R [Kernighan and Ritchie], BSD, and so on) has such an exception list; all are collected in c-style-alist. Here is one entry from c-style-alist:

("gnu" (c-basic-offset . 2) (c-comment-only-line-offset . (0 . 0)) (c-offsets-alist . ((statement-block-intro . +)      (knr-argdecl-intro . 5)      (substatement-open . +)      (label . 0)      (statement-case-open . +)      (statement-cont . +)      (arglist-intro . c-lineup-arglist-intro-after-paren)      (arglist-close . c-lineup-arglist)      )) ) 


Constructing a custom style is beyond the scope of this book. If you are curious, the long story is available in emacs online info beginning at "Customizing C Indentation." The sample .emacs file given in this chapter (page 241) adds a very simple custom style and arranges to use it on every .c file that is edited.

Comments

Each buffer has its own comment-column variable, which you can view with the CONTROL-H v comment-column RETURN help command. Table 7-19 lists commands that facilitate working with comments.

Table 7-19. Comments

Command

Result

META-;

Inserts a comment on the current line or aligns an existing comment. This command's behavior differs according to the situation.

  • If no comment is on this line, META-; creates an empty comment at the value of comment-column.

  • If text already on this line overlaps the position of comment-column, META-; creates an empty comment one SPACE after the end of the text.

  • If a comment is already on this line but not at the current value of comment-column, META-; realigns the comment at that column. If text is in the way, it places the comment one SPACE after the end of the text.

Once an aligned (possibly empty) comment exists on the line, Point moves to the start of the comment text.

CONTROL-X;

Sets comment-column to the column after Point. The left margin is column 0.

CONTROL-U CONTROL-X;

Kills the comment on the current line. This command sets comment-column from the first comment found above this line and then performs a META-; command to insert or align a comment at that position.

CONTROL-U CONTROL-X;

Sets comment-column to the position of the first comment found above this line and then executes a META-; command to insert or align a comment on this line.


Special-Purpose Modes

The emacs editor includes a third family of Major modes that are not oriented toward a particular language or even toward ordinary editing. Instead, these modes perform some special function. The following modes may define their own key bindings and commands to accomplish that function:

  • Rmail: reads, archives, and composes email

  • Dired: moves around in an ls l display and operates on files

  • VIP: simulates a complete vi environment

  • VC: allows you to drive version-control systems (including RCS, CVS, and Subversion) from within emacs

  • GUD: Grand Unified Debugger; allows you to run and debug C (and other) programs from within emacs

  • Tramp: allows you to edit files on any remote system you can reach with ftp or scp

  • Shell: runs an interactive subshell from inside an emacs buffer

This book discusses only Shell mode.

Shell Mode

One-time shell commands and Region filtering were discussed earlier; refer to "Foreground Shell Commands" on page 227. In Shell mode, however, each emacs buffer has an underlying interactive shell permanently associated with it. This shell takes its input from the last line of the buffer and sends its output back to the buffer, advancing Point as it goes. If you do not edit the buffer, it holds a record of the complete shell session.

The shell runs asynchronously, whether or not you have its buffer in view. The emacs editor uses idle time to read the shell's output and add it to the buffer.

Type META-x shell to create a buffer named *shell* and start a subshell. If a buffer named *shell* already exists, emacs just switches to that buffer. The shell that this command runs is taken from one of the following sources:

  • The Lisp variable explicit-shell-file-name

  • The environment variable ESHELL

  • The environment variable SHELL

To start a second shell, first use META-x rename-buffer to change the name of the existing shell's buffer, and then use META-x shell to start another shell. You can create as many subshells and buffers as you like, all running in parallel.

A special set of commands is defined in Shell mode (Table 7-20). They are bound mostly to two-key sequences starting with CONTROL-C. Each sequence is similar to the ordinary control characters found in Mac OS X but uses a leading CONTROL-C.

Table 7-20. Shell mode

Command

Result

RETURN

If Point is at the end of the buffer, emacs inserts the RETURN and sends this (the last) line to the shell. If Point is elsewhere, it copies this line to the end of the buffer, peeling off the old shell prompt (see the regular expression shell-prompt-pattern), if one existed. Then this copied linenow the last in the bufferis sent to the shell.

CONTROL-C CONTROL-D

Sends CONTROL-D to the shell or its subshell.

CONTROL-C CONTROL-C

Sends CONTROL-C to the shell or its subshell.

CONTROL-C CONTROL\

Sends a quit signal to the shell or its subshell.

CONTROL-C CONTROL-U

Kills the text on the current line not yet completed.

CONTROL-C CONTROL-R

Scrolls back to the beginning of the last shell output, putting the first line of output at the top of the window.

CONTROL-C CONTROL-O

Deletes the last batch of shell output.


Optional: Customizing emacs

At the heart of emacs is a Lisp interpreter written in C. This version of Lisp is significantly extended with many special commands specifically oriented to editing. The interpreter's main task is to execute the Lisp-coded system that implements the look-and-feel of emacs.

Reduced to its essentials, this system implements a continuous loop that watches keystrokes arrive, parses them into commands, executes those commands, and updates the screen. This behavior can be customized in a number of ways.

  • As single keystrokes come in, they are mapped immediately through a keyboard translation table. By changing the entries in this table, it is possible to swap keys. If you are used to vi or vim, you can swap DELETE and CONTROL-H. Then CONTROL-H backspaces as it does in vim, and DELETE (which is not used by vim) is the help key. If you use DELETE as an interrupt key, you may want to choose another key to swap with CONTROL-H.

  • The mapped keystrokes are gathered into small groups called key sequences. A key sequence may be only a single key, such as CONTROL-N, or may include two or more keys, such as CONTROL-X CONTROL-F. Once gathered the key sequences are used to select a particular procedure to be executed. The rules for gathering each key sequence and the specific procedure name to be executed when that sequence comes in are codified in a series of tables called keymaps. By altering the keymaps, you can change the gathering rules or change which procedure is associated with which sequence. If you are used to vi's or vim's use of CONTROL-W to back up over the word you are entering, you may want to change emacs's CONTROL-W binding from the standard kill-region to delete-word-backward.

  • The command behavior is often conditioned by one or more global variables or options. It may be possible to get the behavior you want by setting some of these variables.

  • The command itself is usually a Lisp program that can be reprogrammed to make it behave as desired. Although this task is not appropriate for beginners, the Lisp source to nearly all commands is available and the internal Lisp system is fully documented. As mentioned earlier, it is common practice to load customized Lisp code at startup time, even if you did not write it yourself.

Most emacs documentation glosses over all the translation, gathering, and procedure selection and talks about keystrokes as though they were commands. However, it is still important to know that the underlying machinery exists and to understand that its behavior can be changed.

THE .emacs STARTUP FILE

Each time you start emacs, it loads the file of Lisp code named ~/.emacs. Using this file is the most common way to customize emacs. Two command line options control the use of the .emacs file. The q option ignores the .emacs file so that emacs starts up without it; this is one way to get past a bad .emacs file. The u user option uses the ~user/.emacs file (the .emacs file from the home directory of user).

The .emacs startup file is generally concerned only with key bindings and option settings; it is possible to write the Lisp statements for this file in a straightforward style. Each parenthesized Lisp statement is a Lisp function call. Inside the parentheses the first symbol is the function name; the rest of the SPACE-separated tokens are arguments to that function. The most common function in the .emacs file, setq, is a simple assignment to a global variable. The first argument is the name of the variable to set and the second argument is its value. The following example sets the variable named c-indent-level to 8:

(setq c-indent-level 8) 


You can set the default value for a variable that is buffer-private by using the function name setq-default. To set a specific element of a vector, use the function name aset. The first argument is the name of the vector, the second is the target offset, and the third is the value of the target entry. In the startup file the new values are usually constants. Table 7-21 shows the formats of these constants.

Table 7-21. Formats of constants in .emacs

Command

Result

Numbers

Decimal integers, with an optional minus sign

Strings

Similar to C strings but with extensions for CONTROL and META characters: \C-s yields CONTROL-S, \M-s yields META-s, and \M\C-s yields CONTROL-META-s

Characters

Not like C characters; start with ? and continue with a printing character or with a backslash escape sequence (for example, ?a, ?\C-i, ?\033)

Booleans

Not 1 and 0; use t for true and nil for false

Other Lisp objects

Begin with a single quotation mark and continue with the object's name


REMAPPING KEYS

The emacs command loop begins each cycle by translating incoming keystrokes into the name of the command to be executed. The basic translation operation uses the ASCII value of the incoming character to index a 128-element vector called a keymap.

Sometimes a character's eighth bit is interpreted as the META case, but this cannot always be relied on. At the point of translation all META characters appear with the ESCAPE prefix, whether or not they were actually typed that way.

Each position in this vector is one of the following:

  • Not defined at all: No translation possible in this map.

  • The name of another keymap: Switches to that keymap and waits for the next character to arrive.

  • The name of a Lisp function to be called: Translation process is done; call this command.

Because keymaps can reference other keymaps, an arbitrarily complex recognition tree can be set up. The mainstream emacs bindings use at most three keys, with a very small group of well-known prefix keys, each with its well-known keymap name.

Each buffer can have a local keymap that is used first for any keystrokes arriving while a window into that buffer is selected. The local keymap allows the regular mapping to be extended or overridden on a per-buffer basis and is most often used to add bindings for a Major mode.

The basic translation flow runs as follows:

  • Map the first character through the buffer's local keymap. If it is defined as a Lisp function name, translation is done and emacs executes that function. If it is not defined, use this same character to index the global top-level keymap.

  • Map the first character through the top-level global keymap global-map. At this and each following stage, the following conditions hold:

    • If the entry for this character is not defined, it is an error. Send a bell to the terminal and discard all the characters entered in this key sequence.

    • If the entry for this character is defined as a Lisp function name, translation is done and the function is executed.

    • If the entry for this character is defined as the name of another keymap, switch to that keymap and wait for another character to select one of its elements.

Everything must be a command or an error. Ordinary characters that are to be inserted in the buffer are usually bound to the command self-insert-command. Each of the well-known prefix characters is each associated with a keymap (Table 7-22).

Table 7-22. Keymap prefixes

Keymap prefix

Applies to

ctl-x-map

Characters following CONTROL-X

ctl-x-4-map

Characters following CONTROL-X 4

esc-map

Characters following ESCAPE (including META characters)

help-map

Characters following CONTROL-H

mode-specific-map

Characters following CONTROL-C


To see the current state of the keymaps, type CONTROL-H b. They appear in the following order: local, global, and shorter maps for each prefix key. Each line specifies the name of the Lisp function to be called; the documentation for that function can be retrieved with the commands CONTROL-H f function-name or CONTROL-H k key-sequence.

The most common type of keymap customization is making small changes to the global command assignments without creating any new keymaps or commands. This type of customization is most easily done in the .emacs file using the Lisp function define-key. The define-key function takes three arguments:

  • The keymap name

  • A single character defining a position in that map

  • The command to be executed when this character appears

For instance, to bind the command backward-kill-word to CONTROL-W, use the statement

(define-key global-map "\C-w" 'backward-kill-word) 


To bind the command kill-region to CONTROL-X CONTROL-K, use the statement

(define-key ctl-x-map "\C-k" 'kill-region) 


The \ character causes C-w to be interpreted as CONTROL-W instead of three letters (equivalent to \^w). The unmatched single quotation mark in front of the command name is correct. This Lisp escape character keeps the name from being evaluated too soon.

A SAMPLE .emacs FILE

The following ~/.emacs file produces a plain editing environment that minimizes surprises for vi and vim users. Of course, if any section or any line is inapplicable or not to your liking, you can edit it out or comment it with one or more ; comment characters, beginning in column 1.

[View full width]

;;; Preference Variables (setq make-backup-files nil) ;Do not make backup files (setq backup-by-copying t) ;If you do, at least do not destroy links (setq delete-auto-save-files t) ;Delete autosave files when writing orig (setq blink-matching-paren nil) ;Do not blink opening delim (setq-default case-fold-search nil) ;Do not fold cases in search (setq require-final-newline 'ask) ;Ask about missing final newline ;; Reverse mappings for C-h and DEL. (keyboard-translate ?\C-h ?\177) (keyboard-translate ?\177 ?\C-h) ;; reassigning C-w to keep on deleting words backward ;; C-w is supposed to be kill-region, but it's a great burden for vi-trained fingers. ;; Bind it instead to backward-kill-word for more familiar, friendly behavior. (define-key global-map "\^w" 'backward-kill-word) ;; for kill-region use a two-key sequence c-x c-k. (define-key ctl-x-map "\^k" 'kill-region) ;; C mode customization: set vanilla (8-space bsd) indention style (require 'cc-mode) ;kiss: be sure it's here (c-add-style ;add indentation style "bsd8" ;old bsd (8 spaces) '((c-basic-offset . 8) (c-hanging-comment-ender-p . nil) ;isolated "*/" ends blk comments (c-comment-only-line-offset . 0) (c-offsets-alist . ((statement-block-intro . +) (knr-argdecl-intro . +) (substatement-open . 0) (label . 0) (statement-cont . +) )) )) (add-hook ;this is our default style, 'c-mode-hook ;set it always in c-mode-hook (function (lambda () (c-set-style "bsd8")))) ;; end of c mode style setup






A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net