aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Danjou2012-06-28 12:40:24 +0200
committerJulien Danjou2012-06-28 12:40:24 +0200
commitae4969c2d69a74c896eb49c9a34aeb645ffed082 (patch)
tree0227f0d8b09f0e1c065f62f863d430603c4c80c1
parent7ee3791f5b55b455a133f930040061f8a7032401 (diff)
downloademacs-ae4969c2d69a74c896eb49c9a34aeb645ffed082.tar.gz
emacs-ae4969c2d69a74c896eb49c9a34aeb645ffed082.zip
term: rework color cutomizing
* term.el (term-handle-colors-array): Use a set of new faces to color the terminal. Also uses :inverse-video property. (term-default-fg-color): Set to nil by default, deprecate in favor of `term-face'. (term-default-bg-color): Set to nil by default, deprecate in favor of `term-face'. (term-current-face): Use `term-face' by default. (term-bold-attribute): Variable deleted.
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/term.el146
3 files changed, 109 insertions, 57 deletions
diff --git a/etc/NEWS b/etc/NEWS
index e804805c8d0..89cbe4ec584 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -160,6 +160,15 @@ character when doing minibuffer filename prompts.
160 160
161* Changes in Specialized Modes and Packages in Emacs 24.2 161* Changes in Specialized Modes and Packages in Emacs 24.2
162 162
163** Term changes
164
165The variables `term-default-fg-color' and `term-default-bg-color' are
166now deprecated in favor of the `term-face' face, that you can
167customize. Also, it is now possible to cutomize how are displayed the
168ANSI terminal colors and styles by cutomizing the corresponding
169`term-color-<COLOR>', `term-color-underline' and `term-color-bold'
170faces.
171
163** CL's main entry is now (require 'cl-lib). 172** CL's main entry is now (require 'cl-lib).
164`cl-lib' is like the old `cl' except that it uses the namespace cleanly, 173`cl-lib' is like the old `cl' except that it uses the namespace cleanly,
165i.e. all its definitions have the "cl-" prefix. 174i.e. all its definitions have the "cl-" prefix.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5bf2036e11f..26b6c6fd322 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12012-06-28 Julien Danjou <julien@danjou.info>
2
3 * term.el (term-handle-colors-array): Use a set of new faces to
4 color the terminal. Also uses :inverse-video property.
5 (term-default-fg-color): Set to nil by default, deprecate in favor
6 of `term-face'.
7 (term-default-bg-color): Set to nil by default, deprecate in favor
8 of `term-face'.
9 (term-current-face): Use `term-face' by default.
10 (term-bold-attribute): Variable deleted.
11
12012-06-28 Glenn Morris <rgm@gnu.org> 122012-06-28 Glenn Morris <rgm@gnu.org>
2 13
3 * simple.el (completion-list-mode-finish): 14 * simple.el (completion-list-mode-finish):
diff --git a/lisp/term.el b/lisp/term.el
index 7461d7443c8..a9ebf66108a 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -108,11 +108,6 @@
108;; 108;;
109;; Blink, is not supported. Currently it's mapped as bold. 109;; Blink, is not supported. Currently it's mapped as bold.
110;; 110;;
111;; Important caveat:
112;; -----------------
113;; if you want custom colors in term.el redefine term-default-fg-color
114;; and term-default-bg-color BEFORE loading it.
115;;
116;; ---------------------------------------- 111;; ----------------------------------------
117;; 112;;
118;; If you'd like to check out my complete configuration, you can download 113;; If you'd like to check out my complete configuration, you can download
@@ -459,7 +454,7 @@ state 4: term-terminal-parameter contains pending output.")
459 "A queue of strings whose echo we want suppressed.") 454 "A queue of strings whose echo we want suppressed.")
460(defvar term-terminal-parameter) 455(defvar term-terminal-parameter)
461(defvar term-terminal-previous-parameter) 456(defvar term-terminal-previous-parameter)
462(defvar term-current-face 'default) 457(defvar term-current-face 'term-face)
463(defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region.") 458(defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region.")
464(defvar term-scroll-end) ; Number of line (zero-based) after scrolling region. 459(defvar term-scroll-end) ; Number of line (zero-based) after scrolling region.
465(defvar term-pager-count nil 460(defvar term-pager-count nil
@@ -795,28 +790,87 @@ Buffer local variable.")
795(defvar term-terminal-previous-parameter-3 -1) 790(defvar term-terminal-previous-parameter-3 -1)
796(defvar term-terminal-previous-parameter-4 -1) 791(defvar term-terminal-previous-parameter-4 -1)
797 792
798;;; faces -mm 793;;; Faces
799 794(defvar ansi-term-color-vector
800(defcustom term-default-fg-color 795 [term-face
801 ;; FIXME: This depends on the current frame, so depending on when 796 term-color-black
802 ;; it's loaded, the result may be different. 797 term-color-red
803 (face-foreground term-current-face) 798 term-color-green
804 "Default color for foreground in `term'." 799 term-color-yellow
800 term-color-blue
801 term-color-magenta
802 term-color-cyan
803 term-color-white])
804
805(defcustom term-default-fg-color nil
806 "If non-nil, default color for foreground in Term mode.
807This is deprecated in favor of customizing the `term-face' face."
805 :group 'term 808 :group 'term
806 :type 'string) 809 :type 'string)
807 810
808(defcustom term-default-bg-color 811(defcustom term-default-bg-color nil
809 ;; FIXME: This depends on the current frame, so depending on when 812 "If non-nil, default color for foreground in Term mode.
810 ;; it's loaded, the result may be different. 813This is deprecated in favor of customizing the `term-face' face."
811 (face-background term-current-face)
812 "Default color for background in `term'."
813 :group 'term 814 :group 'term
814 :type 'string) 815 :type 'string)
815 816
816;; Use the same colors that xterm uses, see `xterm-standard-colors'. 817(defface term-face
817(defvar ansi-term-color-vector 818 `((t
818 [unspecified "black" "red3" "green3" "yellow3" "blue2" 819 :foreground ,term-default-fg-color
819 "magenta3" "cyan3" "white"]) 820 :background ,term-default-bg-color
821 :inherit default))
822 "Default face to use in Term mode."
823 :group 'term)
824
825(defface term-bold
826 '((t :bold t))
827 "Default face to use for bold text."
828 :group 'term)
829
830(defface term-underline
831 '((t :underline t))
832 "Default face to use for underlined text."
833 :group 'term)
834
835(defface term-color-black
836 '((t :foreground "black" :background "black"))
837 "Face used to render black color code."
838 :group 'term)
839
840(defface term-color-red
841 '((t :foreground "red3" :background "red3"))
842 "Face used to render red color code."
843 :group 'term)
844
845(defface term-color-green
846 '((t :foreground "green3" :background "green3"))
847 "Face used to render green color code."
848 :group 'term)
849
850(defface term-color-yellow
851 '((t :foreground "yellow3" :background "yellow3"))
852 "Face used to render yellow color code."
853 :group 'term)
854
855(defface term-color-blue
856 '((t :foreground "blue2" :background "blue2"))
857 "Face used to render blue color code."
858 :group 'term)
859
860(defface term-color-magenta
861 '((t :foreground "magenta3" :background "magenta3"))
862 "Face used to render magenta color code."
863 :group 'term)
864
865(defface term-color-cyan
866 '((t :foreground "cyan3" :background "cyan3"))
867 "Face used to render cyan color code."
868 :group 'term)
869
870(defface term-color-white
871 '((t :foreground "white" :background "white"))
872 "Face used to render white color code."
873 :group 'term)
820 874
821;; Inspiration came from comint.el -mm 875;; Inspiration came from comint.el -mm
822(defcustom term-buffer-maximum-size 2048 876(defcustom term-buffer-maximum-size 2048
@@ -951,11 +1005,7 @@ is buffer-local."
951 dt)) 1005 dt))
952 1006
953(defun term-ansi-reset () 1007(defun term-ansi-reset ()
954 (setq term-current-face (nconc 1008 (setq term-current-face 'term-face)
955 (if term-default-bg-color
956 (list :background term-default-bg-color))
957 (if term-default-fg-color
958 (list :foreground term-default-fg-color))))
959 (setq term-ansi-current-underline nil) 1009 (setq term-ansi-current-underline nil)
960 (setq term-ansi-current-bold nil) 1010 (setq term-ansi-current-bold nil)
961 (setq term-ansi-current-reverse nil) 1011 (setq term-ansi-current-reverse nil)
@@ -3088,10 +3138,6 @@ See `term-prompt-regexp'."
3088;; New function to deal with ansi colorized output, as you can see you can 3138;; New function to deal with ansi colorized output, as you can see you can
3089;; have any bold/underline/fg/bg/reverse combination. -mm 3139;; have any bold/underline/fg/bg/reverse combination. -mm
3090 3140
3091(defvar term-bold-attribute '(:weight bold)
3092 "Attribute to use for the bold terminal attribute.
3093Set it to nil to disable bold.")
3094
3095(defun term-handle-colors-array (parameter) 3141(defun term-handle-colors-array (parameter)
3096 (cond 3142 (cond
3097 3143
@@ -3153,46 +3199,32 @@ Set it to nil to disable bold.")
3153 ;; term-ansi-current-color 3199 ;; term-ansi-current-color
3154 ;; term-ansi-current-bg-color) 3200 ;; term-ansi-current-bg-color)
3155 3201
3156
3157 (unless term-ansi-face-already-done 3202 (unless term-ansi-face-already-done
3158 (if term-ansi-current-invisible 3203 (if term-ansi-current-invisible
3159 (let ((color 3204 (let ((color
3160 (if term-ansi-current-reverse 3205 (if term-ansi-current-reverse
3161 (if (= term-ansi-current-color 0) 3206 (face-foreground
3162 term-default-fg-color 3207 (elt ansi-term-color-vector term-ansi-current-color))
3163 (elt ansi-term-color-vector term-ansi-current-color)) 3208 (face-background
3164 (if (= term-ansi-current-bg-color 0) 3209 (elt ansi-term-color-vector term-ansi-current-bg-color)))))
3165 term-default-bg-color
3166 (elt ansi-term-color-vector term-ansi-current-bg-color)))))
3167 (setq term-current-face 3210 (setq term-current-face
3168 (list :background color 3211 (list :background color
3169 :foreground color)) 3212 :foreground color))
3170 ) ;; No need to bother with anything else if it's invisible. 3213 ) ;; No need to bother with anything else if it's invisible.
3171
3172 (setq term-current-face 3214 (setq term-current-face
3173 (if term-ansi-current-reverse 3215 (list :foreground
3174 (if (= term-ansi-current-color 0) 3216 (face-foreground (elt ansi-term-color-vector term-ansi-current-color))
3175 (list :background term-default-fg-color 3217 :background
3176 :foreground term-default-bg-color) 3218 (face-background (elt ansi-term-color-vector term-ansi-current-bg-color))
3177 (list :background 3219 :inverse-video term-ansi-current-reverse))
3178 (elt ansi-term-color-vector term-ansi-current-color)
3179 :foreground
3180 (elt ansi-term-color-vector term-ansi-current-bg-color)))
3181
3182 (if (= term-ansi-current-color 0)
3183 (list :foreground term-default-fg-color
3184 :background term-default-bg-color)
3185 (list :foreground
3186 (elt ansi-term-color-vector term-ansi-current-color)
3187 :background
3188 (elt ansi-term-color-vector term-ansi-current-bg-color)))))
3189 3220
3190 (when term-ansi-current-bold 3221 (when term-ansi-current-bold
3191 (setq term-current-face 3222 (setq term-current-face
3192 (append term-bold-attribute term-current-face))) 3223 (list* term-current-face :inherit 'term-bold)))
3224
3193 (when term-ansi-current-underline 3225 (when term-ansi-current-underline
3194 (setq term-current-face 3226 (setq term-current-face
3195 (list* :underline t term-current-face))))) 3227 (list* term-current-face :inherit 'term-underline)))))
3196 3228
3197 ;; (message "Debug %S" term-current-face) 3229 ;; (message "Debug %S" term-current-face)
3198 ;; FIXME: shouldn't we set term-ansi-face-already-done to t here? --Stef 3230 ;; FIXME: shouldn't we set term-ansi-face-already-done to t here? --Stef