Mercurial > hg > xemacs-beta
view man/new-users-guide/custom1.texi @ 4690:257b468bf2ca
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we need such
functionality if we're going to have a reliable and portable
#'query-coding-region implementation. However, this change doesn't yet
provide #'query-coding-region for the mswindow-multibyte coding systems,
there should be no functional differences between an XEmacs with this change
and one without it.
src/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we
need such functionality if we're going to have a reliable and
portable #'query-coding-region implementation. However, this
change doesn't yet provide #'query-coding-region for the
mswindow-multibyte coding systems, there should be no functional
differences between an XEmacs with this change and one without it.
* mule-coding.c (struct fixed_width_coding_system):
Add a new coding system type, fixed_width, and implement it. It
uses the CCL infrastructure but has a much simpler creation API,
and its own query_method, formerly in lisp/mule/mule-coding.el.
* unicode.c:
Move the Unicode query method implementation here from
unicode.el.
* lisp.h: Declare Fmake_coding_system_internal, Fcopy_range_table
here.
* intl-win32.c (complex_vars_of_intl_win32):
Use Fmake_coding_system_internal, not Fmake_coding_system.
* general-slots.h: Add Qsucceeded, Qunencodable, Qinvalid_sequence
here.
* file-coding.h (enum coding_system_variant):
Add fixed_width_coding_system here.
(struct coding_system_methods):
Add query_method and query_lstream_method to the coding system
methods.
Provide flags for the query methods.
Declare the default query method; initialise it correctly in
INITIALIZE_CODING_SYSTEM_TYPE.
* file-coding.c (default_query_method):
New function, the default query method for coding systems that do
not set it. Moved from coding.el.
(make_coding_system_1):
Accept new elements in PROPS in #'make-coding-system; aliases, a
list of aliases; safe-chars and safe-charsets (these were
previously accepted but not saved); and category.
(Fmake_coding_system_internal):
New function, what used to be #'make-coding-system--on Mule
builds, we've now moved some of the functionality of this to
Lisp.
(Fcoding_system_canonical_name_p):
Move this earlier in the file, since it's now called from within
make_coding_system_1.
(Fquery_coding_region):
Move the implementation of this here, from coding.el.
(complex_vars_of_file_coding):
Call Fmake_coding_system_internal, not Fmake_coding_system;
specify safe-charsets properties when we're a mule build.
* extents.h (mouse_highlight_priority, Fset_extent_priority,
Fset_extent_face, Fmap_extents):
Make these available to other C files.
lisp/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
* coding.el:
Consolidate code that depends on the presence or absence of Mule
at the end of this file.
(default-query-coding-region, query-coding-region):
Move these functions to C.
(default-query-coding-region-safe-charset-skip-chars-map):
Remove this variable, the corresponding C variable is
Vdefault_query_coding_region_chartab_cache in file-coding.c.
(query-coding-string): Update docstring to reflect actual multiple
values, be more careful about not modifying a range table that
we're currently mapping over.
(encode-coding-char): Make the implementation of this simpler.
(featurep 'mule): Autoload #'make-coding-system from
mule/make-coding-system.el if we're a mule build; provide an
appropriate compiler macro.
Do various non-mule compatibility things if we're not a mule
build.
* update-elc.el (additional-dump-dependencies):
Add mule/make-coding-system as a dump time dependency if we're a
mule build.
* unicode.el (ccl-encode-to-ucs-2):
(decode-char):
(encode-char):
Move these earlier in the file, for the sake of some byte compile
warnings.
(unicode-query-coding-region):
Move this to unicode.c
* mule/make-coding-system.el:
New file, not dumped. Contains the functionality to rework the
arguments necessary for fixed-width coding systems, and contains
the implementation of #'make-coding-system, which now calls
#'make-coding-system-internal.
* mule/vietnamese.el (viscii):
* mule/latin.el (iso-8859-2):
(windows-1250):
(iso-8859-3):
(iso-8859-4):
(iso-8859-14):
(iso-8859-15):
(iso-8859-16):
(iso-8859-9):
(macintosh):
(windows-1252):
* mule/hebrew.el (iso-8859-8):
* mule/greek.el (iso-8859-7):
(windows-1253):
* mule/cyrillic.el (iso-8859-5):
(koi8-r):
(koi8-u):
(windows-1251):
(alternativnyj):
(koi8-ru):
(koi8-t):
(koi8-c):
(koi8-o):
* mule/arabic.el (iso-8859-6):
(windows-1256):
Move all these coding systems to being of type fixed-width, not of
type CCL. This allows the distinct query-coding-region for them to
be in C, something which will eventually allow us to implement
query-coding-region for the mswindows-multibyte coding systems.
* mule/general-late.el (posix-charset-to-coding-system-hash):
Document why we're pre-emptively persuading the byte compiler that
the ELC for this file needs to be written using escape-quoted.
Call #'set-unicode-query-skip-chars-args, now the Unicode
query-coding-region implementation is in C.
* mule/thai-xtis.el (tis-620):
Don't bother checking whether we're XEmacs or not here.
* mule/mule-coding.el:
Move the eight bit fixed-width functionality from this file to
make-coding-system.el.
tests/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
* automated/mule-tests.el:
Check a coding system's type, not an 8-bit-fixed property, for
whether that coding system should be treated as a fixed-width
coding system.
* automated/query-coding-tests.el:
Don't test the query coding functionality for mswindows-multibyte
coding systems, it's not yet implemented.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 19 Sep 2009 22:53:13 +0100 |
parents | 47c30044fc4e |
children |
line wrap: on
line source
@comment node-name, next, previous, up @node Customization Basics, Help, Edit, Top @chapter Customize key bindings and menus @cindex init.el @cindex customize @findex eval-region When you start Emacs, it reads the file @file{~/.xemacs/init.el} in the @file{.xemacs/} subdirectory of your home directory. You can use this file to initialize and customize Emacs to your liking. This file should contain lisp-code. You can customize your @file{init.el} file to create new menus, disable menus, change key bindings, enable a minor mode, etc. Any kind of customization affects only a particular Emacs job that you do them in. If you want to save your customizations `permanently' i.e. for future use also, you have to put it in your @samp{init.el} file. After you make changes to your @file{init.el} file and save it, the changes will be effective only after you start Emacs again i.e. for a new Emacs process. To try out some of the examples in this section, highlight that region and evaluate the region by giving the command @kbd{M-x eval-region}. You will be able to see the results of your customizations in that Emacs session only (@pxref{Lisp Eval,,,xemacs,XEmacs User's Manual}). @comment node-name, next, previous, up @menu * Customizing key Bindings:: Changing Key Bindings * Customizing Menus:: Adding, Deleting, Enabling and Disabling Menus @end menu @node Customizing key Bindings, Customizing Menus, Customization Basics, Customization Basics @section Customize key bindings @cindex key bindings @cindex keystrokes Most of Emacs commands use key sequences. @xref{Keystrokes,,,xemacs,XEmacs User's Manual}, for more information about Keys and Commands. In Emacs, the keys themselves carry no meaning unless they are bound to a function. For example, @kbd{C-n} moves the cursor to the next line because its bound to the function @b{next-line}. Similarly, @kbd{C-p} moves to the previous line because its bound to the function @b{previous-line}. The functions themselves define a particular behavior. You can customize the key @kbd{C-n} to move to the previous line by binding it to @b{previous-line} and @kbd{C-p} to move to the next line by binding it to @b{next-line}. To bind keys to globally run commands you need to use the following syntax in your @b{init.el} file: @cindex binding keys @example @code{(global-set-key @var{keys} @var{cmd})} @end example @noindent Here, @code{global-set-key} is a function which will bind the @dfn{keys} to the specified @dfn{cmd}. For example, if you type the following in your @b{init.el} file: @example (global-set-key "\C-p" 'next-line) (global-set-key "\C-n" 'previous-line) @end example @noindent then @kbd{C-p} will move to the next line and @kbd{C-n} to the previous line. You can also disable a key binding, by using @samp{nil} as the @var{cmd} in the syntax stated above. Here, @samp{nil} stands for @samp{false} which means disable a command or turn off a feature. If you want to enable a command or turn on a particular feature use @samp{t} which stands for @samp{true}. For example, if you do not wish @kbd{C-x C-c} to @samp{Exit Emacs} you can type the following expression in your @file{init.el} file: @example (global-set-key "\C-x\C-c" nil) @end example @noindent You might want to have this statement in your @file{init.el} file because its easy to hit this command by mistake and it could be annoying to exit Emacs unintentionally. There is an @b{Exit Emacs} option in the @b{File menu} which you might want to use instead. To make a particular key undefined you can also use: @example (global-unset-key "\C-x\C-c") @end example @noindent Now if you use the command @kbd{C-x C-c}, you will get an error saying that the command is undefined. Some other customizations you could try are: @itemize @bullet @item @example (global-set-key 'button3 'beginning-of-buffer) @end example @noindent Now when you press the third button of your mouse, the cursor will be placed at the @code{beginning-of-buffer}. @item @example (global-set-key 'f1 'goto-line) @end example @noindent If you press the @key{F1} key, you will be prompted for a line number. After you type the line number and hit @key{RET}, the cursor will be placed on that line number. @item @example (global-set-key 'f2 'undo) @end example Pressing @key{F2} will undo the last command. If you have a @key{undo} key on your keyboard, try binding that key to the undo command. @end itemize Another syntax for customizing key bindings is: @code{(define-key @var{keymap} @var{keys} @var{def})} It defines @var{keys} to run @var{def} in the keymap @var{keymap}. @var{keymap} is a keymap object which records the bindings of keys to the commands that they run. @var{keys} is the sequence of keystrokes to bind. @var{def} is anything that can be a key's definition: Look at the following two examples: @example (define-key global-map "\C-xl" 'make-symbolic-link) (define-key c-mode-map "\C-xl" 'make-symbolic-link) @end example @findex make-symbolic-link @noindent Both the examples bind the key @kbd{C-xl} to run the function @code{make-symbolic-link} (@pxref{Misc File Ops,,,xemacs,XEmacs User's Manual}). However, the second example will bind the key only for C mode. @xref{Major Modes,,,xemacs,XEmacs User's Manual}, for more information on Major Modes in XEmacs. @comment node-name, next, previous, up @node Customizing Menus, , Customizing key Bindings, Customization Basics @section Customizing Menus @cindex customize menus @cindex delete menus @cindex disable menus @findex add-menu-item @cindex add menus You can customize any of the XEmacs Pull-down-Menus. You can create your own menu, delete an existing one, enable a menu or disable a menu. For more information on the default menus available to you, @xref{Pull-down Menus}. Some of the functions which are available to you for customization are: @enumerate @item add-menu-item: (@var{menu-name} @var{item-name} @var{function} @var{enabled-p} &optional @var{before}) This function will add a menu item to a menu, creating the menu first if necessary. If the named item already exists, the menu will remain unchanged. For example, if you add the following example to your @file{init.el} file or evaluate it (@pxref{Customization Basics}), @example (add-menu-item '("Edit") "Replace String" replace-string t "Clear") @end example @noindent a sub-menu @b{Replace String} will be created under @b{Edit} menu before the sub-menu @b{Clear}. The @b{Edit} menu will now look like: @example Undo C-x u Cut cut Copy copy Paste paste Replace String Clear Start Macro Recording C-x( End Macro Recording C-x) Execute Last Macro C-xe @end example @noindent @b{Replace String} will now execute the function @code{replace-string}. Select this menu item. Emacs will prompt you for a string name to be replaced. Type a string and hit @key{RET}. Now type a new string to replace the old string and hit @key{RET}. All occurrences of the old string will be replaced by the new string. In this example, @samp{Edit} is the @var{menu-name} which identifies the menu into which the new menu item should be inserted. @samp{Replace String} is the @var{item-name} which names the menu item to be added. @samp{replace-string} is the @var{function} i.e. the command to be invoked when the menu item "Replace String" is selected. @samp{t} is the @var{enabled-p} parameter which controls whether the menu item is selectable or not. This parameter can be either @code{t} (selectable), @code{nil} (not selectable), or a form to evaluate. This form is evaluated just before the menu is displayed, and the menu item will be selectable if the form returns non-@code{nil}. @samp{Clear} is the @var{&optional before} parameter which is the name of the menu before which the new menu or sub-menu should be added. The @var{&optional} string means that this parameter is optional. You do not need to specify this parameter. If you do not specify this parameter in the example above, the @b{Replace String} menu item will be added at the end of the list of sub-menus in the @b{Edit} menu i.e. after @b{Execute Last Macro}. If you wish to add a new menu to the menubar, try: @example (add-menu-item nil "Bot" 'end-of-buffer t) @end example @noindent This will create a new menu @b{Bot} on the menu bar. Selecting this menu will take you to the end of the buffer. Using @code{nil} for the parameter @var{menu-name} will create a new menu. Your menu-bar will now look like: @example File Edit Options Buffers Bot Help @end example The following example will illustrate how you can add sub-menus to the submenus themselves: @example (add-menu-item '("File" "Management") "Copy File" 'copy-file t) (add-menu-item '("File" "Management") "Delete File" 'delete-file t) (add-menu-item '("File" "Management") "Rename File" 'rename-file t) @end example @noindent This will create a sub-menu @b{Management} under the @b{File} menu. When you select the submenu @b{Management}, it will contain three submenus: @b{Copy File}, @b{Delete File} and @b{Rename File}. @findex delete-menu-item @cindex deleting menu items @item delete-menu-item: (@var{menu-path}) This function will remove the menu item defined by @var{menu-name} from the menu hierarchy. Look at the following examples and the comments just above them which specify what the examples do. @example ;; deletes the "Replace String" menu item created earlier (delete-menu-item '("Edit" "Replace String")) ;; deletes the "Bot" menu created earlier (delete-menu-item '("Bot")) ;; deletes the sub-menu "Copy File" created earlier (delete-menu-item '("File" "File Management" "Copy File")) ;; deletes the sub-menu "Delete File" created earlier (delete-menu-item '("File" "Management" "Delete File")) ;; deletes the sub-menu "Rename File" created earlier (delete-menu-item '("File" "Management" "Rename File")) @end example @findex disable-menu-item @cindex disabling menu items @item disable-menu-item: (@var{menu-name}) Disables the specified menu item. The following example @example (disable-menu-item '("File" "Management" "Copy File")) @end example @noindent will make the @b{Copy File} item unselectable. This menu-item would still be there but it will appear faded which would mean that it cannot be selected. @findex enable-menu-item @cindex enabling menu items @item enable-menu-item: (@var{menu-name}) Enables the specified previously disabled menu item. @example (enable-menu-item '("File" "Management" "Copy File")) @end example @noindent This will enable the sub-menu @b{Copy File}, which was disabled by the earlier command. @findex relabel-menu-items @cindex relabelling menu items @item relabel-menu-item: (@var{menu-name} @var{new-name}) Change the string of the menu item specified by @var{menu-name} to @var{new-name}. @example (relabel-menu-item '("File" "Open...") "Open File") @end example This example will rename the @b{Open...} menu item from the @b{File} menu to @b{Open File}. @end enumerate