strftime: import from gnulib
[emacs.git] / lisp / cus-start.el
blobd2d99ee64fbc9e68821cc1089242198aa1c4fb60
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
9 ;; This file is part of GNU Emacs.
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.
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.
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/>.
24 ;;; Commentary:
26 ;; This file adds customize support for built-in variables.
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.
34 ;;; Code:
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 (debug-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-ignored-errors debug (repeat (choice symbol regexp)))
176 (debug-on-quit debug
177 (choice (const :tag "off")
178 (repeat :menu-tag "When"
179 :value (nil)
180 (symbol :format "%v"))
181 (const :tag "always" t)))
182 ;; fileio.c
183 (delete-by-moving-to-trash auto-save boolean "23.1")
184 (auto-save-visited-file-name auto-save boolean)
185 ;; filelock.c
186 (temporary-file-directory
187 ;; Darwin section added 24.1, does not seem worth :version bump.
188 files directory nil
189 :standard
190 (file-name-as-directory
191 ;; FIXME ? Should there be Ftemporary_file_directory to do this
192 ;; more robustly (cf set_local_socket in emacsclient.c).
193 ;; It could be used elsewhere, eg Fcall_process_region,
194 ;; server-socket-dir. See bug#7135.
195 (cond ((memq system-type '(ms-dos windows-nt))
196 (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP")
197 "c:/temp"))
198 ((eq system-type 'darwin)
199 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
200 ;; See bug#7135.
201 (let ((tmp (ignore-errors
202 (shell-command-to-string
203 "getconf DARWIN_USER_TEMP_DIR"))))
204 (and (stringp tmp)
205 (setq tmp (replace-regexp-in-string
206 "\n\\'" "" tmp))
207 ;; Handles "getconf: Unrecognized variable..."
208 (file-directory-p tmp)
209 tmp))
210 "/tmp"))
212 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
213 "/tmp"))))
214 :initialize custom-initialize-delay)
215 ;; fns.c
216 (use-dialog-box menu boolean "21.1")
217 (use-file-dialog menu boolean "22.1")
218 (focus-follows-mouse frames boolean "20.3")
219 ;; frame.c
220 (default-frame-alist frames
221 (repeat (cons :format "%v"
222 (symbol :tag "Parameter")
223 (sexp :tag "Value"))))
224 (mouse-highlight mouse (choice (const :tag "disabled" nil)
225 (const :tag "always shown" t)
226 (other :tag "hidden by keypress" 1))
227 "22.1")
228 (make-pointer-invisible mouse boolean "23.2")
229 (menu-bar-mode frames boolean nil
230 ;; FIXME?
231 ; :initialize custom-initialize-default
232 :set custom-set-minor-mode)
233 (tool-bar-mode (frames mouse) boolean nil
234 ; :initialize custom-initialize-default
235 :set custom-set-minor-mode)
236 ;; fringe.c
237 (overflow-newline-into-fringe fringe boolean)
238 ;; indent.c
239 (indent-tabs-mode indent boolean)
240 ;; keyboard.c
241 (meta-prefix-char keyboard character)
242 (auto-save-interval auto-save integer)
243 (auto-save-timeout auto-save (choice (const :tag "off" nil)
244 (integer :format "%v")))
245 (echo-keystrokes minibuffer number)
246 (polling-period keyboard integer)
247 (double-click-time mouse (restricted-sexp
248 :match-alternatives (integerp 'nil 't)))
249 (double-click-fuzz mouse integer "22.1")
250 (inhibit-local-menu-bar-menus menu boolean)
251 (help-char keyboard character)
252 (help-event-list keyboard (repeat (sexp :format "%v")))
253 (menu-prompting menu boolean)
254 (select-active-regions killing
255 (choice (const :tag "always" t)
256 (const :tag "only shift-selection or mouse-drag" only)
257 (const :tag "off" nil))
258 "24.1")
259 (suggest-key-bindings keyboard (choice (const :tag "off" nil)
260 (integer :tag "time" 2)
261 (other :tag "on")))
263 ;; This is not good news because it will use the wrong
264 ;; version-specific directories when you upgrade. We need
265 ;; customization of the front of the list, maintaining the standard
266 ;; value intact at the back.
267 ;;; (load-path environment
268 ;;; (repeat (choice :tag "[Current dir?]"
269 ;;; :format "%[Current dir?%] %v"
270 ;;; (const :tag " current dir" nil)
271 ;;; (directory :format "%v"))))
272 ;; minibuf.c
273 (enable-recursive-minibuffers minibuffer boolean)
274 (history-length minibuffer
275 (choice (const :tag "Infinite" t) integer)
276 "22.1")
277 (history-delete-duplicates minibuffer boolean "22.1")
278 (read-buffer-completion-ignore-case minibuffer boolean "23.1")
280 (minibuffer-prompt-properties
281 minibuffer
282 (list
283 (checklist :inline t
284 (const :tag "Read-Only"
285 :doc "Prevent prompt from being modified"
286 :format "%t%n%h"
287 :inline t
288 (read-only t))
289 (const :tag "Don't Enter"
290 :doc "Prevent point from ever entering prompt"
291 :format "%t%n%h"
292 :inline t
293 (point-entered minibuffer-avoid-prompt)))
294 (repeat :inline t
295 :tag "Other Properties"
296 (list :inline t
297 :format "%v"
298 (symbol :tag "Property")
299 (sexp :tag "Value"))))
300 "21.1")
301 (minibuffer-auto-raise minibuffer boolean)
302 ;; options property set at end
303 (read-buffer-function minibuffer
304 (choice (const nil)
305 (function-item iswitchb-read-buffer)
306 function))
307 ;; msdos.c
308 (dos-unsupported-char-glyph display integer)
309 ;; nsterm.m
310 (ns-control-modifier
312 (choice (const :tag "No modifier" nil)
313 (const control) (const meta)
314 (const alt) (const hyper)
315 (const super)) "23.1")
316 (ns-right-control-modifier
318 (choice (const :tag "No modifier (work as control)" none)
319 (const :tag "Use the value of ns-control-modifier"
320 left)
321 (const control) (const meta)
322 (const alt) (const hyper)
323 (const super)) "24.0")
324 (ns-command-modifier
326 (choice (const :tag "No modifier" nil)
327 (const control) (const meta)
328 (const alt) (const hyper)
329 (const super)) "23.1")
330 (ns-right-command-modifier
332 (choice (const :tag "No modifier (work as command)" none)
333 (const :tag "Use the value of ns-command-modifier"
334 left)
335 (const control) (const meta)
336 (const alt) (const hyper)
337 (const super)) "24.0")
338 (ns-alternate-modifier
340 (choice (const :tag "No modifier (work as alternate/option)" none)
341 (const control) (const meta)
342 (const alt) (const hyper)
343 (const super)) "23.1")
344 (ns-right-alternate-modifier
346 (choice (const :tag "No modifier (work as alternate/option)" none)
347 (const :tag "Use the value of ns-alternate-modifier"
348 left)
349 (const control) (const meta)
350 (const alt) (const hyper)
351 (const super)) "23.3")
352 (ns-function-modifier
354 (choice (const :tag "No modifier (work as function)" none)
355 (const control) (const meta)
356 (const alt) (const hyper)
357 (const super)) "23.1")
358 (ns-antialias-text ns boolean "23.1")
359 ;; process.c
360 (delete-exited-processes processes-basics boolean)
361 ;; syntax.c
362 (parse-sexp-ignore-comments editing-basics boolean)
363 (words-include-escapes editing-basics boolean)
364 (open-paren-in-column-0-is-defun-start editing-basics boolean
365 "21.1")
366 ;; term.c
367 (visible-cursor cursor boolean "22.1")
368 ;; undo.c
369 (undo-limit undo integer)
370 (undo-strong-limit undo integer)
371 (undo-outer-limit undo
372 (choice integer
373 (const :tag "No limit"
374 :format "%t\n%d"
375 :doc
376 "With this choice, \
377 the undo info for the current command never gets discarded.
378 This should only be chosen under exceptional circumstances,
379 since it could result in memory overflow and make Emacs crash."
380 nil))
381 "22.1")
382 ;; window.c
383 (temp-buffer-show-function windows (choice (const nil) function))
384 (next-screen-context-lines windows integer)
385 (window-min-height windows integer)
386 (window-min-width windows integer)
387 (scroll-preserve-screen-position
388 windows (choice
389 (const :tag "Off (nil)" :value nil)
390 (const :tag "Full screen (t)" :value t)
391 (other :tag "Always" 1)) "22.1")
392 (recenter-redisplay windows
393 (choice
394 (const :tag "Never (nil)" :value nil)
395 (const :tag "Only on ttys" :value tty)
396 (other :tag "Always" t))
397 "23.1")
398 ;; xdisp.c
399 (show-trailing-whitespace whitespace-faces boolean nil
400 :safe booleanp)
401 (scroll-step windows integer)
402 (scroll-conservatively windows integer)
403 (scroll-margin windows integer)
404 (hscroll-margin windows integer "22.1")
405 (hscroll-step windows number "22.1")
406 (truncate-partial-width-windows display boolean "23.1")
407 (mode-line-inverse-video mode-line boolean)
408 (mode-line-in-non-selected-windows mode-line boolean "22.1")
409 (line-number-display-limit display
410 (choice integer
411 (const :tag "No limit" nil)))
412 (line-number-display-limit-width display integer "22.1")
413 (highlight-nonselected-windows display boolean)
414 (message-log-max debug (choice (const :tag "Disable" nil)
415 (integer :menu-tag "lines"
416 :format "%v")
417 (other :tag "Unlimited" t)))
418 (unibyte-display-via-language-environment mule boolean)
419 (blink-cursor-alist cursor alist "22.1")
420 (overline-margin display integer "22.1")
421 (underline-minimum-offset display integer "23.1")
422 (mouse-autoselect-window
423 display (choice
424 (const :tag "Off (nil)" :value nil)
425 (const :tag "Immediate" :value t)
426 (number :tag "Delay by secs" :value 0.5)) "22.1")
427 (tool-bar-style
428 frames (choice
429 (const :tag "Images" :value image)
430 (const :tag "Text" :value text)
431 (const :tag "Both" :value both)
432 (const :tag "Both-horiz" :value both-horiz)
433 (const :tag "Text-image-horiz" :value text-image-horiz)
434 (const :tag "System default" :value nil)) "23.3")
435 (tool-bar-max-label-size frames integer "23.3")
436 (auto-hscroll-mode scrolling boolean "21.1")
437 (display-hourglass cursor boolean)
438 (hourglass-delay cursor number)
440 ;; xfaces.c
441 (scalable-fonts-allowed display boolean "22.1")
442 ;; xfns.c
443 (x-bitmap-file-path installation
444 (repeat (directory :format "%v")))
445 (x-gtk-use-old-file-dialog menu boolean "22.1")
446 (x-gtk-show-hidden-files menu boolean "22.1")
447 (x-gtk-file-dialog-help-text menu boolean "22.1")
448 (x-gtk-whole-detached-tool-bar x boolean "22.1")
449 (x-gtk-use-system-tooltips tooltip boolean "23.3")
450 ;; xterm.c
451 (x-use-underline-position-properties display boolean "22.1")
452 (x-underline-at-descent-line display boolean "22.1")
453 (x-stretch-cursor display boolean "21.1")
454 ;; xsettings.c
455 (font-use-system-font font-selection boolean "23.2")))
456 this symbol group type standard version native-p rest prop propval
457 ;; This function turns a value
458 ;; into an expression which produces that value.
459 (quoter (lambda (sexp)
460 (if (or (memq sexp '(t nil))
461 (keywordp sexp)
462 (and (listp sexp)
463 (memq (car sexp) '(lambda)))
464 (stringp sexp)
465 (numberp sexp))
466 sexp
467 (list 'quote sexp)))))
468 (while all
469 (setq this (car all)
470 all (cdr all)
471 symbol (nth 0 this)
472 group (nth 1 this)
473 type (nth 2 this)
474 version (nth 3 this)
475 rest (nthcdr 4 this)
476 ;; If we did not specify any standard value expression above,
477 ;; use the current value as the standard value.
478 standard (if (setq prop (memq :standard rest))
479 (cadr prop)
480 (if (default-boundp symbol)
481 (funcall quoter (default-value symbol))))
482 ;; Don't complain about missing variables which are
483 ;; irrelevant to this platform.
484 native-p (save-match-data
485 (cond
486 ((string-match "\\`dos-" (symbol-name symbol))
487 (eq system-type 'ms-dos))
488 ((string-match "\\`w32-" (symbol-name symbol))
489 (eq system-type 'windows-nt))
490 ((string-match "\\`ns-" (symbol-name symbol))
491 (featurep 'ns))
492 ((string-match "\\`x-.*gtk" (symbol-name symbol))
493 (featurep 'gtk))
494 ((string-match "\\`x-" (symbol-name symbol))
495 (fboundp 'x-create-frame))
496 ((string-match "selection" (symbol-name symbol))
497 (fboundp 'x-selection-exists-p))
498 ((string-match "fringe" (symbol-name symbol))
499 (fboundp 'define-fringe-bitmap))
500 ((equal "font-use-system-font" (symbol-name symbol))
501 (featurep 'system-font-setting))
502 ;; Conditioned on x-create-frame, because that's
503 ;; the condition for loadup.el to preload tool-bar.el.
504 ((string-match "tool-bar-" (symbol-name symbol))
505 (fboundp 'x-create-frame))
506 (t t))))
507 (if (not (boundp symbol))
508 ;; If variables are removed from C code, give an error here!
509 (and native-p
510 (message "Note, built-in variable `%S' not bound" symbol))
511 ;; Save the standard value, unless we already did.
512 (or (get symbol 'standard-value)
513 (put symbol 'standard-value (list standard)))
514 ;; We need these properties independent of whether cus-start is loaded.
515 (if (setq prop (memq :safe rest))
516 (put symbol 'safe-local-variable (cadr prop)))
517 (if (setq prop (memq :risky rest))
518 (put symbol 'risky-local-variable (cadr prop)))
519 (if (setq prop (memq :set rest))
520 (put symbol 'custom-set (cadr prop)))
521 ;; Note this is the _only_ initialize property we handle.
522 (if (eq (cadr (memq :initialize rest)) 'custom-initialize-delay)
523 (push symbol custom-delayed-init-variables))
524 ;; If this is NOT while dumping Emacs, set up the rest of the
525 ;; customization info. This is the stuff that is not needed
526 ;; until someone does M-x customize etc.
527 (unless purify-flag
528 ;; Add it to the right group(s).
529 (if (listp group)
530 (dolist (g group)
531 (custom-add-to-group g symbol 'custom-variable))
532 (custom-add-to-group group symbol 'custom-variable))
533 ;; Set the type.
534 (put symbol 'custom-type type)
535 (if version (put symbol 'custom-version version))
536 (while rest
537 (setq prop (car rest)
538 propval (cadr rest)
539 rest (nthcdr 2 rest))
540 (cond ((memq prop '(:standard :risky :safe :set))) ; handled above
541 ((eq prop :tag)
542 (put symbol 'custom-tag propval))))))))
544 (custom-add-to-group 'iswitchb 'read-buffer-function 'custom-variable)
545 (custom-add-to-group 'font-lock 'open-paren-in-column-0-is-defun-start
546 'custom-variable)
548 ;; Record cus-start as loaded if we have set up all the info that we can.
549 ;; Don't record it as loaded if we have only set up the standard values
550 ;; and safe/risky properties.
551 (unless purify-flag
552 (provide 'cus-start))
554 ;;; cus-start.el ends here