diff options
| author | Richard M. Stallman | 1993-07-13 22:05:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-13 22:05:13 +0000 |
| commit | 710e70052ba5120ea061af816b83e1200f164c6a (patch) | |
| tree | a449ce7ef828f2185095aa960f4742d0d069ecba | |
| parent | e8a700bfcdb1bed2768562449d3217dab80cc5d7 (diff) | |
| download | emacs-710e70052ba5120ea061af816b83e1200f164c6a.tar.gz emacs-710e70052ba5120ea061af816b83e1200f164c6a.zip | |
(copy-face): New arg NEW-FRAME.
(list-faces-display): New command.
| -rw-r--r-- | lisp/faces.el | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index a9481f30ad8..fb418ec5b29 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -287,14 +287,18 @@ If the face already exists, it is unmodified." | |||
| 287 | ))) | 287 | ))) |
| 288 | face) | 288 | face) |
| 289 | 289 | ||
| 290 | (defun copy-face (old-face new-name &optional frame) | 290 | (defun copy-face (old-face new-name &optional frame new-frame) |
| 291 | "Define a face just like OLD-FACE, with name NEW-NAME. | 291 | "Define a face just like OLD-FACE, with name NEW-NAME. |
| 292 | If NEW-NAME already exists as a face, it is modified to be like OLD-FACE. | 292 | If NEW-NAME already exists as a face, it is modified to be like OLD-FACE. |
| 293 | If the optional argument FRAME is given, this applies only to that frame. | 293 | If the optional argument FRAME is given, this applies only to that frame. |
| 294 | Otherwise it applies to each frame separately." | 294 | Otherwise it applies to each frame separately. |
| 295 | If the optional fourth argument NEW-FRAME is given, | ||
| 296 | copy the information from face OLD-FACE on frame FRAME | ||
| 297 | to face NEW-NAME on frame NEW-FRAME." | ||
| 298 | (or new-frame (setq new-frame frame)) | ||
| 295 | (setq old-face (internal-get-face old-face frame)) | 299 | (setq old-face (internal-get-face old-face frame)) |
| 296 | (let* ((inhibit-quit t) | 300 | (let* ((inhibit-quit t) |
| 297 | (new-face (or (internal-find-face new-name frame) | 301 | (new-face (or (internal-find-face new-name new-frame) |
| 298 | (make-face new-name)))) | 302 | (make-face new-name)))) |
| 299 | (if (null frame) | 303 | (if (null frame) |
| 300 | (let ((frames (frame-list))) | 304 | (let ((frames (frame-list))) |
| @@ -302,13 +306,13 @@ Otherwise it applies to each frame separately." | |||
| 302 | (copy-face old-face new-name (car frames)) | 306 | (copy-face old-face new-name (car frames)) |
| 303 | (setq frames (cdr frames))) | 307 | (setq frames (cdr frames))) |
| 304 | (copy-face old-face new-name t)) | 308 | (copy-face old-face new-name t)) |
| 305 | (set-face-font new-face (face-font old-face frame) frame) | 309 | (set-face-font new-face (face-font old-face frame) new-frame) |
| 306 | (set-face-foreground new-face (face-foreground old-face frame) frame) | 310 | (set-face-foreground new-face (face-foreground old-face frame) new-frame) |
| 307 | (set-face-background new-face (face-background old-face frame) frame) | 311 | (set-face-background new-face (face-background old-face frame) new-frame) |
| 308 | ;;; (set-face-background-pixmap | 312 | ;;; (set-face-background-pixmap |
| 309 | ;;; new-face (face-background-pixmap old-face frame) frame) | 313 | ;;; new-face (face-background-pixmap old-face frame) new-frame) |
| 310 | (set-face-underline-p new-face (face-underline-p old-face frame) | 314 | (set-face-underline-p new-face (face-underline-p old-face frame) |
| 311 | frame)) | 315 | new-frame)) |
| 312 | new-face)) | 316 | new-face)) |
| 313 | 317 | ||
| 314 | (defun face-equal (face1 face2 &optional frame) | 318 | (defun face-equal (face1 face2 &optional frame) |
| @@ -621,6 +625,50 @@ If NOERROR is non-nil, return nil on failure." | |||
| 621 | (and (not noerror) | 625 | (and (not noerror) |
| 622 | (error "No unitalic version of %S" font1))))) | 626 | (error "No unitalic version of %S" font1))))) |
| 623 | 627 | ||
| 628 | (defvar list-faces-sample-text | ||
| 629 | "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
| 630 | "*Text string to display as the sample text for `list-faces-display'.") | ||
| 631 | |||
| 632 | ;; The name list-faces would be more consistent, but let's avoid a conflict | ||
| 633 | ;; with Lucid, which uses that name differently. | ||
| 634 | (defun list-faces-display () | ||
| 635 | "List all faces, using the same sample text in each. | ||
| 636 | The sample text is a string that comes from the variable | ||
| 637 | `list-faces-sample-text'. | ||
| 638 | |||
| 639 | It is possible to give a particular face name different appearances in | ||
| 640 | different frames. This command shows the appearance in the | ||
| 641 | selected frame." | ||
| 642 | (interactive) | ||
| 643 | (let ((faces (sort (face-list) (function string-lessp))) | ||
| 644 | (face nil) | ||
| 645 | (frame (selected-frame)) | ||
| 646 | disp-frame window) | ||
| 647 | (with-output-to-temp-buffer "*Faces*" | ||
| 648 | (save-excursion | ||
| 649 | (set-buffer standard-output) | ||
| 650 | (setq truncate-lines t) | ||
| 651 | (while faces | ||
| 652 | (setq face (car faces)) | ||
| 653 | (setq faces (cdr faces)) | ||
| 654 | (insert (format "%25s " (symbol-name face))) | ||
| 655 | (let ((beg (point))) | ||
| 656 | (insert list-faces-sample-text) | ||
| 657 | (insert "\n") | ||
| 658 | (put-text-property beg (1- (point)) 'face face))) | ||
| 659 | (goto-char (point-min)))) | ||
| 660 | ;; If the *Faces* buffer appears in a different frame, | ||
| 661 | ;; copy all the face definitions from FRAME, | ||
| 662 | ;; so that the display will reflect the frame that was selected. | ||
| 663 | (setq window (get-buffer-window (get-buffer "*Faces*") t)) | ||
| 664 | (setq disp-frame (if window (window-frame window) | ||
| 665 | (car (frame-list)))) | ||
| 666 | (or (eq frame disp-frame) | ||
| 667 | (let ((faces (face-list))) | ||
| 668 | (while faces | ||
| 669 | (copy-face (car faces) (car faces) frame disp-frame) | ||
| 670 | (setq faces (cdr faces))))))) | ||
| 671 | |||
| 624 | ;;; Make the default and modeline faces; the C code knows these as | 672 | ;;; Make the default and modeline faces; the C code knows these as |
| 625 | ;;; faces 0 and 1, respectively, so they must be the first two faces | 673 | ;;; faces 0 and 1, respectively, so they must be the first two faces |
| 626 | ;;; made. | 674 | ;;; made. |