]> code.delx.au - gnu-emacs/blob - lisp/cus-start.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / cus-start.el
1 ;;; cus-start.el --- define customization properties of builtins
2 ;;
3 ;; Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: internal
7 ;; Package: emacs
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25 ;;
26 ;; This file adds customize support for built-in variables.
27
28 ;; While dumping Emacs, this file is loaded, but it only records
29 ;; the standard values; it does not do the rest of the job.
30 ;; Later on, if the user makes a customization buffer,
31 ;; this file is loaded again with (require 'cus-start);
32 ;; then it does the whole job.
33
34 ;;; Code:
35
36 ;; Elements of this list have the form:
37 ;; SYMBOL GROUP TYPE VERSION REST...
38 ;; SYMBOL is the name of the variable.
39 ;; GROUP is the custom group to which it belongs (may also be a list
40 ;; of groups)
41 ;; TYPE is the defcustom :type.
42 ;; VERSION is the defcustom :version (or nil).
43 ;; REST is a set of :KEYWORD VALUE pairs. Accepted :KEYWORDs are:
44 ;; :standard - standard value for SYMBOL (else use current value)
45 ;; :set - custom-set property
46 ;; :risky - risky-local-variable property
47 ;; :safe - safe-local-variable property
48 ;; :tag - custom-tag property
49 (let ((all '(;; alloc.c
50 (gc-cons-threshold alloc integer)
51 (garbage-collection-messages alloc boolean)
52 ;; buffer.c
53 (mode-line-format mode-line sexp) ;Hard to do right.
54 (major-mode internal function)
55 (case-fold-search matching boolean)
56 (fill-column fill integer)
57 (left-margin fill integer)
58 (tab-width editing-basics integer)
59 (ctl-arrow display boolean)
60 (truncate-lines display boolean)
61 (word-wrap display boolean)
62 (selective-display-ellipses display boolean)
63 (indicate-empty-lines fringe boolean)
64 (indicate-buffer-boundaries
65 fringe
66 (choice
67 (const :tag "No indicators" nil)
68 (const :tag "On left, with arrows" left)
69 (const :tag "On right, with arrows" right)
70 (set :tag "Pick your own design"
71 :value ((t . nil))
72 :format "%{%t%}:\n%v\n%d"
73 :doc "You can specify a default and then override it \
74 for individual indicators.
75 Leaving \"Default\" unchecked is equivalent with specifying a default of
76 \"Do not show\"."
77 (choice :tag "Default"
78 :value (t . nil)
79 (const :tag "Do not show" (t . nil))
80 (const :tag "On the left" (t . left))
81 (const :tag "On the right" (t . right)))
82 (choice :tag "Top"
83 :value (top . left)
84 (const :tag "Do not show" (top . nil))
85 (const :tag "On the left" (top . left))
86 (const :tag "On the right" (top . right)))
87 (choice :tag "Bottom"
88 :value (bottom . left)
89 (const :tag "Do not show" (bottom . nil))
90 (const :tag "On the left" (bottom . left))
91 (const :tag "On the right" (bottom . right)))
92 (choice :tag "Up arrow"
93 :value (up . left)
94 (const :tag "Do not show" (up . nil))
95 (const :tag "On the left" (up . left))
96 (const :tag "On the right" (up . right)))
97 (choice :tag "Down arrow"
98 :value (down . left)
99 (const :tag "Do not show" (down . nil))
100 (const :tag "On the left" (down . left))
101 (const :tag "On the right" (down . right))))
102 (other :tag "On left, no arrows" t)))
103 (scroll-up-aggressively windows
104 (choice (const :tag "off" nil) number)
105 "21.1")
106 (scroll-down-aggressively windows
107 (choice (const :tag "off" nil) number)
108 "21.1")
109 (line-spacing display (choice (const :tag "none" nil) integer)
110 "22.1")
111 (cursor-in-non-selected-windows
112 cursor boolean nil
113 :tag "Cursor In Non-selected Windows"
114 :set #'(lambda (symbol value)
115 (set-default symbol value)
116 (force-mode-line-update t)))
117 (transient-mark-mode editing-basics boolean nil
118 :standard (not noninteractive)
119 :initialize custom-initialize-delay
120 :set custom-set-minor-mode)
121 ;; callint.c
122 (mark-even-if-inactive editing-basics boolean)
123 ;; callproc.c
124 (shell-file-name execute file)
125 (exec-path execute
126 (repeat (choice (const :tag "default directory" nil)
127 (directory :format "%v"))))
128 ;; charset.c
129 (charset-map-path installation
130 (repeat (directory :format "%v")))
131 ;; coding.c
132 (inhibit-eol-conversion mule boolean)
133 (eol-mnemonic-undecided mule string)
134 (eol-mnemonic-unix mule string)
135 (eol-mnemonic-dos mule string)
136 (eol-mnemonic-mac mule string)
137 (file-coding-system-alist
138 mule
139 (alist
140 :key-type (regexp :tag "File regexp")
141 :value-type (choice
142 :value (undecided . undecided)
143 (cons :tag "Encoding/decoding pair"
144 :value (undecided . undecided)
145 (coding-system :tag "Decoding")
146 (coding-system :tag "Encoding"))
147 (coding-system
148 :tag "Single coding system"
149 :value undecided
150 :match (lambda (widget value)
151 (and value (not (functionp value)))))
152 (function :value ignore))))
153 ;; dired.c
154 (completion-ignored-extensions dired
155 (repeat (string :format "%v")))
156 ;; dispnew.c
157 (baud-rate display integer)
158 (inverse-video display boolean)
159 (visible-bell display boolean)
160 (no-redraw-on-reenter display boolean)
161 ;; editfns.c
162 (user-full-name mail string)
163 ;; eval.c
164 (max-specpdl-size limits integer)
165 (max-lisp-eval-depth limits integer)
166 (max-mini-window-height limits
167 (choice (const :tag "quarter screen" nil)
168 number) "23.1")
169 (stack-trace-on-error debug
170 (choice (const :tag "off")
171 (repeat :menu-tag "When"
172 :value (nil)
173 (symbol :format "%v"))
174 (const :tag "always" t)))
175 (debug-on-error debug
176 (choice (const :tag "off")
177 (repeat :menu-tag "When"
178 :value (nil)
179 (symbol :format "%v"))
180 (const :tag "always" t)))
181 (debug-ignored-errors debug (repeat (choice symbol regexp)))
182 (debug-on-quit debug
183 (choice (const :tag "off")
184 (repeat :menu-tag "When"
185 :value (nil)
186 (symbol :format "%v"))
187 (const :tag "always" t)))
188 ;; fileio.c
189 (delete-by-moving-to-trash auto-save boolean "23.1")
190 (auto-save-visited-file-name auto-save boolean)
191 ;; filelock.c
192 (temporary-file-directory
193 ;; Darwin section added 24.1, does not seem worth :version bump.
194 files directory nil
195 :standard
196 (file-name-as-directory
197 ;; FIXME ? Should there be Ftemporary_file_directory to do this
198 ;; more robustly (cf set_local_socket in emacsclient.c).
199 ;; It could be used elsewhere, eg Fcall_process_region,
200 ;; server-socket-dir. See bug#7135.
201 (cond ((memq system-type '(ms-dos windows-nt))
202 (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP")
203 "c:/temp"))
204 ((eq system-type 'darwin)
205 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
206 ;; See bug#7135.
207 (let ((tmp (ignore-errors
208 (shell-command-to-string
209 "getconf DARWIN_USER_TEMP_DIR"))))
210 (and (stringp tmp)
211 (setq tmp (replace-regexp-in-string
212 "\n\\'" "" tmp))
213 ;; Handles "getconf: Unrecognized variable..."
214 (file-directory-p tmp)
215 tmp))
216 "/tmp"))
217 (t
218 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
219 "/tmp"))))
220 :initialize custom-initialize-delay)
221 ;; fns.c
222 (use-dialog-box menu boolean "21.1")
223 (use-file-dialog menu boolean "22.1")
224 (focus-follows-mouse frames boolean "20.3")
225 ;; frame.c
226 (default-frame-alist frames
227 (repeat (cons :format "%v"
228 (symbol :tag "Parameter")
229 (sexp :tag "Value"))))
230 (mouse-highlight mouse (choice (const :tag "disabled" nil)
231 (const :tag "always shown" t)
232 (other :tag "hidden by keypress" 1))
233 "22.1")
234 (make-pointer-invisible mouse boolean "23.2")
235 (menu-bar-mode frames boolean nil
236 ;; FIXME?
237 ; :initialize custom-initialize-default
238 :set custom-set-minor-mode)
239 (tool-bar-mode (frames mouse) boolean nil
240 ; :initialize custom-initialize-default
241 :set custom-set-minor-mode)
242 ;; fringe.c
243 (overflow-newline-into-fringe fringe boolean)
244 ;; indent.c
245 (indent-tabs-mode indent boolean)
246 ;; keyboard.c
247 (meta-prefix-char keyboard character)
248 (auto-save-interval auto-save integer)
249 (auto-save-timeout auto-save (choice (const :tag "off" nil)
250 (integer :format "%v")))
251 (echo-keystrokes minibuffer number)
252 (polling-period keyboard integer)
253 (double-click-time mouse (restricted-sexp
254 :match-alternatives (integerp 'nil 't)))
255 (double-click-fuzz mouse integer "22.1")
256 (inhibit-local-menu-bar-menus menu boolean)
257 (help-char keyboard character)
258 (help-event-list keyboard (repeat (sexp :format "%v")))
259 (menu-prompting menu boolean)
260 (select-active-regions killing
261 (choice (const :tag "always" t)
262 (const :tag "only shift-selection or mouse-drag" only)
263 (const :tag "off" nil))
264 "24.1")
265 (suggest-key-bindings keyboard (choice (const :tag "off" nil)
266 (integer :tag "time" 2)
267 (other :tag "on")))
268
269 ;; This is not good news because it will use the wrong
270 ;; version-specific directories when you upgrade. We need
271 ;; customization of the front of the list, maintaining the standard
272 ;; value intact at the back.
273 ;;; (load-path environment
274 ;;; (repeat (choice :tag "[Current dir?]"
275 ;;; :format "%[Current dir?%] %v"
276 ;;; (const :tag " current dir" nil)
277 ;;; (directory :format "%v"))))
278 ;; minibuf.c
279 (enable-recursive-minibuffers minibuffer boolean)
280 (history-length minibuffer
281 (choice (const :tag "Infinite" t) integer)
282 "22.1")
283 (history-delete-duplicates minibuffer boolean "22.1")
284 (read-buffer-completion-ignore-case minibuffer boolean "23.1")
285
286 (minibuffer-prompt-properties
287 minibuffer
288 (list
289 (checklist :inline t
290 (const :tag "Read-Only"
291 :doc "Prevent prompt from being modified"
292 :format "%t%n%h"
293 :inline t
294 (read-only t))
295 (const :tag "Don't Enter"
296 :doc "Prevent point from ever entering prompt"
297 :format "%t%n%h"
298 :inline t
299 (point-entered minibuffer-avoid-prompt)))
300 (repeat :inline t
301 :tag "Other Properties"
302 (list :inline t
303 :format "%v"
304 (symbol :tag "Property")
305 (sexp :tag "Value"))))
306 "21.1")
307 (minibuffer-auto-raise minibuffer boolean)
308 ;; options property set at end
309 (read-buffer-function minibuffer
310 (choice (const nil)
311 (function-item iswitchb-read-buffer)
312 function))
313 ;; msdos.c
314 (dos-unsupported-char-glyph display integer)
315 ;; nsterm.m
316 (ns-control-modifier
317 ns
318 (choice (const :tag "No modifier" nil)
319 (const control) (const meta)
320 (const alt) (const hyper)
321 (const super)) "23.1")
322 (ns-right-control-modifier
323 ns
324 (choice (const :tag "No modifier (work as control)" none)
325 (const :tag "Use the value of ns-control-modifier"
326 left)
327 (const control) (const meta)
328 (const alt) (const hyper)
329 (const super)) "24.0")
330 (ns-command-modifier
331 ns
332 (choice (const :tag "No modifier" nil)
333 (const control) (const meta)
334 (const alt) (const hyper)
335 (const super)) "23.1")
336 (ns-right-command-modifier
337 ns
338 (choice (const :tag "No modifier (work as command)" none)
339 (const :tag "Use the value of ns-command-modifier"
340 left)
341 (const control) (const meta)
342 (const alt) (const hyper)
343 (const super)) "24.0")
344 (ns-alternate-modifier
345 ns
346 (choice (const :tag "No modifier (work as alternate/option)" none)
347 (const control) (const meta)
348 (const alt) (const hyper)
349 (const super)) "23.1")
350 (ns-right-alternate-modifier
351 ns
352 (choice (const :tag "No modifier (work as alternate/option)" none)
353 (const :tag "Use the value of ns-alternate-modifier"
354 left)
355 (const control) (const meta)
356 (const alt) (const hyper)
357 (const super)) "23.3")
358 (ns-function-modifier
359 ns
360 (choice (const :tag "No modifier (work as function)" none)
361 (const control) (const meta)
362 (const alt) (const hyper)
363 (const super)) "23.1")
364 (ns-antialias-text ns boolean "23.1")
365 ;; process.c
366 (delete-exited-processes processes-basics boolean)
367 ;; syntax.c
368 (parse-sexp-ignore-comments editing-basics boolean)
369 (words-include-escapes editing-basics boolean)
370 (open-paren-in-column-0-is-defun-start editing-basics boolean
371 "21.1")
372 ;; term.c
373 (visible-cursor cursor boolean "22.1")
374 ;; undo.c
375 (undo-limit undo integer)
376 (undo-strong-limit undo integer)
377 (undo-outer-limit undo
378 (choice integer
379 (const :tag "No limit"
380 :format "%t\n%d"
381 :doc
382 "With this choice, \
383 the undo info for the current command never gets discarded.
384 This should only be chosen under exceptional circumstances,
385 since it could result in memory overflow and make Emacs crash."
386 nil))
387 "22.1")
388 ;; window.c
389 (temp-buffer-show-function windows (choice (const nil) function))
390 (next-screen-context-lines windows integer)
391 (window-min-height windows integer)
392 (window-min-width windows integer)
393 (scroll-preserve-screen-position
394 windows (choice
395 (const :tag "Off (nil)" :value nil)
396 (const :tag "Full screen (t)" :value t)
397 (other :tag "Always" 1)) "22.1")
398 (recenter-redisplay windows
399 (choice
400 (const :tag "Never (nil)" :value nil)
401 (const :tag "Only on ttys" :value tty)
402 (other :tag "Always" t))
403 "23.1")
404 ;; xdisp.c
405 (show-trailing-whitespace whitespace-faces boolean nil
406 :safe booleanp)
407 (scroll-step windows integer)
408 (scroll-conservatively windows integer)
409 (scroll-margin windows integer)
410 (hscroll-margin windows integer "22.1")
411 (hscroll-step windows number "22.1")
412 (truncate-partial-width-windows display boolean "23.1")
413 (mode-line-inverse-video mode-line boolean)
414 (mode-line-in-non-selected-windows mode-line boolean "22.1")
415 (line-number-display-limit display
416 (choice integer
417 (const :tag "No limit" nil)))
418 (line-number-display-limit-width display integer "22.1")
419 (highlight-nonselected-windows display boolean)
420 (message-log-max debug (choice (const :tag "Disable" nil)
421 (integer :menu-tag "lines"
422 :format "%v")
423 (other :tag "Unlimited" t)))
424 (unibyte-display-via-language-environment mule boolean)
425 (blink-cursor-alist cursor alist "22.1")
426 (overline-margin display integer "22.1")
427 (underline-minimum-offset display integer "23.1")
428 (mouse-autoselect-window
429 display (choice
430 (const :tag "Off (nil)" :value nil)
431 (const :tag "Immediate" :value t)
432 (number :tag "Delay by secs" :value 0.5)) "22.1")
433 (tool-bar-style
434 frames (choice
435 (const :tag "Images" :value image)
436 (const :tag "Text" :value text)
437 (const :tag "Both" :value both)
438 (const :tag "Both-horiz" :value both-horiz)
439 (const :tag "Text-image-horiz" :value text-image-horiz)
440 (const :tag "System default" :value nil)) "23.3")
441 (tool-bar-max-label-size frames integer "23.3")
442 (auto-hscroll-mode scrolling boolean "21.1")
443 (display-hourglass cursor boolean)
444 (hourglass-delay cursor number)
445
446 ;; xfaces.c
447 (scalable-fonts-allowed display boolean "22.1")
448 ;; xfns.c
449 (x-bitmap-file-path installation
450 (repeat (directory :format "%v")))
451 (x-gtk-use-old-file-dialog menu boolean "22.1")
452 (x-gtk-show-hidden-files menu boolean "22.1")
453 (x-gtk-file-dialog-help-text menu boolean "22.1")
454 (x-gtk-whole-detached-tool-bar x boolean "22.1")
455 (x-gtk-use-system-tooltips tooltip boolean "23.3")
456 ;; xterm.c
457 (x-use-underline-position-properties display boolean "22.1")
458 (x-underline-at-descent-line display boolean "22.1")
459 (x-stretch-cursor display boolean "21.1")
460 ;; xsettings.c
461 (font-use-system-font font-selection boolean "23.2")))
462 this symbol group type standard version native-p rest prop propval
463 ;; This function turns a value
464 ;; into an expression which produces that value.
465 (quoter (lambda (sexp)
466 (if (or (memq sexp '(t nil))
467 (keywordp sexp)
468 (and (listp sexp)
469 (memq (car sexp) '(lambda)))
470 (stringp sexp)
471 (numberp sexp))
472 sexp
473 (list 'quote sexp)))))
474 (while all
475 (setq this (car all)
476 all (cdr all)
477 symbol (nth 0 this)
478 group (nth 1 this)
479 type (nth 2 this)
480 version (nth 3 this)
481 rest (nthcdr 4 this)
482 ;; If we did not specify any standard value expression above,
483 ;; use the current value as the standard value.
484 standard (if (setq prop (memq :standard rest))
485 (cadr prop)
486 (if (default-boundp symbol)
487 (funcall quoter (default-value symbol))))
488 ;; Don't complain about missing variables which are
489 ;; irrelevant to this platform.
490 native-p (save-match-data
491 (cond
492 ((string-match "\\`dos-" (symbol-name symbol))
493 (eq system-type 'ms-dos))
494 ((string-match "\\`w32-" (symbol-name symbol))
495 (eq system-type 'windows-nt))
496 ((string-match "\\`ns-" (symbol-name symbol))
497 (featurep 'ns))
498 ((string-match "\\`x-.*gtk" (symbol-name symbol))
499 (featurep 'gtk))
500 ((string-match "\\`x-" (symbol-name symbol))
501 (fboundp 'x-create-frame))
502 ((string-match "selection" (symbol-name symbol))
503 (fboundp 'x-selection-exists-p))
504 ((string-match "fringe" (symbol-name symbol))
505 (fboundp 'define-fringe-bitmap))
506 ((equal "font-use-system-font" (symbol-name symbol))
507 (featurep 'system-font-setting))
508 ;; Conditioned on x-create-frame, because that's
509 ;; the condition for loadup.el to preload tool-bar.el.
510 ((string-match "tool-bar-" (symbol-name symbol))
511 (fboundp 'x-create-frame))
512 (t t))))
513 (if (not (boundp symbol))
514 ;; If variables are removed from C code, give an error here!
515 (and native-p
516 (message "Note, built-in variable `%S' not bound" symbol))
517 ;; Save the standard value, unless we already did.
518 (or (get symbol 'standard-value)
519 (put symbol 'standard-value (list standard)))
520 ;; We need these properties independent of whether cus-start is loaded.
521 (if (setq prop (memq :safe rest))
522 (put symbol 'safe-local-variable (cadr prop)))
523 (if (setq prop (memq :risky rest))
524 (put symbol 'risky-local-variable (cadr prop)))
525 (if (setq prop (memq :set rest))
526 (put symbol 'custom-set (cadr prop)))
527 ;; Note this is the _only_ initialize property we handle.
528 (if (eq (cadr (memq :initialize rest)) 'custom-initialize-delay)
529 (push symbol custom-delayed-init-variables))
530 ;; If this is NOT while dumping Emacs, set up the rest of the
531 ;; customization info. This is the stuff that is not needed
532 ;; until someone does M-x customize etc.
533 (unless purify-flag
534 ;; Add it to the right group(s).
535 (if (listp group)
536 (dolist (g group)
537 (custom-add-to-group g symbol 'custom-variable))
538 (custom-add-to-group group symbol 'custom-variable))
539 ;; Set the type.
540 (put symbol 'custom-type type)
541 (if version (put symbol 'custom-version version))
542 (while rest
543 (setq prop (car rest)
544 propval (cadr rest)
545 rest (nthcdr 2 rest))
546 (cond ((memq prop '(:standard :risky :safe :set))) ; handled above
547 ((eq prop :tag)
548 (put symbol 'custom-tag propval))))))))
549
550 (custom-add-to-group 'iswitchb 'read-buffer-function 'custom-variable)
551 (custom-add-to-group 'font-lock 'open-paren-in-column-0-is-defun-start
552 'custom-variable)
553
554 ;; Record cus-start as loaded if we have set up all the info that we can.
555 ;; Don't record it as loaded if we have only set up the standard values
556 ;; and safe/risky properties.
557 (unless purify-flag
558 (provide 'cus-start))
559
560 ;;; cus-start.el ends here