diff options
| author | Lute Kamstra | 2005-07-01 08:30:30 +0000 |
|---|---|---|
| committer | Lute Kamstra | 2005-07-01 08:30:30 +0000 |
| commit | b97c98ad01e66166679c23cc5e6a9a1a018f7bd8 (patch) | |
| tree | 0fd72ef601ee00bd2326d022fd9a0e1030b0a099 | |
| parent | 11bc6e51a0868393ca6879cd4b122e8d78d67c11 (diff) | |
| download | emacs-b97c98ad01e66166679c23cc5e6a9a1a018f7bd8.tar.gz emacs-b97c98ad01e66166679c23cc5e6a9a1a018f7bd8.zip | |
(facemenu-unlisted-faces): Delete foreground and background color
faces.
(facemenu-set-foreground, facemenu-set-background): Use
facemenu-set-face-from-menu.
(facemenu-set-face-from-menu): Treat face names that start with "fg:"
or "bg:" as special.
(facemenu-add-new-color): Don't create faces. Simplify.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/facemenu.el | 72 |
2 files changed, 49 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 407f779999a..0aaf512a1bb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2005-07-01 Lute Kamstra <lute@gnu.org> | ||
| 2 | |||
| 3 | * facemenu.el (facemenu-unlisted-faces): Delete foreground and | ||
| 4 | background color faces. | ||
| 5 | (facemenu-set-foreground, facemenu-set-background): Use | ||
| 6 | facemenu-set-face-from-menu. | ||
| 7 | (facemenu-set-face-from-menu): Treat face names that start with | ||
| 8 | "fg:" or "bg:" as special. | ||
| 9 | (facemenu-add-new-color): Don't create faces. Simplify. | ||
| 10 | |||
| 1 | 2005-06-30 Richard M. Stallman <rms@gnu.org> | 11 | 2005-06-30 Richard M. Stallman <rms@gnu.org> |
| 2 | 12 | ||
| 3 | * emacs-lisp/crm.el (crm-do-completion): Handle minibuffer prompt. | 13 | * emacs-lisp/crm.el (crm-do-completion): Handle minibuffer prompt. |
diff --git a/lisp/facemenu.el b/lisp/facemenu.el index 43c275e4a2f..acbb4d80f6a 100644 --- a/lisp/facemenu.el +++ b/lisp/facemenu.el | |||
| @@ -135,8 +135,7 @@ just before \"Other\" at the end." | |||
| 135 | `(modeline region secondary-selection highlight scratch-face | 135 | `(modeline region secondary-selection highlight scratch-face |
| 136 | ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-") | 136 | ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-") |
| 137 | ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-") | 137 | ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-") |
| 138 | ,(purecopy "^widget-") ,(purecopy "^custom-") ,(purecopy "^vm-") | 138 | ,(purecopy "^widget-") ,(purecopy "^custom-") ,(purecopy "^vm-")) |
| 139 | ,(purecopy "^fg:") ,(purecopy "^bg:")) | ||
| 140 | "*List of faces not to include in the Face menu. | 139 | "*List of faces not to include in the Face menu. |
| 141 | Each element may be either a symbol, which is the name of a face, or a string, | 140 | Each element may be either a symbol, which is the name of a face, or a string, |
| 142 | which is a regular expression to be matched against face names. Matching | 141 | which is a regular expression to be matched against face names. Matching |
| @@ -366,8 +365,9 @@ typing a character to insert cancels the specification." | |||
| 366 | (region-beginning)) | 365 | (region-beginning)) |
| 367 | (if (and mark-active (not current-prefix-arg)) | 366 | (if (and mark-active (not current-prefix-arg)) |
| 368 | (region-end)))) | 367 | (region-end)))) |
| 369 | (facemenu-add-face (facemenu-add-new-color color 'facemenu-foreground-menu) | 368 | (facemenu-set-face-from-menu |
| 370 | start end)) | 369 | (facemenu-add-new-color color 'facemenu-foreground-menu) |
| 370 | start end)) | ||
| 371 | 371 | ||
| 372 | ;;;###autoload | 372 | ;;;###autoload |
| 373 | (defun facemenu-set-background (color &optional start end) | 373 | (defun facemenu-set-background (color &optional start end) |
| @@ -388,31 +388,41 @@ typing a character to insert cancels the specification." | |||
| 388 | (region-beginning)) | 388 | (region-beginning)) |
| 389 | (if (and mark-active (not current-prefix-arg)) | 389 | (if (and mark-active (not current-prefix-arg)) |
| 390 | (region-end)))) | 390 | (region-end)))) |
| 391 | (facemenu-add-face (facemenu-add-new-color color 'facemenu-background-menu) | 391 | (facemenu-set-face-from-menu |
| 392 | start end)) | 392 | (facemenu-add-new-color color 'facemenu-background-menu) |
| 393 | start end)) | ||
| 393 | 394 | ||
| 394 | ;;;###autoload | 395 | ;;;###autoload |
| 395 | (defun facemenu-set-face-from-menu (face start end) | 396 | (defun facemenu-set-face-from-menu (face start end) |
| 396 | "Set the FACE of the region or next character typed. | 397 | "Set the FACE of the region or next character typed. |
| 397 | This function is designed to be called from a menu; the face to use | 398 | This function is designed to be called from a menu; FACE is determined |
| 398 | is the menu item's name. | 399 | using the event type of the menu entry. If FACE is a symbol whose |
| 400 | name starts with \"fg:\" or \"bg:\", then this functions sets the | ||
| 401 | foreground or background to the color specified by the rest of the | ||
| 402 | symbol's name. Any other symbol is considered the name of a face. | ||
| 399 | 403 | ||
| 400 | If the region is active (normally true except in Transient Mark mode) | 404 | If the region is active (normally true except in Transient Mark mode) |
| 401 | and there is no prefix argument, this command sets the region to the | 405 | and there is no prefix argument, this command sets the region to the |
| 402 | requested face. | 406 | requested face. |
| 403 | 407 | ||
| 404 | Otherwise, this command specifies the face for the next character | 408 | Otherwise, this command specifies the face for the next character |
| 405 | inserted. Moving point or switching buffers before | 409 | inserted. Moving point or switching buffers before typing a character |
| 406 | typing a character to insert cancels the specification." | 410 | to insert cancels the specification." |
| 407 | (interactive (list last-command-event | 411 | (interactive (list last-command-event |
| 408 | (if (and mark-active (not current-prefix-arg)) | 412 | (if (and mark-active (not current-prefix-arg)) |
| 409 | (region-beginning)) | 413 | (region-beginning)) |
| 410 | (if (and mark-active (not current-prefix-arg)) | 414 | (if (and mark-active (not current-prefix-arg)) |
| 411 | (region-end)))) | 415 | (region-end)))) |
| 412 | (barf-if-buffer-read-only) | 416 | (barf-if-buffer-read-only) |
| 413 | (if start | 417 | (facemenu-add-face |
| 414 | (facemenu-add-face face start end) | 418 | (let ((fn (symbol-name face))) |
| 415 | (facemenu-add-face face))) | 419 | (if (string-match "\\`\\([fb]\\)g:\\(.+\\)" fn) |
| 420 | (list (list (if (string= (match-string 1 fn) "f") | ||
| 421 | :foreground | ||
| 422 | :background) | ||
| 423 | (match-string 2 fn))) | ||
| 424 | face)) | ||
| 425 | start end)) | ||
| 416 | 426 | ||
| 417 | ;;;###autoload | 427 | ;;;###autoload |
| 418 | (defun facemenu-set-invisible (start end) | 428 | (defun facemenu-set-invisible (start end) |
| @@ -708,7 +718,7 @@ This is called whenever you create a new face." | |||
| 708 | (defun facemenu-add-new-color (color menu) | 718 | (defun facemenu-add-new-color (color menu) |
| 709 | "Add COLOR (a color name string) to the appropriate Face menu. | 719 | "Add COLOR (a color name string) to the appropriate Face menu. |
| 710 | MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'. | 720 | MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'. |
| 711 | Create the appropriate face and return it. | 721 | Return the event type (a symbol) of the added menu entry. |
| 712 | 722 | ||
| 713 | This is called whenever you use a new color." | 723 | This is called whenever you use a new color." |
| 714 | (let (symbol docstring) | 724 | (let (symbol docstring) |
| @@ -718,30 +728,26 @@ This is called whenever you use a new color." | |||
| 718 | (setq docstring | 728 | (setq docstring |
| 719 | (format "Select foreground color %s for subsequent insertion." | 729 | (format "Select foreground color %s for subsequent insertion." |
| 720 | color) | 730 | color) |
| 721 | symbol (intern (concat "fg:" color))) | 731 | symbol (intern (concat "fg:" color)))) |
| 722 | (set-face-foreground (make-face symbol) color)) | ||
| 723 | ((eq menu 'facemenu-background-menu) | 732 | ((eq menu 'facemenu-background-menu) |
| 724 | (setq docstring | 733 | (setq docstring |
| 725 | (format "Select background color %s for subsequent insertion." | 734 | (format "Select background color %s for subsequent insertion." |
| 726 | color) | 735 | color) |
| 727 | symbol (intern (concat "bg:" color))) | 736 | symbol (intern (concat "bg:" color)))) |
| 728 | (set-face-background (make-face symbol) color)) | ||
| 729 | (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'"))) | 737 | (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'"))) |
| 730 | (cond ((facemenu-iterate ; check if equivalent face is already in the menu | 738 | (unless (facemenu-iterate ; Check if color is already in the menu. |
| 731 | (lambda (m) (and (listp m) | 739 | (lambda (m) (and (listp m) |
| 732 | (symbolp (car m)) | 740 | (eq (car m) symbol))) |
| 733 | (stringp (cadr m)) | 741 | (cdr (symbol-function menu))) |
| 734 | (string-equal (cadr m) color))) | 742 | ;; Color is not in the menu. Figure out where to put it. |
| 735 | (cdr (symbol-function menu)))) | 743 | (let ((key (vector symbol)) |
| 736 | (t ; No keyboard equivalent. Figure out where to put it: | 744 | (function 'facemenu-set-face-from-menu) |
| 737 | (let ((key (vector symbol)) | 745 | (menu-val (symbol-function menu))) |
| 738 | (function 'facemenu-set-face-from-menu) | 746 | (if (and facemenu-new-faces-at-end |
| 739 | (menu-val (symbol-function menu))) | 747 | (> (length menu-val) 3)) |
| 740 | (if (and facemenu-new-faces-at-end | 748 | (define-key-after menu-val key (cons color function) |
| 741 | (> (length menu-val) 3)) | 749 | (car (nth (- (length menu-val) 3) menu-val))) |
| 742 | (define-key-after menu-val key (cons color function) | 750 | (define-key menu key (cons color function))))) |
| 743 | (car (nth (- (length menu-val) 3) menu-val))) | ||
| 744 | (define-key menu key (cons color function)))))) | ||
| 745 | symbol)) | 751 | symbol)) |
| 746 | 752 | ||
| 747 | (defun facemenu-complete-face-list (&optional oldlist) | 753 | (defun facemenu-complete-face-list (&optional oldlist) |