Mercurial > hg > xemacs-beta
view man/xemacs/keystrokes.texi @ 5353:38e24b8be4ea
Improve the lexical scoping in #'block, #'return-from.
lisp/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
Shadow `block', `return-from' here, we implement them differently
when byte-compiling.
* bytecomp.el (byte-compile-active-blocks): New.
* bytecomp.el (byte-compile-block-1): New.
* bytecomp.el (byte-compile-return-from-1): New.
* bytecomp.el (return-from-1): New.
* bytecomp.el (block-1): New.
These are two aliases that exist to have their own associated
byte-compile functions, which functions implement `block' and
`return-from'.
* cl-extra.el (cl-macroexpand-all):
Fix a bug here when macros in the environment have been compiled.
* cl-macs.el (block):
* cl-macs.el (return):
* cl-macs.el (return-from):
Be more careful about lexical scope in these macros.
* cl.el:
* cl.el ('cl-block-wrapper): Removed.
* cl.el ('cl-block-throw): Removed.
These aren't needed in code generated by this XEmacs. They
shouldn't be needed in code generated by XEmacs 21.4, but if it
turns out the packages do need them, we can put them back.
2011-01-30 Mike Sperber <mike@xemacs.org>
* font-lock.el (font-lock-fontify-pending-extents): Don't fail if
`font-lock-mode' is unset, which can happen in the middle of
`revert-buffer'.
2011-01-23 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete):
* cl-macs.el (delq):
* cl-macs.el (remove):
* cl-macs.el (remq):
Don't use the compiler macro if these functions were given the
wrong number of arguments, as happens in lisp-tests.el.
* cl-seq.el (remove, remq): Removed.
I added these to subr.el, and forgot to remove them from here.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-setq, byte-compile-set):
Remove kludge allowing keywords' values to be set, all the code
that does that is gone.
* cl-compat.el (elt-satisfies-test-p):
* faces.el (set-face-parent):
* faces.el (face-doc-string):
* gtk-font-menu.el:
* gtk-font-menu.el (gtk-reset-device-font-menus):
* msw-font-menu.el:
* msw-font-menu.el (mswindows-reset-device-font-menus):
* package-get.el (package-get-installedp):
* select.el (select-convert-from-image-data):
* sound.el:
* sound.el (load-sound-file):
* x-font-menu.el (x-reset-device-font-menus-core):
Don't quote keywords, they're self-quoting, and the
win from backward-compatibility is sufficiently small now that the
style problem overrides it.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (block, return-from): Require that NAME be a symbol
in these macros, as always documented in the #'block docstring and
as required by Common Lisp.
* descr-text.el (unidata-initialize-unihan-database):
Correct the use of non-symbols in #'block and #'return-from in
this function.
2011-01-15 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (concatenate): Accept more complicated TYPEs in this
function, handing the sequences over to #'coerce if we don't
understand them here.
* cl-macs.el (inline): Don't proclaim #'concatenate as inline, its
compiler macro is more useful than doing that.
2011-01-11 Aidan Kehoe <kehoea@parhasard.net>
* subr.el (delete, delq, remove, remq): Move #'remove, #'remq
here, they don't belong in cl-seq.el; move #'delete, #'delq here
from fns.c, implement them in terms of #'delete*, allowing support
for sequences generally.
* update-elc.el (do-autoload-commands): Use #'delete*, not #'delq
here, now the latter's no longer dumped.
* cl-macs.el (delete, delq): Add compiler macros transforming
#'delete and #'delq to #'delete* calls.
2011-01-10 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box): Correct a misplaced parenthesis
here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se !
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box):
* list-mode.el (display-completion-list):
These functions used to use cl-parsing-keywords; change them to
use defun* instead, fixing the build. (Not sure what led to me
not including this change in d1b17a33450b!)
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (define-star-compiler-macros):
Make sure the form has ITEM and LIST specified before attempting
to change to calls with explicit tests; necessary for some tests
in lisp-tests.el to compile correctly.
(stable-union, stable-intersection): Add compiler macros for these
functions, in the same way we do for most of the other functions
in cl-seq.el.
2011-01-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (dolist, dotimes, do-symbols, macrolet)
(symbol-macrolet):
Define these macros with defmacro* instead of parsing the argument
list by hand, for the sake of style and readability; use backquote
where appropriate, instead of calling #'list and and friends, for
the same reason.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* x-misc.el (device-x-display):
Provide this function, documented in the Lispref for years, but
not existing previously. Thank you Julian Bradfield, thank you
Jeff Mincy.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el:
Move the heavy lifting from this file to C. Dump the
cl-parsing-keywords macro, but don't use defun* for the functions
we define that do take keywords, dynamic scope lossage makes that
not practical.
* subr.el (sort, fillarray): Move these aliases here.
(map-plist): #'nsublis is now built-in, but at this point #'eql
isn't necessarily available as a test; use #'eq.
* obsolete.el (cl-delete-duplicates): Make this available for old
compiler macros and old code.
(memql): Document that this is equivalent to #'member*, and worse.
* cl.el (adjoin, subst): Removed. These are in C.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (assoc-ignore-case): Remove a duplicate definition of
this function (it's already in subr.el).
* iso8859-1.el (char-width):
On non-Mule, make this function equivalent to that produced by
(constantly 1), but preserve its docstring.
* subr.el (subst-char-in-string): Define this in terms of
#'substitute, #'nsubstitute.
(string-width): Define this using #'reduce and #'char-width.
(char-width): Give this a simpler definition, it makes far more
sense to check for mule at load time and redefine, as we do in
iso8859-1.el.
(store-substring): Implement this in terms of #'replace, now
#'replace is cheap.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* update-elc.el (lisp-files-needed-for-byte-compilation)
(lisp-files-needing-early-byte-compilation):
cl-macs belongs in the former, not the latter, it is as
fundamental as bytecomp.el.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl.el:
Provde the Common Lisp program-error, type-error as error
symbols. This doesn't nearly go far enough for anyone using the
Common Lisp errors.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete-duplicates):
If the form has an incorrect number of arguments, don't attempt a
compiler macroexpansion.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (cl-safe-expr-p):
Forms that start with the symbol lambda are also safe.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
For these functions' compiler macros, the optimisation is safe
even if the first and the last arguments have side effects, since
they're only used the once.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (inline-side-effect-free-compiler-macros):
Unroll a loop here at macro-expansion time, so these compiler
macros are compiled. Use #'eql instead of #'eq in a couple of
places for better style.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (notany, notevery): Avoid some dynamic scope
stupidity with local variable names in these functions, when they
weren't prefixed with cl-; go into some more detail in the doc
strings.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns): #'remove, #'remq are
free of side-effects.
(side-effect-and-error-free-fns):
Drop dot, dot-marker from the list.
2010-11-17 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (coerce):
In the argument list, name the first argument OBJECT, not X; the
former name was always used in the doc string and is clearer.
Handle vector type specifications which include the length of the
target sequence, error if there's a mismatch.
* cl-macs.el (cl-make-type-test): Handle type specifications
starting with the symbol 'eql.
2010-11-14 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (eql): Don't remove the byte-compile property of this
symbol. That was necessary to override a bug in bytecomp.el where
#'eql was confused with #'eq, which bug we no longer have.
If neither expression is constant, don't attempt to handle the
expression in this compiler macro, leave it to byte-compile-eql,
which produces better code anyway.
* bytecomp.el (eq): #'eql is not the function associated with the
byte-eq byte code.
(byte-compile-eql): Add an explicit compile method for this
function, for cases where the cl-macs compiler macro hasn't
reduced it to #'eq or #'equal.
2010-10-25 Aidan Kehoe <kehoea@parhasard.net>
Add compiler macros and compilation sanity-checking for various
functions that take keywords.
* byte-optimize.el (side-effect-free-fns): #'symbol-value is
side-effect free and not error free.
* bytecomp.el (byte-compile-normal-call): Check keyword argument
lists for sanity; store information about the positions where
keyword arguments start using the new byte-compile-keyword-start
property.
* cl-macs.el (cl-const-expr-val): Take a new optional argument,
cl-not-constant, defaulting to nil, in this function; return it if
the expression is not constant.
(cl-non-fixnum-number-p): Make this into a separate function, we
want to pass it to #'every.
(eql): Use it.
(define-star-compiler-macros): Use the same code to generate the
member*, assoc* and rassoc* compiler macros; special-case some
code in #'add-to-list in subr.el.
(remove, remq): Add compiler macros for these two functions, in
preparation for #'remove being in C.
(define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to
(remove ... :if-not) at compile time, which will be a real win
once the latter is in C.
(define-substitute-if-compiler-macros)
(define-subst-if-compiler-macros): Similarly for these functions.
(delete-duplicates): Change this compiler macro to use
#'plists-equal; if we don't have information about the type of
SEQUENCE at compile time, don't bother attempting to inline the
call, the function will be in C soon enough.
(equalp): Remove an old commented-out compiler macro for this, if
we want to see it it's in version control.
(subst-char-in-string): Transform this to a call to nsubstitute or
nsubstitute, if that is appropriate.
* cl.el (ldiff): Don't call setf here, this makes for a load-time
dependency problem in cl-macs.el
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* term/vt100.el:
Refer to XEmacs, not GNU Emacs, in permissions.
* term/bg-mouse.el:
* term/sup-mouse.el:
Put copyright notice in canonical "Copyright DATE AUTHOR" form.
Refer to XEmacs, not GNU Emacs, in permissions.
* site-load.el:
Add permission boilerplate.
* mule/canna-leim.el:
* alist.el:
Refer to XEmacs, not APEL/this program, in permissions.
* mule/canna-leim.el:
Remove my copyright, I've assigned it to the FSF.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* gtk.el:
* gtk-widget-accessors.el:
* gtk-package.el:
* gtk-marshal.el:
* gtk-compose.el:
* gnome.el:
Add copyright notice based on internal evidence.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* easymenu.el: Add reference to COPYING to permission notice.
* gutter.el:
* gutter-items.el:
* menubar-items.el:
Fix typo "Xmacs" in permissions notice.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* auto-save.el:
* font.el:
* fontconfig.el:
* mule/kinsoku.el:
Add "part of XEmacs" text to permission notice.
2010-10-14 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns):
* cl-macs.el (remf, getf):
* cl-extra.el (tailp, cl-set-getf, cl-do-remf):
* cl.el (ldiff, endp):
Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp;
add circularity checking for the first two.
#'cl-set-getf and #'cl-do-remf were Lisp implementations of
#'plist-put and #'plist-remprop; change the names to aliases,
changes the macros that use them to using #'plist-put and
#'plist-remprop directly.
2010-10-12 Aidan Kehoe <kehoea@parhasard.net>
* abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table):
Create both these abbrev tables using the usual
#'define-abbrev-table calls, rather than attempting to
special-case them.
* cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is
being loaded interpreted. Previously other, later files would
redundantly call (load "cl-macs") when interpreted, it's more
reasonable to do it here, once.
* cmdloop.el (read-quoted-char-radix): Use defcustom here, we
don't have any dump-order dependencies that would prevent that.
* custom.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling, rely on cl-extra.el in the
former case and the appropriate entry in bytecomp-load-hook in the
latter. Get rid of custom-declare-variable-list, we have no
dump-time dependencies that would require it.
* faces.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling.
* packages.el: Remove some inaccurate comments.
* post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not
here, now the order of preloaded-file-list has been changed to
make it available.
* subr.el (custom-declare-variable-list): Remove. No need for it.
Also remove a stub define-abbrev-table from this file, given the
current order of preloaded-file-list there's no need for it.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are
also constant.
(byte-compile-initial-macro-environment): In #'the, if FORM is
constant and does not match TYPE, warn at byte-compile time.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* backquote.el (bq-vector-contents, bq-list*): Remove; the former
is equivalent to (append VECTOR nil), the latter to (list* ...).
(bq-process-2): Use (append VECTOR nil) instead of using
#'bq-vector-contents to convert to a list.
(bq-process-1): Now we use list* instead of bq-list
* subr.el (list*): Moved from cl.el, since it is now required to
be available the first time a backquoted form is encountered.
* cl.el (list*): Move to subr.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* test-harness.el (Check-Message):
Add an omitted comma here, thank you the buildbot.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* hash-table.el (hash-table-key-list, hash-table-value-list)
(hash-table-key-value-alist, hash-table-key-value-plist):
Remove some useless #'nreverse calls in these files; our hash
tables have no order, it's not helpful to pretend they do.
* behavior.el (read-behavior):
Do the same in this file, in some code evidently copied from
hash-table.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* info.el (Info-insert-dir):
* format.el (format-deannotate-region):
* files.el (cd, save-buffers-kill-emacs):
Use #'some, #'every and related functions for applying boolean
operations to lists, instead of rolling our own ones that cons and
don't short-circuit.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-initial-macro-environment):
* cl-macs.el (the):
Rephrase the docstring, make its implementation when compiling
files a little nicer.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* descr-text.el (unidata-initialize-unicodedata-database)
(unidata-initialize-unihan-database, describe-char-unicode-data)
(describe-char-unicode-data):
Wrap calls to the database functions with (with-fboundp ...),
avoiding byte compile warnings on builds without support for the
database functions.
(describe-char): (reduce #'max ...), not (apply #'max ...), no
need to cons needlessly.
(describe-char): Remove a redundant lambda wrapping
#'extent-properties.
(describe-char-unicode-data): Call #'nsubst when replacing "" with
nil in the result of #'split-string, instead of consing inside
mapcar.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* x-faces.el (x-available-font-sizes):
* specifier.el (let-specifier):
* package-ui.el (pui-add-required-packages):
* msw-faces.el (mswindows-available-font-sizes):
* modeline.el (modeline-minor-mode-menu):
* minibuf.el (minibuf-directory-files):
Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with
the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
When these functions are handed more than two arguments, and those
arguments have no side effects, transform to a series of two
argument calls, avoiding funcall in the byte-compiled code.
* mule/mule-cmds.el (finish-set-language-environment):
Take advantage of this change in a function called 256 times at
startup.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-function-form, byte-compile-quote)
(byte-compile-quote-form):
Warn at compile time, and error at runtime, if a (quote ...) or a
(function ...) form attempts to quote more than one object.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc
(mapcar ...)) to (mapcan ...); warn about use of the first idiom.
* update-elc.el (do-autoload-commands):
* packages.el (packages-find-package-library-path):
* frame.el (frame-list):
* extents.el (extent-descendants):
* etags.el (buffer-tag-table-files):
* dumped-lisp.el (preloaded-file-list):
* device.el (device-list):
* bytecomp-runtime.el (proclaim-inline, proclaim-notinline)
Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files.
* bytecomp-runtime.el (eval-when-compile, eval-and-compile):
In passing, mention that these macros also evaluate the body when
interpreted.
tests/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test lexical scope for `block', `return-from'; add a
Known-Bug-Expect-Failure for a contorted example that fails when
byte-compiled.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 07 Feb 2011 12:01:24 +0000 |
parents | 9db20cbbe4c7 |
children |
line wrap: on
line source
@node Keystrokes, Pull-down Menus, Frame, Top @chapter Keystrokes, Key Sequences, and Key Bindings @iftex This chapter discusses the character set Emacs uses for input commands and inside files. You have already learned that the more frequently used Emacs commands are bound to keys. For example, @kbd{Control-f} is bound to @code{forward-char}. The following issues are covered: @itemize @bullet @item How keystrokes can be represented @item How you can create key sequences from keystrokes @item How you can add to the available modifier keys by customizing your keyboard: for example, you could have the @key{Capslock} key be understood as the @key{Super} key by Emacs. A @key{Super} key is used like @key{Control} or @key{Meta} in that you hold it while typing another key. @end itemize You will also learn how to customize existing key bindings and create new ones. @end iftex @menu * Intro to Keystrokes:: Keystrokes as building blocks of key sequences. * Representing Keystrokes:: Using lists of modifiers and keysyms to represent keystrokes. * Key Sequences:: Combine key strokes into key sequences you can bind to commands. * String Key Sequences:: Available for upward compatibility. * Meta Key:: Using @key{ESC} to represent @key{Meta} * Super and Hyper Keys:: Adding modifier keys on certain keyboards. * Character Representation:: How characters appear in Emacs buffers. * Commands:: How commands are bound to key sequences. * Non-Latin keyboards:: Commands on keyboards where one can't type Latin. @end menu @node Intro to Keystrokes, Representing Keystrokes, Keystrokes, Keystrokes @section Keystrokes as Building Blocks of Key Sequences @cindex character set @cindex ASCII @cindex keystroke Earlier versions of Emacs used only the ASCII character set, which defines 128 different character codes. Some of these codes are assigned graphic symbols like @samp{a} and @samp{=}; the rest are control characters, such as @kbd{Control-a} (also called @kbd{C-a}). @kbd{C-a} means you hold down the @key{CTRL} key and then press @kbd{a}.@refill Keybindings in XEmacs are not restricted to the set of keystrokes that can be represented in ASCII. XEmacs can tell the difference between, for example, @kbd{Control-h}, @kbd{Control-Shift-h}, and @kbd{Backspace}. @cindex modifier key @cindex keysym @kindex meta key @kindex control key @kindex hyper key @kindex super key @kindex shift key @kindex button1 @kindex button2 @kindex button3 @kindex button1up @kindex button2up @kindex button3up A keystroke is like a piano chord: you get it by simultaneously striking several keys. To be more precise, a keystroke consists of a possibly empty set of modifiers followed by a single @dfn{keysym}. The set of modifiers is small; it consists of @kbd{Control}, @kbd{Meta}, @kbd{Super}, @kbd{Hyper}, and @kbd{Shift}. The rest of the keys on your keyboard, along with the mouse buttons, make up the set of keysyms. A keysym is usually what is printed on the keys on your keyboard. Here is a table of some of the symbolic names for keysyms: @table @kbd @item a,b,c... alphabetic keys @item f1,f2... function keys @item button1 left mouse button @item button2 middle mouse button @item button3 right mouse button @item button1up upstroke on the left mouse button @item button2up upstroke on the middle mouse button @item button3up upstroke on the right mouse button @item return Return key @end table @vindex keyboard-translate-table Use the variable @code{keyboard-translate-table} only if you are on a dumb tty, as it cannot handle input that cannot be represented as ASCII. The value of this variable is a string used as a translate table for keyboard input or @code{nil}. Each character is looked up in this string and the contents used instead. If the string is of length @code{n}, character codes @code{N} and up are untranslated. If you are running Emacs under X, you should do the translations with the @code{xmodmap} program instead. @node Representing Keystrokes, Key Sequences, Intro to Keystrokes, Keystrokes @comment node-name, next, previous, up @subsection Representing Keystrokes @kindex hyper key @kindex super key @findex read-key-sequence XEmacs represents keystrokes as lists. Each list consists of an arbitrary combination of modifiers followed by a single keysym at the end of the list. If the keysym corresponds to an ASCII character, you can use its character code. (A keystroke may also be represented by an event object, as returned by the @code{read-key-sequence} function; non-programmers need not worry about this.) The following table gives some examples of how to list representations for keystrokes. Each list consists of sets of modifiers followed by keysyms: @table @kbd @item (control a) Pressing @key{CTRL} and @kbd{a} simultaneously. @item (control ?a) Another way of writing the keystroke @kbd{C-a}. @item (control 65) Yet another way of writing the keystroke @kbd{C-a}. @item (break) Pressing the @key{BREAK} key. @item (control meta button2up) Release the middle mouse button, while pressing @key{CTRL} and @key{META}. @end table @cindex shift modifier Note: As you define keystrokes, you can use the @kbd{shift} key only as a modifier with characters that do not have a second keysym on the same key, such as @kbd{backspace} and @kbd{tab}. It is an error to define a keystroke using the @key{shift} modifier with keysyms such as @kbd{a} and @kbd{=}. The correct forms are @kbd{A} and @kbd{+}. @node Key Sequences, String Key Sequences, Representing Keystrokes, Keystrokes @subsection Representing Key Sequences A @dfn{complete key sequence} is a sequence of keystrokes that Emacs understands as a unit. Key sequences are significant because you can bind them to commands. Note that not all sequences of keystrokes are possible key sequences. In particular, the initial keystrokes in a key sequence must make up a @dfn{prefix key sequence}. Emacs represents a key sequence as a vector of keystrokes. Thus, the schematic representation of a complete key sequence is as follows: @example [(modifier .. modifier keysym) ... (modifier .. modifier keysym)] @end example Here are some examples of complete key sequences: @table @kbd @item [(control c) (control a)] Typing @kbd{C-c} followed by @kbd{C-a} @item [(control c) (control 65)] Typing @kbd{C-c} followed by @kbd{C-a}. (Using the ASCII code for the character `a')@refill @item [(control c) (break)] Typing @kbd{C-c} followed by the @kbd{break} character.@refill @end table @kindex C-c @kindex C-x @kindex C-h @kindex ESC @cindex prefix key sequence A @dfn{prefix key sequence} is the beginning of a series of longer sequences that are valid key sequences; adding any single keystroke to the end of a prefix results in a valid key sequence. For example, @kbd{control-x} is standardly defined as a prefix. Thus there is a two-character key sequence starting with @kbd{C-x} for each valid keystroke, giving numerous possibilities. Here are some samples: @itemize @bullet @item @kbd{[(control x) (c)]} @item @kbd{[(control x) (control c)]} @end itemize Adding one character to a prefix key does not have to form a complete key. It could make another, longer prefix. For example, @kbd{[(control x) (\4)]} is itself a prefix that leads to any number of different three-character keys, including @kbd{[(control x) (\4) (f)]}, @kbd{[(control x) (\4) (b)]} and so on. It would be possible to define one of those three-character sequences as a prefix, creating a series of four-character keys, but we did not define any of them this way.@refill By contrast, the two-character sequence @kbd{[(control f) (control k)]} is not a key, because the @kbd{(control f)} is a complete key sequence in itself. You cannot give @kbd{[(control f (control k)]} an independent meaning as a command while @kbd{(control f)} is a complete sequence, because Emacs would understand @key{C-f C-k} as two commands.@refill The predefined prefix key sequences in Emacs are @kbd{(control c)}, @kbd{(control x)}, @kbd{(control h)}, @kbd{[(control x) (\4)]}, and @kbd{escape}. You can customize Emacs and could make new prefix keys or eliminate the default key sequences. @xref{Key Bindings}. For example, if you redefine @kbd{(control f)} as a prefix, @kbd{[(control f) (control k)]} automatically becomes a valid key sequence (complete, unless you define it as a prefix as well). Conversely, if you remove the prefix definition of @kbd{[(control x) (\4)]}, @kbd{[(control x) (\4) (f)]} (or @kbd{[(control x) (\4) @var{anything}]}) is no longer a valid key sequence. Note that the above paragraphs uses \4 instead of simply 4, because \4 is the symbol whose name is "4", and plain 4 is the integer 4, which would have been interpreted as the ASCII value. Another way of representing the symbol whose name is "4" is to write ?4, which would be interpreted as the number 52, which is the ASCII code for the character "4". We could therefore actually have written 52 directly, but that is far less clear. @node String Key Sequences, Meta Key, Key Sequences, Keystrokes @comment node-name, next, previous, up @subsection String Key Sequences For backward compatibility, you may also represent a key sequence using strings. For example, we have the following equivalent representations: @table @kbd @item "\C-c\C-c" @code{[(control c) (control c)]} @item "\e\C-c" @code{[(meta control c)]} @end table @kindex LFD @kindex TAB @node Meta Key, Super and Hyper Keys, String Key Sequences, Keystrokes @comment node-name, next, previous, up @subsection Assignment of the @key{META} Key @kindex META @kindex ESC Not all terminals have the complete set of modifiers. Terminals that have a @key{Meta} key allow you to type Meta characters by just holding that key down. To type @kbd{Meta-a}, hold down @key{META} and press @kbd{a}. On those terminals, the @key{META} key works like the @key{SHIFT} key. Such a key is not always labeled @key{META}, however, as this function is often a special option for a key with some other primary purpose.@refill If there is no @key{META} key, you can still type Meta characters using two-character sequences starting with @key{ESC}. To enter @kbd{M-a}, you could type @kbd{@key{ESC} a}. To enter @kbd{C-M-a}, you would type @kbd{ESC C-a}. @key{ESC} is allowed on terminals with Meta keys, too, in case you have formed a habit of using it.@refill If you are running under X and do not have a @key{META} key, it is possible to reconfigure some other key to be a @key{META} key. @xref{Super and Hyper Keys}. @refill @vindex meta-flag Emacs believes the terminal has a @key{META} key if the variable @code{meta-flag} is non-@code{nil}. Normally this is set automatically according to the termcap entry for your terminal type. However, sometimes the termcap entry is wrong, and then it is useful to set this variable yourself. @xref{Variables}, for how to do this. Note: If you are running under the X window system, the setting of the @code{meta-flag} variable is irrelevant. @node Super and Hyper Keys, Character Representation, Meta Key, Keystrokes @comment node-name, next, previous, up @subsection Assignment of the @key{SUPER} and @key{HYPER} Keys @kindex hyper key @kindex super key Most keyboards do not, by default, have @key{SUPER} or @key{HYPER} modifier keys. Under X, you can simulate the @key{SUPER} or @key{HYPER} key if you want to bind keys to sequences using @kbd{super} and @kbd{hyper}. You can use the @code{xmodmap} program to do this. For example, to turn your @key{CAPS-LOCK} key into a @key{SUPER} key, do the following: Create a file called @code{~/.xmodmap}. In this file, place the lines @example remove Lock = Caps_Lock keysym Caps_Lock = Super_L add Mod2 = Super_L @end example The first line says that the key that is currently called @code{Caps_Lock} should no longer behave as a ``lock'' key. The second line says that this should now be called @code{Super_L} instead. The third line says that the key called @code{Super_L} should be a modifier key, which produces the @code{Mod2} modifier. To create a @key{META} or @key{HYPER} key instead of a @key{SUPER} key, replace the word @code{Super} above with @code{Meta} or @code{Hyper}. Just after you start up X, execute the command @code{xmodmap /.xmodmap}. You can add this command to the appropriate initialization file to have the command executed automatically.@refill If you have problems, see the documentation for the @code{xmodmap} program. The X keyboard model is quite complicated, and explaining it is beyond the scope of this manual. However, we reprint the following description from the X Protocol document for your convenience: @cindex keysyms @cindex keycode A list of keysyms is associated with each keycode. If that list (ignoring trailing @code{NoSymbol} entries) is a single keysym @samp{K}, then the list is treated as if it were the list @code{``K NoSymbol K NoSymbol''}. If the list (ignoring trailing @code{NoSymbol} entries) is a pair of keysyms @samp{K1 K2}, then the list is treated as if it were the list @code{``K1 K2 K1 K2''}. If the list (ignoring trailing @code{NoSymbol} entries) is a triple of keysyms @samp{K1 K2 K3}, then the list is treated as if it were the list @code{``K1 K2 K3 NoSymbol''}. The first four elements of the list are split into two groups of keysyms. Group 1 contains the first and second keysyms; Group 2 contains third and fourth keysyms. Within each group, if the second element of the group is NoSymbol, then the group should be treated as if the second element were the same as the first element, except when the first element is an alphabetic keysym @samp{K} for which both lowercase and uppercase forms are defined. In that case, the group should be treated as if the first element were the lowercase form of @samp{K} and the second element were the uppercase form of @samp{K}. The standard rules for obtaining a keysym from a KeyPress event make use of only the Group 1 and Group 2 keysyms; no interpretation of other keysyms in the list is given here. (That is, the last four keysyms are unused.) Which group to use is determined by modifier state. Switching between groups is controlled by the keysym named @code{Mode_switch}. Attach that keysym to some keycode and attach that keycode to any one of the modifiers Mod1 through Mod5. This modifier is called the @dfn{group modifier}. For any keycode, Group 1 is used when the group modifier is off, and Group 2 is used when the group modifier is on. Within a group, which keysym to use is also determined by modifier state. The first keysym is used when the @code{Shift} and @code{Lock} modifiers are off. The second keysym is used when the @code{Shift} modifier is on, or when the @code{Lock} modifier is on and the second keysym is uppercase alphabetic, or when the @code{Lock} modifier is on and is interpreted as @code{ShiftLock}. Otherwise, when the @code{Lock} modifier is on and is interpreted as @code{CapsLock}, the state of the @code{Shift} modifier is applied first to select a keysym, but if that keysym is lower-case alphabetic, then the corresponding upper-case keysym is used instead. In addition to the above information on keysyms, we also provide the following description of modifier mapping from the InterClient Communications Conventions Manual: @cindex modifier mapping X11 supports 8 modifier bits, of which 3 are pre-assigned to @code{Shift}, @code{Lock}, and @code{Control}. Each modifier bit is controlled by the state of a set of keys, and these sets are specified in a table accessed by @code{GetModifierMapping()} and @code{SetModifierMapping()}. A client needing to use one of the pre-assigned modifiers should assume that the modifier table has been set up correctly to control these modifiers. The @code{Lock} modifier should be interpreted as @code{Caps Lock} or @code{Shift Lock} according to whether the keycodes in its controlling set include @code{XK_Caps_Lock} or @code{XK_Shift_Lock}. Clients should determine the meaning of a modifier bit from the keysyms being used to control it. A client needing to use an extra modifier, for example @code{Meta}, should: @enumerate @item Scan the existing modifier mappings. @enumerate @item If it finds a modifier that contains a keycode whose set of keysyms includes @code{XK_Meta_L} or @code{XK_Meta_R}, it should use that modifier bit. @item If there is no existing modifier controlled by @code{XK_Meta_L} or @code{XK_Meta_R}, it should select an unused modifier bit (one with an empty controlling set) and: @end enumerate @item If there is a keycode with @code{XL_Meta_L} in its set of keysyms, add that keycode to the set for the chosen modifier, and then: @enumerate @item If there is a keycode with @code{XL_Meta_R} in its set of keysyms, add that keycode to the set for the chosen modifier, and then: @item If the controlling set is still empty, interact with the user to select one or more keys to be @code{Meta}. @end enumerate @item If there are no unused modifier bits, ask the user to take corrective action. @end enumerate This means that the @code{Mod1} modifier does not necessarily mean @code{Meta}, although some applications (such as twm and emacs 18) assume that. Any of the five unassigned modifier bits could mean @code{Meta}; what matters is that a modifier bit is generated by a keycode which is bound to the keysym @code{Meta_L} or @code{Meta_R}. Therefore, if you want to make a @key{META} key, the right way is to make the keycode in question generate both a @code{Meta} keysym and some previously-unassigned modifier bit. @node Character Representation, Commands, Super and Hyper Keys, Keystrokes @comment node-name, next, previous, up @section Representation of Characters This section briefly discusses how characters are represented in Emacs buffers. @xref{Key Sequences}, for information on representing key sequences to create key bindings. Printable characters (letters, numbers, punctuation and so on) in XEmacs buffers are displayed as such. @key{LFD} (line feed, character code @samp{\012} (octal)) is the same as a newline character; it is displayed by starting a new line. @key{TAB} is displayed by moving to the next tab stop column (usually every 8 spaces). Other control characters below #x20 (hexadecimal) are displayed as a caret (@samp{^}) followed by the non-control version of the character; thus, @kbd{C-a} is displayed as @samp{^A}. Characters between (hexadecimal) #x80 and #xA0 are displayed with octal escape sequences; thus, character code 243 (octal), also called @kbd{M-#} when used as an input character, is displayed as @samp{\243}. The variable @code{ctl-arrow} may be used to alter this behavior. @xref{Display Vars}. As a rule, its value limits octal display to those characters in the range just mentioned, and otherwise characters are treated as printable, and will be displayed as themselves when the relevant fonts are available. @node Commands, Non-Latin keyboards, Character Representation, Keystrokes @section Keys and Commands @cindex binding @cindex customization @cindex keymap @cindex function @cindex command This manual is full of passages that tell you what particular keys do. But Emacs does not assign meanings to keys directly. Instead, Emacs assigns meanings to @dfn{functions}, and then gives keys their meanings by @dfn{binding} them to functions. A function is a Lisp object that can be executed as a program. Usually it is a Lisp symbol that has been given a function definition; every symbol has a name, usually made of a few English words separated by dashes, such as @code{next-line} or @code{forward-word}. It also has a @dfn{definition}, which is a Lisp program. Only some functions can be the bindings of keys; these are functions whose definitions use @code{interactive} to specify how to call them interactively. Such functions are called @dfn{commands}, and their names are @dfn{command names}. More information on this subject will appear in the @i{XEmacs Lisp Reference Manual}. The bindings between keys and functions are recorded in various tables called @dfn{keymaps}. @xref{Key Bindings}, for more information on key sequences you can bind commands to. @xref{Keymaps}, for information on creating keymaps. When we say ``@kbd{C-n} moves down vertically one line'' we are glossing over a distinction that is irrelevant in ordinary use but is vital in understanding how to customize Emacs. The function @code{next-line} is programmed to move down vertically. @kbd{C-n} has this effect @i{because} it is bound to that function. If you rebind @kbd{C-n} to the function @code{forward-word} then @kbd{C-n} will move forward by words instead. Rebinding keys is a common method of customization.@refill The rest of this manual usually ignores this subtlety to keep things simple. To give the customizer the information needed, we often state the name of the command that really does the work in parentheses after mentioning the key that runs it. For example, we will say that ``The command @kbd{C-n} (@code{next-line}) moves point vertically down,'' meaning that @code{next-line} is a command that moves vertically down and @kbd{C-n} is a key that is standardly bound to it. @cindex variables While we are on the subject of information for customization only, it's a good time to tell you about @dfn{variables}. Often the description of a command will say, ``To change this, set the variable @code{mumble-foo}.'' A variable is a name used to remember a value. Most of the variables documented in this manual exist just to facilitate customization: some command or other part of Emacs uses the variable and behaves differently depending on its setting. Until you are interested in customizing, you can ignore the information about variables. When you are ready to be interested, read the basic information on variables, and then the information on individual variables will make sense. @xref{Variables}. @node Non-Latin keyboards, ,Commands, Keystrokes @cindex russian @cindex greek @cindex ``russian c-x'' @cindex try-alternate-layouts-for-commands If your computer has a keyboard designed for a language like Russian or Greek, where you have to go to some trouble to type Roman-alphabet characters, then typing @kbd{C-f} to call @code{forward-character} is very inconvenient. To address this, XEmacs allows you to pretend that your keyboard has a US layout for such commands. That is, you can type @kbd{C-Cyrillic_che C-Cyrillic_a} and XEmacs will work out that it should call the command that @kbd{C-x C-f} is bound to@footnote{You can, of course, override this with an explicit binding for @kbd{C-Cyrillic_che C-Cyrillic_a} to something else.}. Function keys, like @key{F1}, @key{Shift} or @key{Control} are not handled by this, just alphanumeric characters and punctuation. The main user variable associated with this functionality is @code{try-alternate-layouts-for-commands}. Setting this to @code{nil} inhibits this translation, which would be appropriate if your keyboard can handle the Roman alphabet but doesn't have the US layout, and you want to avoid the possible confusion. If @code{try-alternate-layouts-for-commands} is @code{t} but this functionality doesn't work for you under X11, check the value of the variable @code{x-us-keymap-description}. This is a hardware-specific map from key codes to the US layout, and can be initialized from the output of @code{xmodmap -pke}; see the documentation for that variable and for @code{x-us-keymap-first-keycode}.