1 @comment node-name, next, previous, up
2 @node Other Customizations, Select and Move, Files, Top
3 @chapter Other Customizations
8 You can modify the behavior of Emacs in minor ways permanently by
9 putting your changes in your @file{init.el} file. This file contains Lisp
10 function call expressions. Each of these expressions will consist of a
11 function name followed by arguments, all surrounded by parentheses. For
12 example, to turn on the auto-fill-mode (i.e. break lines automatically
13 when they become too long) , put the following line in your
17 (add-hook 'text-mode-hook
18 '(lambda() (auto-fill-mode 1)))
22 Emacs has a function named "turn-on-auto-fill" which is defined as
23 "(lambda() (auto-fill-mode 1))". Therefore you can also write the above
27 (add-hook 'text-mode-hook 'turn-on-auto-fill)
31 Emacs provides a number of hooks for the sake of customization. The hook
32 variables contain list of functions to be called with no arguments. To
33 turn on the auto-fill-mode, add the appropriate hook as shown in the
36 Similarly, to enable the "font-lock mode" which displays your program in
37 different fonts and colors(@pxref{Modes}), put the following in your
38 @file{init.el} file. The comments above the statement explain what the
42 ;;; enables the font-lock-mode in Lisp Mode
43 (add-hook 'lisp-mode-hook 'turn-on-font-lock)
45 ;;; enables the font-lock-mode in Texinfo Mode
46 (add-hook 'texinfo-mode-hook 'turn-on-font-lock)
48 ;;; enables the font-lock mode in C Mode
49 (add-hook 'c-mode-hook 'turn-on-font-lock)
52 To turn on the font-lock mode in other Major Modes like emacs-lisp, just
53 put the name of the mode with "-hook" appended to it as the middle
54 parameter in the above examples. You can also select the color that the
55 functions, comments or other keywords should be displayed in :
58 ;;; the function names will now be displayed in blue color
59 (set-face-foreground 'font-lock-function-name-face "blue")
61 ;;; the comments will be displayed in forest green
62 (set-face-foreground 'font-lock-comment-face "forest green")
66 For other customizations regarding the font-lock face, look at the file
67 @file{/usr/local/lib/xemacs-VERSION/etc/sample.init.el}.
71 @comment node-name, next, previous, up
73 * Setting Variables:: Customizing Emacs variables
74 * Init File:: Some examples of Lisp expressions in
78 @node Setting Variables, Init File, Other Customizations, Other Customizations
79 @section Other Customizations
80 @cindex setting variables
81 @findex describe-variable
83 In XEmacs, @dfn{variables} are used for internal record-keeping and
84 customizations. There are some variables called "options" which you can
85 use for customizations. To examine a variable use:
88 ;;; print the value and documentation of the variable, use either of the
89 ;;; following commands
94 After you type any of the above commands, you will be prompted for a
95 variable name in the @dfn{echo area}. Type in the name of the variable,
96 for example, type @code{case-fold-search} @key{RET}
97 Your window will split into two and you will see the following message
101 case-fold-search's value is t
102 This value is specific to the current buffer.
105 *Non-nil if searches should ignore case.
106 Automatically becomes buffer-local when set in any fashion.
111 Since this variable's value is 't' searches will ignore case. If you
112 want case-sensitive-search (i.e. if you are searching for "Foo" and you do
113 not want "foo" to be included in the search, you need to set this
114 variable to "nil". In order to do that, use:
122 Emacs will prompt you for the variable which you wish to set. Type in
123 "case-fold-search" and hit @key{RET}. You will see the following
127 Set case-fold-search to value:
131 Type "nil" and hit @key{RET}. Now if you again use @kbd{M-x describe
132 variable} , you will see that the new value of case-fold-search will be
133 "nil" and your searches will be case-sensitive. This will be effective
134 only for that Emacs session. If you want to change the value of a
135 variable permanently put the following statement in your @file{init.el}
139 (setq case-fold-search nil)
143 This statement will make searches case-sensitive only in the current
144 buffer which is the @file{init.el} file. This will not be very useful. To
145 make searches case-sensitive globally in all buffers, use:
148 (setq-default case-fold-search nil)
151 If you want to change the value of any other variable, use :
154 (setq <variable-name> <new value>)
158 "setq" will assign the "new value" to the "variable-name" .
161 If you want a list of the "options" i.e. the variables available for
168 ;;; displays a buffer listing names, values and documentation of options
171 ;;; displays options and allows you to edit those list of options
177 Try these options. If you are using edit-options to edit a variable,
178 just point at the variable you wish to edit and use one of the following
183 Set the value of the variable to t (non-nil).
185 Set the value of the variable to nil.
187 Move to the next variable.
189 Move to the previous variable.
193 There are some other options available to make the value of a variable
194 local to a buffer and then to switch to its global value. You can also
195 have a @dfn{local variables list} in a file which specifies the values
196 to use for certain Emacs variables when you edit that
197 file. @xref{Variables,,,xemacs,XEmacs User's Manual}, for information on
201 @comment node-name, next, previous, up
202 @node Init File, , Setting Variables, Other Customizations
203 @section Init File Examples
204 @cindex init file examples
206 For customizing Emacs, you need to put Lisp expressions in your
207 @file{init.el} file. The following are some useful Lisp expressions. If
208 you find any of them useful, just type them in your @file{init.el} file:
212 The following expression will make @key{TAB} in C mode insert a real tab
213 character if the cursor or point is in the middle of the line. Now
214 hitting the @key{TAB} key will indent a line only if the cursor is at
215 the left margin or in the line's indentation:
218 (setq c-tab-always-indent nil)
222 The value of the variable @code{c-tab-always-indent} is usually @samp{t}
223 for @samp{true}. When this variable is true, then hitting the @key{TAB}
224 key always indents the current line.
227 This expression will turn on the @var{auto-fill-mode} when you are in
231 (setq text-mode-hook 'turn-on-auto-fill)
234 This mode will automatically break lines when you type a space so that
235 the lines don't become too long. The length of the lines is controlled
236 by the variable @code{fill-column}. You can set this variable to a value
237 you wish. Look at the documentation for this variable to see its default
238 value. To change the value to 75 for example, use:
242 (setq-default fill-column 75)
246 This will change the value of this variable globally.
249 @findex eval-expression
250 The following expression will enable the use of @var{eval-expression}
251 without confirmation:
254 (put 'eval-expression 'disabled nil)
258 Now when you use @var{eval-expression}, it will print the value of the
259 expression you specify in the @dfn{echo area} without confirming with
263 This expression will remove the binding of @kbd{C-x C-c}, because its
264 easy to hit this key by mistake and you will exit Emacs
265 unintentionally. You can use the @b{Exit Emacs} option from the @b{File}
269 (global-set-key "\C-x\C-c" nil)
273 Now if you type @kbd{C-x C-c}, you won't exit Emacs.
276 The following expression will make the @key{BACKSPACE} and the @key{DEL}
277 key work in the same manner:
280 (global-set-key 'backspace [delete])
284 This expression will make searches case sensitive:
287 (setq-default case-fold-search nil)
291 If we use "setq" instead of "setq-default" then searches will be
292 case-sensitive only in the current buffer's local value. In this case the
293 buffer would be the @file{init.el} file. Since this would not be too
294 helpful and we want to have case-sensitive searches in all buffers, we
295 have to use "setq-default".
298 This expression will enable the font-lock mode when you are using
302 (add-hook 'texinfo-mode-hook 'turn-on-font-lock)
306 @xref{Minor Modes}, for information on font-lock mode.
309 Rebinds the key @kbd{C-x l} to run the function
310 @code{make-symbolic-link}:
313 (global-set-key "\C-xl" 'make-symbolic-link)
317 We use the single quote before "make-symbolic-link" because its a
318 function name. You can also use the following expression which does the
322 (define-key global-map "C-xl" 'make-symbolic-link)
326 The following expression will bind @kbd{C-x l} to run the function
327 @code{make-symbolic-link} in C mode only:
330 (define-key c-mode-map "C-xl" 'make-symbolic-link)
334 Instead of binding @kbd{C-xl} to run @code{make-symbolic-link}, you can
335 bind the @key{F1} key to run this function:
338 (define-key c-mode-map 'f1 'make-symbolic-link)
342 Here, you have to use lower case for naming function keys like @key{F1}.
345 You can bind the function @code{undo} i.e. @kbd{C-x u} to any key, for
349 (global-set-key 'f2 'undo)
353 The following statement will display the current time in the modeline of
357 @cindex displaying time
363 This displays the current line number on which the cursor is present in
367 (setq line-number-mode t)
371 If you don't want the text to be highlighted when you use commands for
372 marking regions so as to use the @dfn{kill} and @dfn{yank} commands
373 later, you can use the following expression in your @file{init.el} file:
375 @vindex zmacs-regions
377 (setq zmacs-regions nil)
381 Now if you use a command like @kbd{C-x C-p} (@code{mark-page}), the text
382 will not be highlighted.
385 To control the number of buffers listed when you select the @b{Buffers}
386 menu, you need to set the variable @code{buffers-menu-max-size} to
387 whatever value you wish. For example, if you want 20 buffers to be listed
388 when you select @b{Buffers} use:
390 @vindex buffers-menu-max-size
392 (setq buffers-menu-max-size 20)
396 If you want the window title area to display the full directory/name of
397 the current buffer's file, and not just the name, use:
399 @vindex frame-title-format
401 (setq frame-title-format "%S: %f")
405 To get rid of the menu, use :
412 If you want an extensive menu-bar use the following expression in your
420 If you want to write your own menus, you can look at some of the
422 @file{/usr/local/lib/xemacs/xemacs-packages/lisp/edit-utils/big-menubar.el} file.
426 For more information on initializing your @file{init.el} file,
427 @xref{Init File,,,xemacs,XEmacs User's Manual}. You should also look at
428 @file{/usr/local/lib/xemacs-VERSION/etc/sample.init.el}, which is a sample
429 @file{init.el} file. It contains some of the commonly desired
430 customizations in Emacs.