Mercurial > emacs
comparison lisp/custom.el @ 41224:fc0e6d3f905d
(custom-current-group-alist): New var.
(custom-declare-group): Set it.
(custom-current-group): New fun.
(custom-declare-variable, custom-handle-all-keywords):
Use it as a default if no :group argument is specified.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 18 Nov 2001 01:35:12 +0000 |
parents | c576f3427825 |
children | ad017e26a4db |
comparison
equal
deleted
inserted
replaced
41223:0ca8b0f41ebd | 41224:fc0e6d3f905d |
---|---|
36 (require 'widget) | 36 (require 'widget) |
37 | 37 |
38 (defvar custom-define-hook nil | 38 (defvar custom-define-hook nil |
39 ;; Customize information for this option is in `cus-edit.el'. | 39 ;; Customize information for this option is in `cus-edit.el'. |
40 "Hook called after defining each customize option.") | 40 "Hook called after defining each customize option.") |
41 | |
42 (defvar custom-current-group-alist nil | |
43 "Alist of (FILE . GROUP) indicating the current group to use for FILE.") | |
41 | 44 |
42 ;;; The `defcustom' Macro. | 45 ;;; The `defcustom' Macro. |
43 | 46 |
44 (defun custom-initialize-default (symbol value) | 47 (defun custom-initialize-default (symbol value) |
45 "Initialize SYMBOL with VALUE. | 48 "Initialize SYMBOL with VALUE. |
112 (put symbol 'force-value nil)) | 115 (put symbol 'force-value nil)) |
113 (when doc | 116 (when doc |
114 (put symbol 'variable-documentation doc)) | 117 (put symbol 'variable-documentation doc)) |
115 (let ((initialize 'custom-initialize-reset) | 118 (let ((initialize 'custom-initialize-reset) |
116 (requests nil)) | 119 (requests nil)) |
120 (unless (memq :group args) | |
121 (custom-add-to-group (custom-current-group) symbol 'custom-variable)) | |
117 (while args | 122 (while args |
118 (let ((arg (car args))) | 123 (let ((arg (car args))) |
119 (setq args (cdr args)) | 124 (setq args (cdr args)) |
120 (unless (symbolp arg) | 125 (unless (symbolp arg) |
121 (error "Junk in args %S" args)) | 126 (error "Junk in args %S" args)) |
260 ;; if you need to recompile all the Lisp files using interpreted code. | 265 ;; if you need to recompile all the Lisp files using interpreted code. |
261 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args)) | 266 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args)) |
262 | 267 |
263 ;;; The `defgroup' Macro. | 268 ;;; The `defgroup' Macro. |
264 | 269 |
270 (defun custom-current-group () | |
271 (cdr (assoc load-file-name custom-current-group-alist))) | |
272 | |
265 (defun custom-declare-group (symbol members doc &rest args) | 273 (defun custom-declare-group (symbol members doc &rest args) |
266 "Like `defgroup', but SYMBOL is evaluated as a normal argument." | 274 "Like `defgroup', but SYMBOL is evaluated as a normal argument." |
267 (while members | 275 (while members |
268 (apply 'custom-add-to-group symbol (car members)) | 276 (apply 'custom-add-to-group symbol (car members)) |
269 (setq members (cdr members))) | 277 (setq members (cdr members))) |
284 (cond ((eq keyword :prefix) | 292 (cond ((eq keyword :prefix) |
285 (put symbol 'custom-prefix value)) | 293 (put symbol 'custom-prefix value)) |
286 (t | 294 (t |
287 (custom-handle-keyword symbol keyword value | 295 (custom-handle-keyword symbol keyword value |
288 'custom-group)))))) | 296 'custom-group)))))) |
297 ;; Record the group on the `current' list. | |
298 (let ((elt (assoc load-file-name custom-current-group-alist))) | |
299 (if elt (setcdr elt symbol) | |
300 (push (cons load-file-name symbol) custom-current-group-alist))) | |
289 (run-hooks 'custom-define-hook) | 301 (run-hooks 'custom-define-hook) |
290 symbol) | 302 symbol) |
291 | 303 |
292 (defmacro defgroup (symbol members doc &rest args) | 304 (defmacro defgroup (symbol members doc &rest args) |
293 "Declare SYMBOL as a customization group containing MEMBERS. | 305 "Declare SYMBOL as a customization group containing MEMBERS. |
330 ;;; Properties. | 342 ;;; Properties. |
331 | 343 |
332 (defun custom-handle-all-keywords (symbol args type) | 344 (defun custom-handle-all-keywords (symbol args type) |
333 "For customization option SYMBOL, handle keyword arguments ARGS. | 345 "For customization option SYMBOL, handle keyword arguments ARGS. |
334 Third argument TYPE is the custom option type." | 346 Third argument TYPE is the custom option type." |
347 (unless (memq :group args) | |
348 (custom-add-to-group (custom-current-group) symbol 'custom-face)) | |
335 (while args | 349 (while args |
336 (let ((arg (car args))) | 350 (let ((arg (car args))) |
337 (setq args (cdr args)) | 351 (setq args (cdr args)) |
338 (unless (symbolp arg) | 352 (unless (symbolp arg) |
339 (error "Junk in args %S" args)) | 353 (error "Junk in args %S" args)) |