Section 8.6. Summary of Commands by Name


8.6. Summary of Commands by Name

The following Emacs commands are presented alphabetically by command name. Use M-x to access the command name. Tables list command name, keystroke, and description. C- indicates the Ctrl key; M- indicates the Meta key.

Command

Binding

Action

macroname

(none)

Execute a keyboard macro you've saved.

abbrev-mode

(none)

Enter (or exit) word abbreviation mode.

abort-recursive-edit

C-]

Exit recursive edit and query replace.

advertised-undo

C-x u

Undo last edit (can be done repeatedly).

apropos

(none)

What functions and variables involve this concept?

back-to-indentation

M-m

Move cursor to first nonblank character on line.

backward-char

C-b

Move backward one character (left).

backward-delete-char

Del

Delete previous character.

backward-kill-paragraph

(none)

Delete previous paragraph.

backward-kill- sentence

C-x Del

Delete previous sentence.

backward-kill-word

C-c C-w

Delete previous word.

backward-kill-word

M-Del

Delete previous word.

backward-page

C-x [

Move backward one page.

backward-paragraph

M-{

Move backward one paragraph.

backward-sentence

M-a

Move backward one sentence.

backward-word

M-b

Move backward one word.

beginning-of-buffer

M-<

Move to beginning of file.

beginning-of-line

C-a

Move to beginning of line.

call-last-kbd-macro

C-x e

Execute last macro defined.

capitalize-region

(none)

Capitalize region.

capitalize-word

M-c

Capitalize first letter of word.

center-line

(none)

Center line that cursor is on.

center-paragraph

(none)

Center paragraph that cursor is on.

center-region

(none)

Center currently defined region.

command-apropos

C-h a

What commands involve this concept?

compare- windows

(none)

Compare two buffers; show first difference.

delete-char

C-d

Delete character under cursor.

delete-indentation

M-^

Join this line to previous one.

delete-other-windows

C-x 1

Delete all windows but this one.

delete-window

C-x 0

Delete current window.

delete-windows-on

(none)

Delete all windows on a given buffer.

describe-bindings

C-h b

What are all the key bindings for in this buffer?

describe-copying

C-h C-c

View the Emacs General Public License.

describe-distribution

C-h C-d

View information on ordering Emacs from the FSF.

describe-function

C-h f

What does this function do?

describe-key

C-h k

What command does this keystroke sequence run, and what does it do?

describe-key- briefly

C-h c

What command does this keystroke sequence run?

describe-mode

C-h m

Tell me about the mode the current buffer is in.

describe-no-warranty

C-h C-w

View the (non)warranty for Emacs.

describe-syntax

C-h s

What is the syntax table for this buffer?

describe-variable

C-h v

What does this variable mean, and what is its value?

digit-argument

M- n

Repeat next command n times.

downcase-region

C-x C-l

Lowercase region.

downcase-word

M-l

Lowercase word.

edit-abbrevs

(none)

Edit word abbreviations.

end-kbd-macro

C-x )

End macro definition.

end-of-buffer

M->

Move to end-of-file.

end-of-line

C-e

Move to end-of-line.

enlarge-window

C-x ^

Make window taller.

enlarge-window-horizontally

C-x }

Make window wider.

exchange-point-and-mark

C-x C-x

Exchange location of cursor and mark.

exit-recursive-edit

M-C-c

Exit a recursive edit.

fill-individual-paragraphs

(none)

Reformat indented paragraphs, keeping indentation.

fill-paragraph

M-q

Reformat paragraph.

fill-region

(none)

Reformat individual paragraphs within a region.

find-alternate-file

C-x C-v

Read an alternate file, replacing the one currently in the buffer.

find-file

C-x C-f

Find file and read it.

find-file-other-frame

C-x 5 f

Find a file in another frame.

find-file-other-window

C-x 4 f

Find a file in another window.

forward-char

C-f

Move forward one character (right).

forward-page

C-x ]

Move forward one page.

forward-paragraph

M-}

Move forward one paragraph.

forward-sentence

M-e

Move forward one sentence.

forward-word

M-f

Move forward one word.

goto-char

(none)

Go to numbered character of file.

goto-line

(none)

Go to numbered line of file.

help-command

C-h

Enter the online help system.

help-with-tutorial

C-h t

Run the Emacs tutorial.

indent-region

M-C-\

Indent a region to match first line in region.

indented-text-mode

(none)

Major mode: each tab defines a new indent for subsequent lines.

info

C-h i

Start the Info documentation reader.

insert-file

C-x i

Insert file at cursor position.

insert-last-keyboard-macro

(none)

Insert the macro you named into a file.

interrupt-shell-subjob

C-c C-c

Terminate the current job (shell mode).

inverse-add-global-abbrev

C-x a -

Define previous word as global (mode-independent) abbreviation.

inverse-add-mode-abbrev

C-x a i l

Define previous word as mode-specific abbreviation.

isearch-backward

C-r

Start incremental search backward.

isearch-backward-regexp

M-C-r

