comparison lisp/faces.el @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children 558f606b08ae
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
144 (defun convert-face-property-into-specifier (face property) 144 (defun convert-face-property-into-specifier (face property)
145 "Convert PROPERTY on FACE into a specifier, if it's not already." 145 "Convert PROPERTY on FACE into a specifier, if it's not already."
146 (setq face (get-face face)) 146 (setq face (get-face face))
147 (let ((specifier (get face property))) 147 (let ((specifier (get face property)))
148 ;; if a user-property does not have a specifier but a 148 ;; if a user-property does not have a specifier but a
149 ;; locale was specified, put a specifier there. 149 ;; locale was specified, put a specifier there.
150 ;; If there was already a value there, convert it to a 150 ;; If there was already a value there, convert it to a
151 ;; specifier with the value as its 'global instantiator. 151 ;; specifier with the value as its 'global instantiator.
152 (unless (specifierp specifier) 152 (unless (specifierp specifier)
153 (let ((new-specifier (make-specifier 'generic))) 153 (let ((new-specifier (make-specifier 'generic)))
154 (if (or (not (null specifier)) 154 (if (or (not (null specifier))
229 default no-fallback))) 229 default no-fallback)))
230 value)) 230 value))
231 231
232 (defun set-face-property (face property value &optional locale tag-set 232 (defun set-face-property (face property value &optional locale tag-set
233 how-to-add) 233 how-to-add)
234 "Change a property of a FACE. 234 "Change a property of FACE.
235 235
236 NOTE: If you want to remove a property from a face, use `remove-face-property' 236 NOTE: If you want to remove a property from a face, use `remove-face-property'
237 rather than attempting to set a value of nil for the property. 237 rather than attempting to set a value of nil for the property.
238 238
239 For built-in properties, the actual value of the property is a 239 For built-in properties, the actual value of the property is a
291 291
292 The following symbols have predefined meanings: 292 The following symbols have predefined meanings:
293 293
294 foreground The foreground color of the face. 294 foreground The foreground color of the face.
295 For valid instantiators, see `color-specifier-p'. 295 For valid instantiators, see `color-specifier-p'.
296 296
297 background The background color of the face. 297 background The background color of the face.
298 For valid instantiators, see `color-specifier-p'. 298 For valid instantiators, see `color-specifier-p'.
299 299
300 font The font used to display text covered by this face. 300 font The font used to display text covered by this face.
301 For valid instantiators, see `font-specifier-p'. 301 For valid instantiators, see `font-specifier-p'.
302 302
303 display-table The display table of the face. 303 display-table The display table of the face.
304 This should be a vector of 256 elements. 304 This should be a vector of 256 elements.
305 305
306 background-pixmap The pixmap displayed in the background of the face. 306 background-pixmap The pixmap displayed in the background of the face.
307 Only used by faces on X devices. 307 Only used by faces on X devices.
308 For valid instantiators, see `image-specifier-p'. 308 For valid instantiators, see `image-specifier-p'.
309 309
310 underline Underline all text covered by this face. 310 underline Underline all text covered by this face.
314 For valid instantiators, see `face-boolean-specifier-p'. 314 For valid instantiators, see `face-boolean-specifier-p'.
315 315
316 highlight Highlight all text covered by this face. 316 highlight Highlight all text covered by this face.
317 Only used by faces on TTY devices. 317 Only used by faces on TTY devices.
318 For valid instantiators, see `face-boolean-specifier-p'. 318 For valid instantiators, see `face-boolean-specifier-p'.
319 319
320 dim Dim all text covered by this face. 320 dim Dim all text covered by this face.
321 Only used by faces on TTY devices. 321 Only used by faces on TTY devices.
322 For valid instantiators, see `face-boolean-specifier-p'. 322 For valid instantiators, see `face-boolean-specifier-p'.
323 323
324 blinking Blink all text covered by this face. 324 blinking Blink all text covered by this face.
325 Only used by faces on TTY devices. 325 Only used by faces on TTY devices.
326 For valid instantiators, see `face-boolean-specifier-p'. 326 For valid instantiators, see `face-boolean-specifier-p'.
327 327
328 reverse Reverse the foreground and background colors. 328 reverse Reverse the foreground and background colors.
329 Only used by faces on TTY devices. 329 Only used by faces on TTY devices.
330 For valid instantiators, see `face-boolean-specifier-p'. 330 For valid instantiators, see `face-boolean-specifier-p'.
331 331
332 doc-string Description of what the face's normal use is. 332 doc-string Description of what the face's normal use is.
333 NOTE: This is not a specifier, unlike all 333 NOTE: This is not a specifier, unlike all
334 the other built-in properties, and cannot 334 the other built-in properties, and cannot
335 contain locale-specific values." 335 contain locale-specific values."
336 336
345 (add-spec-to-specifier (get face property) value locale tag-set 345 (add-spec-to-specifier (get face property) value locale tag-set
346 how-to-add))) 346 how-to-add)))
347 value) 347 value)
348 348
349 (defun remove-face-property (face property &optional locale tag-set exact-p) 349 (defun remove-face-property (face property &optional locale tag-set exact-p)
350 "Remove a property from a face. 350 "Remove a property from FACE.
351 For built-in properties, this is analogous to `remove-specifier'. 351 For built-in properties, this is analogous to `remove-specifier'.
352 See `remove-specifier' for the meaning of the LOCALE, TAG-SET, and EXACT-P 352 See `remove-specifier' for the meaning of the LOCALE, TAG-SET, and EXACT-P
353 arguments." 353 arguments."
354 (or locale (setq locale 'all)) 354 (or locale (setq locale 'all))
355 (if (memq property built-in-face-specifiers) 355 (if (memq property built-in-face-specifiers)
395 "Change the documentation string of FACE to DOC-STRING." 395 "Change the documentation string of FACE to DOC-STRING."
396 (interactive (face-interactive "doc-string")) 396 (interactive (face-interactive "doc-string"))
397 (set-face-property face 'doc-string doc-string)) 397 (set-face-property face 'doc-string doc-string))
398 398
399 (defun face-font-name (face &optional domain charset) 399 (defun face-font-name (face &optional domain charset)
400 "Return the font name of the given face, or nil if it is unspecified. 400 "Return the font name of FACE in DOMAIN, or nil if it is unspecified.
401 DOMAIN is as in `face-font-instance'." 401 DOMAIN is as in `face-font-instance'."
402 (let ((f (face-font-instance face domain charset))) 402 (let ((f (face-font-instance face domain charset)))
403 (and f (font-instance-name f)))) 403 (and f (font-instance-name f))))
404 404
405 (defun face-font (face &optional locale tag-set exact-p) 405 (defun face-font (face &optional locale tag-set exact-p)
406 "Return the font of the given face, or nil if it is unspecified. 406 "Return the font of FACE in LOCALE, or nil if it is unspecified.
407 407
408 FACE may be either a face object or a symbol representing a face. 408 FACE may be either a face object or a symbol representing a face.
409 409
410 LOCALE may be a locale (the instantiators for that particular locale 410 LOCALE may be a locale (the instantiators for that particular locale
411 will be returned), a locale type (the specifications for all locales 411 will be returned), a locale type (the specifications for all locales
414 414
415 See `face-property' for more information." 415 See `face-property' for more information."
416 (face-property face 'font locale tag-set exact-p)) 416 (face-property face 'font locale tag-set exact-p))
417 417
418 (defun face-font-instance (face &optional domain charset) 418 (defun face-font-instance (face &optional domain charset)
419 "Return the instance of the given face's font in the given domain. 419 "Return the instance of FACE's font in DOMAIN.
420 420
421 FACE may be either a face object or a symbol representing a face. 421 FACE may be either a face object or a symbol representing a face.
422 422
423 Normally DOMAIN will be a window or nil (meaning the selected window), 423 Normally DOMAIN will be a window or nil (meaning the selected window),
424 and an instance object describing how the font appears in that 424 and an instance object describing how the font appears in that
428 (if charset 428 (if charset
429 (face-property-matching-instance face 'font charset domain) 429 (face-property-matching-instance face 'font charset domain)
430 (face-property-instance face 'font domain))) 430 (face-property-instance face 'font domain)))
431 431
432 (defun set-face-font (face font &optional locale tag-set how-to-add) 432 (defun set-face-font (face font &optional locale tag-set how-to-add)
433 "Change the font of the given face. 433 "Change the font of FACE to FONT in LOCALE.
434 434
435 FACE may be either a face object or a symbol representing a face. 435 FACE may be either a face object or a symbol representing a face.
436 436
437 FONT should be an instantiator (see `font-specifier-p'), a list of 437 FONT should be an instantiator (see `font-specifier-p'), a list of
438 instantiators, an alist of specifications (each mapping a 438 instantiators, an alist of specifications (each mapping a
447 See `set-face-property' for more information." 447 See `set-face-property' for more information."
448 (interactive (face-interactive "font")) 448 (interactive (face-interactive "font"))
449 (set-face-property face 'font font locale tag-set how-to-add)) 449 (set-face-property face 'font font locale tag-set how-to-add))
450 450
451 (defun face-foreground (face &optional locale tag-set exact-p) 451 (defun face-foreground (face &optional locale tag-set exact-p)
452 "Return the foreground of the given face, or nil if it is unspecified. 452 "Return the foreground of FACE in LOCALE, or nil if it is unspecified.
453 453
454 FACE may be either a face object or a symbol representing a face. 454 FACE may be either a face object or a symbol representing a face.
455 455
456 LOCALE may be a locale (the instantiators for that particular locale 456 LOCALE may be a locale (the instantiators for that particular locale
457 will be returned), a locale type (the specifications for all locales 457 will be returned), a locale type (the specifications for all locales
460 460
461 See `face-property' for more information." 461 See `face-property' for more information."
462 (face-property face 'foreground locale tag-set exact-p)) 462 (face-property face 'foreground locale tag-set exact-p))
463 463
464 (defun face-foreground-instance (face &optional domain default no-fallback) 464 (defun face-foreground-instance (face &optional domain default no-fallback)
465 "Return the instance of the given face's foreground in the given domain. 465 "Return the instance of FACE's foreground in DOMAIN.
466 466
467 FACE may be either a face object or a symbol representing a face. 467 FACE may be either a face object or a symbol representing a face.
468 468
469 Normally DOMAIN will be a window or nil (meaning the selected window), 469 Normally DOMAIN will be a window or nil (meaning the selected window),
470 and an instance object describing how the foreground appears in that 470 and an instance object describing how the foreground appears in that
472 472
473 See `face-property-instance' for more information." 473 See `face-property-instance' for more information."
474 (face-property-instance face 'foreground domain default no-fallback)) 474 (face-property-instance face 'foreground domain default no-fallback))
475 475
476 (defun face-foreground-name (face &optional domain default no-fallback) 476 (defun face-foreground-name (face &optional domain default no-fallback)
477 "Return the name of the given face's foreground color in the given domain. 477 "Return the name of FACE's foreground color in DOMAIN.
478 478
479 FACE may be either a face object or a symbol representing a face. 479 FACE may be either a face object or a symbol representing a face.
480 480
481 Normally DOMAIN will be a window or nil (meaning the selected window), 481 Normally DOMAIN will be a window or nil (meaning the selected window),
482 and an instance object describing how the background appears in that 482 and an instance object describing how the background appears in that
485 See `face-property-instance' for more information." 485 See `face-property-instance' for more information."
486 (color-instance-name (face-foreground-instance 486 (color-instance-name (face-foreground-instance
487 face domain default no-fallback))) 487 face domain default no-fallback)))
488 488
489 (defun set-face-foreground (face color &optional locale tag-set how-to-add) 489 (defun set-face-foreground (face color &optional locale tag-set how-to-add)
490 "Change the foreground of the given face. 490 "Change the foreground color of FACE to COLOR in LOCALE.
491 491
492 FACE may be either a face object or a symbol representing a face. 492 FACE may be either a face object or a symbol representing a face.
493 493
494 COLOR should be an instantiator (see `color-specifier-p'), a list of 494 COLOR should be an instantiator (see `color-specifier-p'), a list of
495 instantiators, an alist of specifications (each mapping a locale to 495 instantiators, an alist of specifications (each mapping a locale to
504 See `set-face-property' for more information." 504 See `set-face-property' for more information."
505 (interactive (face-interactive "foreground")) 505 (interactive (face-interactive "foreground"))
506 (set-face-property face 'foreground color locale tag-set how-to-add)) 506 (set-face-property face 'foreground color locale tag-set how-to-add))
507 507
508 (defun face-background (face &optional locale tag-set exact-p) 508 (defun face-background (face &optional locale tag-set exact-p)
509 "Return the background of the given face, or nil if it is unspecified. 509 "Return the background color of FACE in LOCALE, or nil if it is unspecified.
510 510
511 FACE may be either a face object or a symbol representing a face. 511 FACE may be either a face object or a symbol representing a face.
512 512
513 LOCALE may be a locale (the instantiators for that particular locale 513 LOCALE may be a locale (the instantiators for that particular locale
514 will be returned), a locale type (the specifications for all locales 514 will be returned), a locale type (the specifications for all locales
517 517
518 See `face-property' for more information." 518 See `face-property' for more information."
519 (face-property face 'background locale tag-set exact-p)) 519 (face-property face 'background locale tag-set exact-p))
520 520
521 (defun face-background-instance (face &optional domain default no-fallback) 521 (defun face-background-instance (face &optional domain default no-fallback)
522 "Return the instance of the given face's background in the given domain. 522 "Return the instance of FACE's background in DOMAIN.
523 523
524 FACE may be either a face object or a symbol representing a face. 524 FACE may be either a face object or a symbol representing a face.
525 525
526 Normally DOMAIN will be a window or nil (meaning the selected window), 526 Normally DOMAIN will be a window or nil (meaning the selected window),
527 and an instance object describing how the background appears in that 527 and an instance object describing how the background appears in that
529 529
530 See `face-property-instance' for more information." 530 See `face-property-instance' for more information."
531 (face-property-instance face 'background domain default no-fallback)) 531 (face-property-instance face 'background domain default no-fallback))
532 532
533 (defun face-background-name (face &optional domain default no-fallback) 533 (defun face-background-name (face &optional domain default no-fallback)
534 "Return the name of the given face's background color in the given domain. 534 "Return the name of FACE's background color in DOMAIN.
535 535
536 FACE may be either a face object or a symbol representing a face. 536 FACE may be either a face object or a symbol representing a face.
537 537
538 Normally DOMAIN will be a window or nil (meaning the selected window), 538 Normally DOMAIN will be a window or nil (meaning the selected window),
539 and an instance object describing how the background appears in that 539 and an instance object describing how the background appears in that
542 See `face-property-instance' for more information." 542 See `face-property-instance' for more information."
543 (color-instance-name (face-background-instance 543 (color-instance-name (face-background-instance
544 face domain default no-fallback))) 544 face domain default no-fallback)))
545 545
546 (defun set-face-background (face color &optional locale tag-set how-to-add) 546 (defun set-face-background (face color &optional locale tag-set how-to-add)
547 "Change the background of the given face. 547 "Change the background color of FACE to COLOR in LOCALE.
548 548
549 FACE may be either a face object or a symbol representing a face. 549 FACE may be either a face object or a symbol representing a face.
550 550
551 COLOR should be an instantiator (see `color-specifier-p'), a list of 551 COLOR should be an instantiator (see `color-specifier-p'), a list of
552 instantiators, an alist of specifications (each mapping a locale to 552 instantiators, an alist of specifications (each mapping a locale to
561 See `set-face-property' for more information." 561 See `set-face-property' for more information."
562 (interactive (face-interactive "background")) 562 (interactive (face-interactive "background"))
563 (set-face-property face 'background color locale tag-set how-to-add)) 563 (set-face-property face 'background color locale tag-set how-to-add))
564 564
565 (defun face-background-pixmap (face &optional locale tag-set exact-p) 565 (defun face-background-pixmap (face &optional locale tag-set exact-p)
566 "Return the background pixmap of the given face, or nil if it is unspecified. 566 "Return the background pixmap of FACE in LOCALE, or nil if it is unspecified.
567 This property is only used on X devices. 567 This property is only used on window system devices.
568 568
569 FACE may be either a face object or a symbol representing a face. 569 FACE may be either a face object or a symbol representing a face.
570 570
571 LOCALE may be a locale (the instantiators for that particular locale 571 LOCALE may be a locale (the instantiators for that particular locale
572 will be returned), a locale type (the specifications for all locales 572 will be returned), a locale type (the specifications for all locales
576 See `face-property' for more information." 576 See `face-property' for more information."
577 (face-property face 'background-pixmap locale tag-set exact-p)) 577 (face-property face 'background-pixmap locale tag-set exact-p))
578 578
579 (defun face-background-pixmap-instance (face &optional domain default 579 (defun face-background-pixmap-instance (face &optional domain default
580 no-fallback) 580 no-fallback)
581 "Return the instance of the given face's background pixmap in the given domain. 581 "Return the instance of FACE's background pixmap in DOMAIN.
582 582
583 FACE may be either a face object or a symbol representing a face. 583 FACE may be either a face object or a symbol representing a face.
584 584
585 Normally DOMAIN will be a window or nil (meaning the selected window), 585 Normally DOMAIN will be a window or nil (meaning the selected window),
586 and an instance object describing how the background appears in that 586 and an instance object describing how the background appears in that
589 See `face-property-instance' for more information." 589 See `face-property-instance' for more information."
590 (face-property-instance face 'background-pixmap domain default no-fallback)) 590 (face-property-instance face 'background-pixmap domain default no-fallback))
591 591
592 (defun set-face-background-pixmap (face pixmap &optional locale tag-set 592 (defun set-face-background-pixmap (face pixmap &optional locale tag-set
593 how-to-add) 593 how-to-add)
594 "Change the background pixmap of the given face. 594 "Change the background pixmap of FACE to PIXMAP in LOCALE.
595 This property is only used on X devices. 595 This property is only used on window system devices.
596 596
597 FACE may be either a face object or a symbol representing a face. 597 FACE may be either a face object or a symbol representing a face.
598 598
599 PIXMAP should be an instantiator (see `image-specifier-p'), a list 599 PIXMAP should be an instantiator (see `image-specifier-p'), a list
600 of instantiators, an alist of specifications (each mapping a locale 600 of instantiators, an alist of specifications (each mapping a locale
609 See `set-face-property' for more information." 609 See `set-face-property' for more information."
610 (interactive (face-interactive "background-pixmap")) 610 (interactive (face-interactive "background-pixmap"))
611 (set-face-property face 'background-pixmap pixmap locale tag-set how-to-add)) 611 (set-face-property face 'background-pixmap pixmap locale tag-set how-to-add))
612 612
613 (defun face-display-table (face &optional locale tag-set exact-p) 613 (defun face-display-table (face &optional locale tag-set exact-p)
614 "Return the display table of the given face. 614 "Return the display table of FACE in LOCALE.
615 615
616 A vector (as returned by `make-display-table') will be returned. 616 A vector (as returned by `make-display-table') will be returned.
617 617
618 LOCALE may be a locale (the instantiators for that particular locale 618 LOCALE may be a locale (the instantiators for that particular locale
619 will be returned), a locale type (the specifications for all locales 619 will be returned), a locale type (the specifications for all locales
630 See `face-property-instance' for the semantics of the DOMAIN argument." 630 See `face-property-instance' for the semantics of the DOMAIN argument."
631 (face-property-instance face 'display-table domain default no-fallback)) 631 (face-property-instance face 'display-table domain default no-fallback))
632 632
633 (defun set-face-display-table (face display-table &optional locale tag-set 633 (defun set-face-display-table (face display-table &optional locale tag-set
634 how-to-add) 634 how-to-add)
635 "Change the display table of the given face. 635 "Change the display table of FACE to DISPLAY-TABLE in LOCALE.
636 DISPLAY-TABLE should be a vector as returned by `make-display-table'. 636 DISPLAY-TABLE should be a vector as returned by `make-display-table'.
637 637
638 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 638 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
639 HOW-TO-ADD arguments." 639 HOW-TO-ADD arguments."
640 (interactive (face-interactive "display-table")) 640 (interactive (face-interactive "display-table"))
643 643
644 ;; The following accessors and mutators are, IMHO, good 644 ;; The following accessors and mutators are, IMHO, good
645 ;; implementation. Cf. with `make-face-bold'. 645 ;; implementation. Cf. with `make-face-bold'.
646 646
647 (defun face-underline-p (face &optional domain default no-fallback) 647 (defun face-underline-p (face &optional domain default no-fallback)
648 "Return whether the given face is underlined. 648 "Return t if FACE is underlined in DOMAIN.
649 See `face-property-instance' for the semantics of the DOMAIN argument." 649 See `face-property-instance' for the semantics of the DOMAIN argument."
650 (face-property-instance face 'underline domain default no-fallback)) 650 (face-property-instance face 'underline domain default no-fallback))
651 651
652 (defun set-face-underline-p (face underline-p &optional locale tag-set 652 (defun set-face-underline-p (face underline-p &optional locale tag-set
653 how-to-add) 653 how-to-add)
654 "Change whether the given face is underlined. 654 "Change the underline property of FACE to UNDERLINE-P.
655 UNDERLINE-P is normally a face-boolean instantiator; see 655 UNDERLINE-P is normally a face-boolean instantiator; see
656 `face-boolean-specifier-p'. 656 `face-boolean-specifier-p'.
657 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 657 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
658 HOW-TO-ADD arguments." 658 HOW-TO-ADD arguments."
659 (interactive (face-interactive "underline-p" "underlined")) 659 (interactive (face-interactive "underline-p" "underlined"))
660 (set-face-property face 'underline underline-p locale tag-set how-to-add)) 660 (set-face-property face 'underline underline-p locale tag-set how-to-add))
661 661
662 (defun face-strikethru-p (face &optional domain default no-fallback) 662 (defun face-strikethru-p (face &optional domain default no-fallback)
663 "Return whether the given face is strikethru-d (i.e. struck through). 663 "Return t if FACE is strikethru-d (i.e. struck through) in DOMAIN.
664 See `face-property-instance' for the semantics of the DOMAIN argument." 664 See `face-property-instance' for the semantics of the DOMAIN argument."
665 (face-property-instance face 'strikethru domain default no-fallback)) 665 (face-property-instance face 'strikethru domain default no-fallback))
666 666
667 (defun set-face-strikethru-p (face strikethru-p &optional locale tag-set 667 (defun set-face-strikethru-p (face strikethru-p &optional locale tag-set
668 how-to-add) 668 how-to-add)
669 "Change whether the given face is strikethru-d (i.e. struck through). 669 "Change whether FACE is strikethru-d (i.e. struck through) in LOCALE.
670 STRIKETHRU-P is normally a face-boolean instantiator; see 670 STRIKETHRU-P is normally a face-boolean instantiator; see
671 `face-boolean-specifier-p'. 671 `face-boolean-specifier-p'.
672 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 672 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
673 HOW-TO-ADD arguments." 673 HOW-TO-ADD arguments."
674 (interactive (face-interactive "strikethru-p" "strikethru-d")) 674 (interactive (face-interactive "strikethru-p" "strikethru-d"))
675 (set-face-property face 'strikethru strikethru-p locale tag-set how-to-add)) 675 (set-face-property face 'strikethru strikethru-p locale tag-set how-to-add))
676 676
677 (defun face-highlight-p (face &optional domain default no-fallback) 677 (defun face-highlight-p (face &optional domain default no-fallback)
678 "Return whether the given face is highlighted (TTY domains only). 678 "Return t if FACE is highlighted in DOMAIN (TTY domains only).
679 See `face-property-instance' for the semantics of the DOMAIN argument." 679 See `face-property-instance' for the semantics of the DOMAIN argument."
680 (face-property-instance face 'highlight domain default no-fallback)) 680 (face-property-instance face 'highlight domain default no-fallback))
681 681
682 (defun set-face-highlight-p (face highlight-p &optional locale tag-set 682 (defun set-face-highlight-p (face highlight-p &optional locale tag-set
683 how-to-add) 683 how-to-add)
684 "Change whether the given face is highlighted (TTY locales only). 684 "Change whether FACE is highlighted in LOCALE (TTY locales only).
685 HIGHLIGHT-P is normally a face-boolean instantiator; see 685 HIGHLIGHT-P is normally a face-boolean instantiator; see
686 `face-boolean-specifier-p'. 686 `face-boolean-specifier-p'.
687 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 687 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
688 HOW-TO-ADD arguments." 688 HOW-TO-ADD arguments."
689 (interactive (face-interactive "highlight-p" "highlighted")) 689 (interactive (face-interactive "highlight-p" "highlighted"))
690 (set-face-property face 'highlight highlight-p locale tag-set how-to-add)) 690 (set-face-property face 'highlight highlight-p locale tag-set how-to-add))
691 691
692 (defun face-dim-p (face &optional domain default no-fallback) 692 (defun face-dim-p (face &optional domain default no-fallback)
693 "Return whether the given face is dimmed (TTY domains only). 693 "Return t if FACE is dimmed in DOMAIN (TTY domains only).
694 See `face-property-instance' for the semantics of the DOMAIN argument." 694 See `face-property-instance' for the semantics of the DOMAIN argument."
695 (face-property-instance face 'dim domain default no-fallback)) 695 (face-property-instance face 'dim domain default no-fallback))
696 696
697 (defun set-face-dim-p (face dim-p &optional locale tag-set how-to-add) 697 (defun set-face-dim-p (face dim-p &optional locale tag-set how-to-add)
698 "Change whether the given face is dimmed (TTY locales only). 698 "Change whether FACE is dimmed in LOCALE (TTY locales only).
699 DIM-P is normally a face-boolean instantiator; see 699 DIM-P is normally a face-boolean instantiator; see
700 `face-boolean-specifier-p'. 700 `face-boolean-specifier-p'.
701 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 701 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
702 HOW-TO-ADD arguments." 702 HOW-TO-ADD arguments."
703 (interactive (face-interactive "dim-p" "dimmed")) 703 (interactive (face-interactive "dim-p" "dimmed"))
704 (set-face-property face 'dim dim-p locale tag-set how-to-add)) 704 (set-face-property face 'dim dim-p locale tag-set how-to-add))
705 705
706 (defun face-blinking-p (face &optional domain default no-fallback) 706 (defun face-blinking-p (face &optional domain default no-fallback)
707 "Return whether the given face is blinking (TTY domains only). 707 "Return t if FACE is blinking in DOMAIN (TTY domains only).
708 See `face-property-instance' for the semantics of the DOMAIN argument." 708 See `face-property-instance' for the semantics of the DOMAIN argument."
709 (face-property-instance face 'blinking domain default no-fallback)) 709 (face-property-instance face 'blinking domain default no-fallback))
710 710
711 (defun set-face-blinking-p (face blinking-p &optional locale tag-set 711 (defun set-face-blinking-p (face blinking-p &optional locale tag-set
712 how-to-add) 712 how-to-add)
713 "Change whether the given face is blinking (TTY locales only). 713 "Change whether FACE is blinking in LOCALE (TTY locales only).
714 BLINKING-P is normally a face-boolean instantiator; see 714 BLINKING-P is normally a face-boolean instantiator; see
715 `face-boolean-specifier-p'. 715 `face-boolean-specifier-p'.
716 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 716 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
717 HOW-TO-ADD arguments." 717 HOW-TO-ADD arguments."
718 (interactive (face-interactive "blinking-p" "blinking")) 718 (interactive (face-interactive "blinking-p" "blinking"))
719 (set-face-property face 'blinking blinking-p locale tag-set how-to-add)) 719 (set-face-property face 'blinking blinking-p locale tag-set how-to-add))
720 720
721 (defun face-reverse-p (face &optional domain default no-fallback) 721 (defun face-reverse-p (face &optional domain default no-fallback)
722 "Return whether the given face is reversed (TTY domains only). 722 "Return t if FACE is reversed in DOMAIN (TTY domains only).
723 See `face-property-instance' for the semantics of the DOMAIN argument." 723 See `face-property-instance' for the semantics of the DOMAIN argument."
724 (face-property-instance face 'reverse domain default no-fallback)) 724 (face-property-instance face 'reverse domain default no-fallback))
725 725
726 (defun set-face-reverse-p (face reverse-p &optional locale tag-set how-to-add) 726 (defun set-face-reverse-p (face reverse-p &optional locale tag-set how-to-add)
727 "Change whether the given face is reversed (TTY locales only). 727 "Change whether FACE is reversed in LOCALE (TTY locales only).
728 REVERSE-P is normally a face-boolean instantiator; see 728 REVERSE-P is normally a face-boolean instantiator; see
729 `face-boolean-specifier-p'. 729 `face-boolean-specifier-p'.
730 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and 730 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
731 HOW-TO-ADD arguments." 731 HOW-TO-ADD arguments."
732 (interactive (face-interactive "reverse-p" "reversed")) 732 (interactive (face-interactive "reverse-p" "reversed"))
742 (face-property-equal face1 face2 (car props) domain)) 742 (face-property-equal face1 face2 (car props) domain))
743 (setq props (cdr props))) 743 (setq props (cdr props)))
744 (null props)) 744 (null props))
745 745
746 (defun face-equal (face1 face2 &optional domain) 746 (defun face-equal (face1 face2 &optional domain)
747 "True if the given faces will display in the same way. 747 "Return t if FACE1 and FACE2 will display in the same way in DOMAIN.
748 See `face-property-instance' for the semantics of the DOMAIN argument." 748 See `face-property-instance' for the semantics of the DOMAIN argument."
749 (if (null domain) (setq domain (selected-window))) 749 (if (null domain) (setq domain (selected-window)))
750 (if (not (valid-specifier-domain-p domain)) 750 (if (not (valid-specifier-domain-p domain))
751 (error "Invalid specifier domain")) 751 (error "Invalid specifier domain"))
752 (let ((device (dfw-device domain)) 752 (let ((device (dfw-device domain))
763 ((eq 'x (device-type device)) 763 ((eq 'x (device-type device))
764 (face-equal-loop x-props face1 face2 domain)) 764 (face-equal-loop x-props face1 face2 domain))
765 (t t))))) 765 (t t)))))
766 766
767 (defun face-differs-from-default-p (face &optional domain) 767 (defun face-differs-from-default-p (face &optional domain)
768 "True if the given face will display differently from the default face. 768 "Return t if FACE will display differently from the default face in DOMAIN.
769 See `face-property-instance' for the semantics of the DOMAIN argument." 769 See `face-property-instance' for the semantics of the DOMAIN argument."
770 (not (face-equal face 'default domain))) 770 (not (face-equal face 'default domain)))
771 771
772 772
773 ;; This function is a terrible, disgusting hack!!!! Need to 773 ;; This function is a terrible, disgusting hack!!!! Need to
929 (face-property-instance unfrobbed-face 'font domain))) 929 (face-property-instance unfrobbed-face 'font domain)))
930 (set-face-property face 'font (vector frobbed-face) 930 (set-face-property face 'font (vector frobbed-face)
931 the-locale)))))) 931 the-locale))))))
932 932
933 (defun make-face-bold (face &optional locale) 933 (defun make-face-bold (face &optional locale)
934 "Make the face bold, if possible. 934 "Make FACE bold in LOCALE, if possible.
935 This will attempt to make the font bold for X locales and will set the 935 This will attempt to make the font bold for X locales and will set the
936 highlight flag for TTY locales. 936 highlight flag for TTY locales.
937 937
938 If LOCALE is nil, omitted, or `all', this will attempt to frob all 938 If LOCALE is nil, omitted, or `all', this will attempt to frob all
939 font specifications for FACE to make them appear bold. Similarly, if 939 font specifications for FACE to make them appear bold. Similarly, if
975 ([bold] . t) 975 ([bold] . t)
976 ([italic] . [bold-italic]) 976 ([italic] . [bold-italic])
977 ([bold-italic] . t)))) 977 ([bold-italic] . t))))
978 978
979 (defun make-face-italic (face &optional locale) 979 (defun make-face-italic (face &optional locale)
980 "Make the face italic, if possible. 980 "Make FACE italic in LOCALE, if possible.
981 This will attempt to make the font italic for X locales and will set 981 This will attempt to make the font italic for X locales and will set
982 the underline flag for TTY locales. 982 the underline flag for TTY locales.
983 See `make-face-bold' for the semantics of the LOCALE argument and 983 See `make-face-bold' for the semantics of the LOCALE argument and
984 for more specifics on exactly how this function works." 984 for more specifics on exactly how this function works."
985 (interactive (list (read-face-name "Make which face italic: "))) 985 (interactive (list (read-face-name "Make which face italic: ")))
1000 ([bold] . [bold-italic]) 1000 ([bold] . [bold-italic])
1001 ([italic] . t) 1001 ([italic] . t)
1002 ([bold-italic] . t)))) 1002 ([bold-italic] . t))))
1003 1003
1004 (defun make-face-bold-italic (face &optional locale) 1004 (defun make-face-bold-italic (face &optional locale)
1005 "Make the face bold and italic, if possible. 1005 "Make FACE bold and italic in LOCALE, if possible.
1006 This will attempt to make the font bold-italic for X locales and will 1006 This will attempt to make the font bold-italic for X locales and will
1007 set the highlight and underline flags for TTY locales. 1007 set the highlight and underline flags for TTY locales.
1008 See `make-face-bold' for the semantics of the LOCALE argument and 1008 See `make-face-bold' for the semantics of the LOCALE argument and
1009 for more specifics on exactly how this function works." 1009 for more specifics on exactly how this function works."
1010 (interactive (list (read-face-name "Make which face bold-italic: "))) 1010 (interactive (list (read-face-name "Make which face bold-italic: ")))
1026 ([bold] . [bold-italic]) 1026 ([bold] . [bold-italic])
1027 ([italic] . [bold-italic]) 1027 ([italic] . [bold-italic])
1028 ([bold-italic] . t)))) 1028 ([bold-italic] . t))))
1029 1029
1030 (defun make-face-unbold (face &optional locale) 1030 (defun make-face-unbold (face &optional locale)
1031 "Make the face non-bold, if possible. 1031 "Make FACE non-bold in LOCALE, if possible.
1032 This will attempt to make the font non-bold for X locales and will 1032 This will attempt to make the font non-bold for X locales and will
1033 unset the highlight flag for TTY locales. 1033 unset the highlight flag for TTY locales.
1034 See `make-face-bold' for the semantics of the LOCALE argument and 1034 See `make-face-bold' for the semantics of the LOCALE argument and
1035 for more specifics on exactly how this function works." 1035 for more specifics on exactly how this function works."
1036 (interactive (list (read-face-name "Make which face non-bold: "))) 1036 (interactive (list (read-face-name "Make which face non-bold: ")))
1051 ([bold] . [default]) 1051 ([bold] . [default])
1052 ([italic] . t) 1052 ([italic] . t)
1053 ([bold-italic] . [italic])))) 1053 ([bold-italic] . [italic]))))
1054 1054
1055 (defun make-face-unitalic (face &optional locale) 1055 (defun make-face-unitalic (face &optional locale)
1056 "Make the face non-italic, if possible. 1056 "Make FACE non-italic in LOCALE, if possible.
1057 This will attempt to make the font non-italic for X locales and will 1057 This will attempt to make the font non-italic for X locales and will
1058 unset the underline flag for TTY locales. 1058 unset the underline flag for TTY locales.
1059 See `make-face-bold' for the semantics of the LOCALE argument and 1059 See `make-face-bold' for the semantics of the LOCALE argument and
1060 for more specifics on exactly how this function works." 1060 for more specifics on exactly how this function works."
1061 (interactive (list (read-face-name "Make which face non-italic: "))) 1061 (interactive (list (read-face-name "Make which face non-italic: ")))
1080 1080
1081 ;; Why do the following two functions lose so badly in so many 1081 ;; Why do the following two functions lose so badly in so many
1082 ;; circumstances? 1082 ;; circumstances?
1083 1083
1084 (defun make-face-smaller (face &optional locale) 1084 (defun make-face-smaller (face &optional locale)
1085 "Make the font of the given face be smaller, if possible. 1085 "Make the font of FACE be smaller, if possible.
1086 LOCALE works as in `make-face-bold' et al., but the ``inheriting- 1086 LOCALE works as in `make-face-bold' et al., but the ``inheriting-
1087 from-the-bold-face'' operations described there are not done 1087 from-the-bold-face'' operations described there are not done
1088 because they don't make sense in this context." 1088 because they don't make sense in this context."
1089 (interactive (list (read-face-name "Shrink which face: "))) 1089 (interactive (list (read-face-name "Shrink which face: ")))
1090 ;; handle X specific entries 1090 ;; handle X specific entries
1092 (frob-face-property face 'font 'x-find-smaller-font locale)) 1092 (frob-face-property face 'font 'x-find-smaller-font locale))
1093 (when (featurep 'mswindows) 1093 (when (featurep 'mswindows)
1094 (frob-face-property face 'font 'mswindows-find-smaller-font locale))) 1094 (frob-face-property face 'font 'mswindows-find-smaller-font locale)))
1095 1095
1096 (defun make-face-larger (face &optional locale) 1096 (defun make-face-larger (face &optional locale)
1097 "Make the font of the given face be larger, if possible. 1097 "Make the font of FACE be larger, if possible.
1098 See `make-face-smaller' for the semantics of the LOCALE argument." 1098 See `make-face-smaller' for the semantics of the LOCALE argument."
1099 (interactive (list (read-face-name "Enlarge which face: "))) 1099 (interactive (list (read-face-name "Enlarge which face: ")))
1100 ;; handle X specific entries 1100 ;; handle X specific entries
1101 (when (featurep 'x) 1101 (when (featurep 'x)
1102 (frob-face-property face 'font 'x-find-larger-font locale)) 1102 (frob-face-property face 'font 'x-find-larger-font locale))
1117 1117
1118 1118
1119 ;;; Convenience functions 1119 ;;; Convenience functions
1120 1120
1121 (defun face-ascent (face &optional domain charset) 1121 (defun face-ascent (face &optional domain charset)
1122 "Return the ascent of a face. 1122 "Return the ascent of FACE in DOMAIN.
1123 See `face-property-instance' for the semantics of the DOMAIN argument." 1123 See `face-property-instance' for the semantics of the DOMAIN argument."
1124 (font-ascent (face-font face) domain charset)) 1124 (font-ascent (face-font face) domain charset))
1125 1125
1126 (defun face-descent (face &optional domain charset) 1126 (defun face-descent (face &optional domain charset)
1127 "Return the descent of a face. 1127 "Return the descent of FACE in DOMAIN.
1128 See `face-property-instance' for the semantics of the DOMAIN argument." 1128 See `face-property-instance' for the semantics of the DOMAIN argument."
1129 (font-descent (face-font face) domain charset)) 1129 (font-descent (face-font face) domain charset))
1130 1130
1131 (defun face-width (face &optional domain charset) 1131 (defun face-width (face &optional domain charset)
1132 "Return the width of a face. 1132 "Return the width of FACE in DOMAIN.
1133 See `face-property-instance' for the semantics of the DOMAIN argument." 1133 See `face-property-instance' for the semantics of the DOMAIN argument."
1134 (font-width (face-font face) domain charset)) 1134 (font-width (face-font face) domain charset))
1135 1135
1136 (defun face-height (face &optional domain charset) 1136 (defun face-height (face &optional domain charset)
1137 "Return the height of a face. 1137 "Return the height of FACE in DOMAIN.
1138 See `face-property-instance' for the semantics of the DOMAIN argument." 1138 See `face-property-instance' for the semantics of the DOMAIN argument."
1139 (+ (face-ascent face domain charset) (face-descent face domain charset))) 1139 (+ (face-ascent face domain charset) (face-descent face domain charset)))
1140 1140
1141 (defun face-proportional-p (face &optional domain charset) 1141 (defun face-proportional-p (face &optional domain charset)
1142 "Return whether FACE is proportional. 1142 "Return t if FACE is proportional in DOMAIN.
1143 See `face-property-instance' for the semantics of the DOMAIN argument." 1143 See `face-property-instance' for the semantics of the DOMAIN argument."
1144 (font-proportional-p (face-font face) domain charset)) 1144 (font-proportional-p (face-font face) domain charset))
1145 1145
1146 1146
1147 ;; Functions that used to be in cus-face.el, but logically go here. 1147 ;; Functions that used to be in cus-face.el, but logically go here.
1150 "*The brightness of the background. 1150 "*The brightness of the background.
1151 Set this to the symbol dark if your background color is dark, light if 1151 Set this to the symbol dark if your background color is dark, light if
1152 your background is light, or nil (default) if you want Emacs to 1152 your background is light, or nil (default) if you want Emacs to
1153 examine the brightness for you." 1153 examine the brightness for you."
1154 :group 'faces 1154 :group 'faces
1155 :type '(choice (choice-item dark) 1155 :type '(choice (choice-item dark)
1156 (choice-item light) 1156 (choice-item light)
1157 (choice-item :tag "Auto" nil))) 1157 (choice-item :tag "Auto" nil)))
1158 1158
1159 ;; The old variable that many people still have in .emacs files. 1159 ;; The old variable that many people still have in .emacs files.
1160 (define-obsolete-variable-alias 'custom-background-mode 1160 (define-obsolete-variable-alias 'custom-background-mode
1226 (setq spec nil))))) 1226 (setq spec nil)))))
1227 1227
1228 (defvar default-custom-frame-properties nil 1228 (defvar default-custom-frame-properties nil
1229 "The frame properties used for the global faces. 1229 "The frame properties used for the global faces.
1230 Frames not matching these propertiess should have frame local faces. 1230 Frames not matching these propertiess should have frame local faces.
1231 The value should be nil, if uninitialized, or a plist otherwise. 1231 The value should be nil, if uninitialized, or a plist otherwise.
1232 See `defface' for a list of valid keys and values for the plist.") 1232 See `defface' for a list of valid keys and values for the plist.")
1233 1233
1234 (defun get-custom-frame-properties (&optional frame) 1234 (defun get-custom-frame-properties (&optional frame)
1235 "Return a plist with the frame properties of FRAME used by custom. 1235 "Return a plist with the frame properties of FRAME used by custom.
1236 If FRAME is nil, return the default frame properties." 1236 If FRAME is nil, return the default frame properties."
1248 ;;(default-custom-frame-properties) 1248 ;;(default-custom-frame-properties)
1249 (t 1249 (t
1250 (setq default-custom-frame-properties 1250 (setq default-custom-frame-properties
1251 (extract-custom-frame-properties (selected-frame)))))) 1251 (extract-custom-frame-properties (selected-frame))))))
1252 1252
1253 (defun face-spec-set-match-display (display frame) 1253 (defun face-spec-set-match-display (display &optional frame)
1254 "Non-nil iff DISPLAY matches FRAME. 1254 "Return non-nil if DISPLAY matches FRAME.
1255 DISPLAY is part of a spec such as can be used in `defface'. 1255 DISPLAY is part of a spec such as can be used in `defface'.
1256 If FRAME is nil, the current FRAME is used." 1256 If FRAME is nil or omitted, the selected frame is used."
1257 (if (eq display t) 1257 (if (eq display t)
1258 t 1258 t
1259 (let* ((props (get-custom-frame-properties frame)) 1259 (let* ((props (get-custom-frame-properties frame))
1260 (type (plist-get props 'type)) 1260 (type (plist-get props 'type))
1261 (class (plist-get props 'class)) 1261 (class (plist-get props 'class))
1302 (face-display-set symbol spec frame)))) 1302 (face-display-set symbol spec frame))))
1303 (face-list))) 1303 (face-list)))
1304 1304
1305 (defun custom-initialize-frame (frame) 1305 (defun custom-initialize-frame (frame)
1306 "Initialize frame-local custom faces for FRAME if necessary." 1306 "Initialize frame-local custom faces for FRAME if necessary."
1307 (unless (equal (get-custom-frame-properties) 1307 (unless (equal (get-custom-frame-properties)
1308 (get-custom-frame-properties frame)) 1308 (get-custom-frame-properties frame))
1309 (initialize-custom-faces frame))) 1309 (initialize-custom-faces frame)))
1310 1310
1311 1311
1312 (defun make-empty-face (name &optional doc-string temporary) 1312 (defun make-empty-face (name &optional doc-string temporary)
1447 ;; For instance, the definition of `bold' should be something like 1447 ;; For instance, the definition of `bold' should be something like
1448 ;; (defface bold ((t (:bold t))) "Bold text.") -- and `:bold t' should 1448 ;; (defface bold ((t (:bold t))) "Bold text.") -- and `:bold t' should
1449 ;; make sure that everything works properly. 1449 ;; make sure that everything works properly.
1450 1450
1451 (defun init-other-random-faces (device) 1451 (defun init-other-random-faces (device)
1452 "Initializes the colors and fonts of the bold, italic, bold-italic, 1452 "Initialize the colors and fonts of the bold, italic, bold-italic,
1453 zmacs-region, list-mode-item-selected, highlight, primary-selection, 1453 zmacs-region, list-mode-item-selected, highlight, primary-selection,
1454 secondary-selection, and isearch faces when each device is created. If 1454 secondary-selection, and isearch faces when each device is created. If
1455 you want to add code to do stuff like this, use the create-device-hook." 1455 you want to add code to do stuff like this, use the create-device-hook."
1456 1456
1457 ;; try to make 'bold look different from the default on this device. 1457 ;; try to make 'bold look different from the default on this device.
1467 ;; Similar for italic. 1467 ;; Similar for italic.
1468 ;; It's unreasonable to expect to be able to make a font italic all 1468 ;; It's unreasonable to expect to be able to make a font italic all
1469 ;; the time. For many languages, italic is an alien concept. 1469 ;; the time. For many languages, italic is an alien concept.
1470 ;; Basically, because italic is not a globally meaningful concept, 1470 ;; Basically, because italic is not a globally meaningful concept,
1471 ;; the use of the italic face should really be oboleted. 1471 ;; the use of the italic face should really be oboleted.
1472 1472
1473 ;; I disagree with above. In many languages, the concept of capital 1473 ;; I disagree with above. In many languages, the concept of capital
1474 ;; letters is just as alien, and yet we use them. Italic is here to 1474 ;; letters is just as alien, and yet we use them. Italic is here to
1475 ;; stay. -hniksic 1475 ;; stay. -hniksic
1476 1476
1477 ;; In a Solaris Japanese environment, there just aren't any italic 1477 ;; In a Solaris Japanese environment, there just aren't any italic
1518 nil 'append)) 1518 nil 'append))
1519 ) 1519 )
1520 1520
1521 ;; New function with 20.1, suggested by Per Abrahamsen, coded by Kyle Jones. 1521 ;; New function with 20.1, suggested by Per Abrahamsen, coded by Kyle Jones.
1522 (defun set-face-stipple (face pixmap &optional frame) 1522 (defun set-face-stipple (face pixmap &optional frame)
1523 "Change the stipple pixmap of face FACE to PIXMAP. 1523 "Change the stipple pixmap of FACE to PIXMAP.
1524 This is an Emacs compatibility function; consider using 1524 This is an Emacs compatibility function; consider using
1525 set-face-background-pixmap instead. 1525 set-face-background-pixmap instead.
1526 1526
1527 PIXMAP should be a string, the name of a file of pixmap data. 1527 PIXMAP should be a string, the name of a file of pixmap data.
1528 The directories listed in the `x-bitmap-file-path' variable are searched. 1528 The directories listed in the `x-bitmap-file-path' variable are searched.