comparison lisp/specifier.el @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 70ad99077275
children 501cfd01ee6d
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
400 (add-spec-list-to-specifier 400 (add-spec-list-to-specifier
401 specifier 401 specifier
402 (canonicalize-spec-list nval (specifier-type specifier)) 402 (canonicalize-spec-list nval (specifier-type specifier))
403 how-to-add)))) 403 how-to-add))))
404 value) 404 value)
405
406 (defun modify-specifier-instances (specifier func &optional args force default
407 locale tag-set)
408 "Modify all specifications that match LOCALE and TAG-SET by FUNC.
409
410 For each specification that exists for SPECIFIER, in locale LOCALE
411 that matches TAG-SET, call the function FUNC with the instance as its
412 first argument and with optional arguments ARGS. The result is then
413 used as the new value of the instantiator.
414
415 If there is no specification in the domain LOCALE matching TAG-SET and
416 FORCE is non-nil, an explicit one is created from the matching
417 specifier instance if that exists or DEFAULT otherwise. If LOCALE is
418 not a domain (i.e. a buffer), DEFAULT is always used. FUNC is then
419 applied like above and the resulting specification is added."
420
421 (let ((spec-list (specifier-spec-list specifier locale tag-set)))
422 (cond
423 (spec-list
424 ;; Destructively edit the spec-list
425 (mapc #'(lambda (spec)
426 (mapc #'(lambda (inst-pair)
427 (setcdr inst-pair
428 (apply func (cdr inst-pair) args)))
429 (cdr spec)))
430 spec-list)
431 (add-spec-list-to-specifier specifier spec-list))
432 (force
433 (set-specifier specifier
434 (apply func
435 (or (and (valid-specifier-domain-p locale)
436 (specifier-instance specifier))
437 default) args)
438 locale tag-set)))))
405 439
406 (defmacro let-specifier (specifier-list &rest body) 440 (defmacro let-specifier (specifier-list &rest body)
407 "Add specifier specs, evaluate forms in BODY and restore the specifiers. 441 "Add specifier specs, evaluate forms in BODY and restore the specifiers.
408 \(let-specifier SPECIFIER-LIST BODY...) 442 \(let-specifier SPECIFIER-LIST BODY...)
409 443