Same, but search for regular expression.

isearch-forward

C-s

Start incremental search forward.

isearch-forward-regexp

M-C-s

Same, but search for regular expression.

kbd-macro-query

C-x q

Insert a query in a macro definition.

keyboard-quit

C-g

Abort current command.

kill-all-abbrevs

(none)

Kill abbreviations for this session.

kill-buffer

C-x k

Delete the buffer specified.

kill-line

C-k

Delete from cursor to end-of-line.

kill-paragraph

(none)

Delete from cursor to end of paragraph.

kill-region

C-w

Delete a marked region.

kill-sentence

M-k

Delete sentence the cursor is on.

kill-shell-input

C-c C-u

Delete current line.

kill-some-buffers

(none)

Ask about deleting each buffer.

kill-word

M-d

Delete word the cursor is on.

list-abbrevs

(none)

View word abbreviations.

list-buffers

C-x C-b

Display buffer list.

load-file

(none)

Load macro files you've saved.

mark-page

C-x C-p

Place cursor and mark around whole page.

mark-paragraph

M-h

Place cursor and mark around whole paragraph.

mark-whole-buffer

C-x h

Place cursor and mark around whole buffer.

name-last-kbd-macro

(none)

Name last macro you created (before saving it).

negative-argument; capitalize-word

M-- M-c

Capitalize previous word.

negative-argument; downcase-word

M-- M-l

Lowercase previous word.

negative-argument; upcase -word

M-- M-u

Uppercase previous word.

next-line

C-n

Move to next line (down).

other-window

C-x o

Move to the other window.

previous-line

C-p

Move to previous line (up).

query-replace

M-%

Search for and replace a string.

query-replace-regexp

(none)

Query-replace a regular expression.

quoted-insert

C-q

Insert next character typed. Useful for inserting a control character.

recenter

C-l

Redraw screen, with current line in center.

rename-buffer

(none)

Change buffer name to specified name.

replace-regexp

(none)

Replace a regular expression unconditionally.

re-search-backward

(none)

Simple regular-expression search backward.

re-search-forward

(none)

Simple regular-expression search forward.

revert-buffer

(none)

Restore buffer to the state it was in when the file was last saved (or auto-saved).

save-buffer

C-x C-s

Save file. (If terminal hangs , C-q restarts.)

save-buffers-kill-emacs

C-x C-c

Exit Emacs.

save-some-buffers

C-x s

Ask whether to save each modified buffer.

scroll-down

M-v

Move backward one screen.

scroll-left

C-x <

Scroll the window left.

scroll-other-window

M-C-v

Scroll other window.

scroll-right

C-x >

Scroll the window right.

scroll-up

C-v

Move forward one screen.

set-fill-prefix

C-x .

Prepend each line in paragraph with characters from beginning of line up to cursor column; cancel prefix by typing this command in column 1.

set-mark-command

C-@ or C-Space

Mark the beginning (or end) of a region.

shell-command

M-!

Prompt for a shell command and run it.

shell-send-eof

C-c C-d

End-of-file character (shell mode).

shrink-window

(none)

Make window shorter.

shrink-window-horizontally

