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