C-x {

Make window narrower.

spell-buffer

(none)

Check spelling of current buffer.

spell-region

(none)

Check spelling of current region.

spell-string

(none)

Check spelling of string typed in minibuffer.

spell-word

M-$

Check spelling of word after cursor.

split-line

M-C-o

Split line at cursor; indent to column of cursor.

split-window-horizontally

C-x 3

Divide current window horizontally into two.

split-window-vertically

C-x 2

Divide current window vertically into two.

start-kbd-macro

C-x (

Start macro definition.

stop-shell-subjob

C-c C-z

Suspend current job.

suspend-emacs

C-z

Suspend Emacs (use fg to restart).

switch-to-buffer

C-x b

Move to the buffer specified.

switch-to-buffer-other-frame

C-x 5 b

Select a buffer in another frame.

switch-to-buffer-other- window

C-x 4 b

Select a buffer in another window.

text-mode

(none)

Enter text mode.

transpose-chars

C-t

Transpose two characters.

transpose-lines

C-x C-t

Transpose two lines.

transpose-paragraphs

(none)

Transpose two paragraphs.

transpose-sentences

(none)

Transpose two sentences.

transpose-words

M-t

Transpose two words.

unexpand -abbrev

(none)

Undo the last word abbreviation.

universal-argument

C-u n

Repeat the next command n times.

upcase-region

C-x C-u

Uppercase region.

upcase-word

M-u

Uppercase word.

view-emacs-news

C-h n

View news about updates to Emacs.

view-lossage

C-h l

What are the last 100 characters I typed?

where-is

C-h w

What is the key binding for this command?

write-abbrev-file

(none)

Write the word abbreviation file.

write-file

C-x C-w

Write buffer contents to file.

yank

C-y

Restore what you've deleted.


8.6.1. Extending Emacs

Emacs' many modes come courtesy of elisp files, programs written in Emacs' own LISP-based language and stored in .el and .elc files (the latter for compiled files). Getting into the Elisp language is outside the topic of this book, [*] but be aware that all the modes you're working with are written in elisp .

[*] However, there are books on this topic alone, such as Writing GNU Emacs Extensions (O'Reilly).

Darwin's directory for Emacs extensions is /usr/share/emacs/ emacs-version-number/ lisp . Generally speaking, installing Emacs extensions that you download is as simple as moving them into this folder or into the neighboring site-lisp directory. Some .el files need to be compiled in order to work; this involves using the M-x byte-compile-file command from within Emacs. Packages that contain many interdependent files, such as the PSGML extension for editing SGML and XML files (http://www.lysator.liu.se/projects/about_psgml.html), may make this process easier by including standard Unix configure and Makefile files, which often just run Emacs in batch mode to compile the files in the right order.

Many modes require you to activate various Emacs variables and settings before they'll work. This usually involves editing your .emacs file (see the next section) in some way and is usually described in the extension's README file, or perhaps in the comment section of the elisp file itself.

Many Emacs modes and main functions are centered around programming. The elisp files that ship with Mac OS X include full-featured (which is to say, many-variabled) major modes for C, Java, Perl, and many other languages. Through Meta-X commands such as compile , debug , and the compilation-mode major mode, you can even use Emacs as a complete build-and-debug environment.

That said, there's not much reason to use Emacs as your IDE, unless you're working with a very obscure language that lacks editor support outside of Emacs modes (such as elisp ) or with a rapid-development language with a console-based interface that doesn't really need an IDE, such as Perl or shell scripting. For all other Mac OS X programming, investigate what Project Builder can do.


8.6.2. The .emacs File

You can configure Emacs' default behavior by creating and editing a special elisp file called .emacs in your Home folder. (As with all dotfiles, the Finder hides .emacs from sight; see "Hidden files" in Chapter 10.) Emacs executes all the commands in this file whenever you launch the program, so it's a great place to set variables, activate and customize major mode options, and so on.

Even if you don't know elisp , it's good to know about .emacs because Emacs extensions often require it. If you use Emacs a lot, you may find your .emacs file growing over time. A well-organized elisp file maintains scalability through grouping similar commands together into well-commented blocks, so that you know what everything does each time you return to add to (or debug) the file.

As an example, here's part of the .emacs file on a Mac OS X system:

 ; First, adjust my loadpath so I can see me own .el files (setq load-path (cons (expand-file-name "/Users/jmac/emacs-lisp/") load- path) ) ; Activate and configure PSGML mode (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t ) (custom-set-variables) (custom-set-faces  '(font-lock-comment-face ((((class color) (background dark)) (:foreground  "orchid1"))))) ;; required for Emacs 21 (setq after-change-function nil) ;; Activate XSL-editing mode (autoload 'xsl-mode "xslide" "Major mode for XSL stylesheets." t) ;; Turn on font lock when in XSL mode (add-hook 'xsl-mode-hook           'turn-on-font-lock) (setq auto-mode-alist       (append        (list         '("\.xsl" . xsl-mode))        auto-mode-alist)) ;; Activate the 'time-clock' minor mode, which adds time-tracking functionality.    (require 'timeclock) ;; Define some keystrokes to trigger timeclock functions quickly.    (define-key ctl-x-map "ti" 'timeclock-in)    (define-key ctl-x-map "to" 'timeclock-out)    (define-key ctl-x-map "tc" 'timeclock-change)    (define-key ctl-x-map "tr" 'timeclock-reread-log)    (define-key ctl-x-map "tu" 'timeclock-update-modeline)    (define-key ctl-x-map "tw" 'timeclock-when-to-leave-string) ;; The M-x-erase-buffer command will warn you about your rash deed unless ;; you have the following variable set: (put 'erase-buffer 'disabled nil) 

You can find plenty of other .emacs examples online, including a whole repository just for them at http://www.dotfiles.com.

Note the path-extending command, (setq load-path ... ) , at the top of the previous example. If you're not a member of the machine's admin group , and thus lack the sudo powers necessary to write to the /usr/share/emacs/21.2/ directory, you can define your own space to place elisp files, just as we have here with the directory /Users/jmac/emacs-lisp . This tells Emacs to add that directory to the paths it scans when it seeks extension files.

8.6.3. GUI Emacs

The Emacs that comes with Mac OS X Tiger is a console application that runs in the Terminal. There's no interaction with the GUI, and so many features such as menus , mouse and scroll wheel support, and syntax coloring are not supported. However, there are currently at least two distributions of Emacs that take advantage of Mac OS X and the Carbon and Aqua frameworks.



Emacs for Mac OS X

http://www.mindlube.com/products/emacs/



Aquamacs

http://aquamacs.org/

Finally, if you're running X Windows on your Macintosh, you can compile Emacs and run it with X support.



MAC OS X Tiger in a Nutshell
Mac OS X Tiger in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009437
EAN: 2147483647
Year: 2003
Pages: 130

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