From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.devel Subject: Re: Inclusion of naquadah-theme Date: Tue, 26 Jun 2012 12:48:16 +0200 Message-ID: <87k3yujqmn.fsf@zelenka.enovance.com> References: <87pq8nk8cj.fsf@zelenka.enovance.com> <87bok7zekq.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1340707716 18578 80.91.229.3 (26 Jun 2012 10:48:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jun 2012 10:48:36 +0000 (UTC) Cc: emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 26 12:48:35 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SjTJy-0007jJ-CW for ged-emacs-devel@m.gmane.org; Tue, 26 Jun 2012 12:48:34 +0200 Original-Received: from localhost ([::1]:39281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjTJy-0002oO-7x for ged-emacs-devel@m.gmane.org; Tue, 26 Jun 2012 06:48:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjTJt-0002o2-Q0 for emacs-devel@gnu.org; Tue, 26 Jun 2012 06:48:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SjTJr-0004d9-81 for emacs-devel@gnu.org; Tue, 26 Jun 2012 06:48:29 -0400 Original-Received: from prometheus.naquadah.org ([212.85.154.174]:43821 helo=mx1.naquadah.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjTJk-0004bB-Dh; Tue, 26 Jun 2012 06:48:20 -0400 Original-Received: from zelenka.enovance.com (unknown [83.167.43.235]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.naquadah.org (Postfix) with ESMTPSA id 4EF175C135; Tue, 26 Jun 2012 12:48:17 +0200 (CEST) Mail-Followup-To: Chong Yidong , emacs-devel@gnu.org User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.85.154.174 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151177 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain On Mon, Jun 25 2012, Chong Yidong wrote: > Please have a better description in the first line than "A color theme", > since this serves as the accompanying text in the M-x customize-themes > buffer. Likewise the docstring to deftheme, which is shown with the > describe-theme command. Sure, I fixed this two. But it's kinda hard to describe a theme actually. :) > Do not set ansi-term-color-vector directly with setq. If you find the > need to customize it, please fix it right: submit a patch to term.el > that converts this to a defcustom, then use custom-theme-set-variables. What do you think of the following patch? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-term-use-faces-for-color-handling.patch Content-Transfer-Encoding: quoted-printable From=2015acb6ecb90cca322109344521379d843ce53c15 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 26 Jun 2012 12:39:41 +0200 Subject: [PATCH] term: use faces for color handling Signed-off-by: Julien Danjou =2D-- lisp/ChangeLog | 5 +++ lisp/term.el | 135 +++++++++++++++++++++++++++++++---------------------= ---- 2 files changed, 81 insertions(+), 59 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 69fee94..9680fb3 100644 =2D-- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-06-26 Julien Danjou + + * term.el (term-handle-colors-array): Use a set of new faces to + color the terminal. Also uses :inverse-video property. + 2012-06-26 Martin Rudalics =20 * calendar/calendar.el (calendar-exit): Don't try to delete or diff --git a/lisp/term.el b/lisp/term.el index 7461d74..d11fd57 100644 =2D-- a/lisp/term.el +++ b/lisp/term.el @@ -108,11 +108,6 @@ ;; ;; Blink, is not supported. Currently it's mapped as bold. ;; =2D;; Important caveat: =2D;; ----------------- =2D;; if you want custom colors in term.el redefine term-default-fg-color =2D;; and term-default-bg-color BEFORE loading it. =2D;; ;; ---------------------------------------- ;; ;; If you'd like to check out my complete configuration, you can download @@ -459,7 +454,7 @@ state 4: term-terminal-parameter contains pending outpu= t.") "A queue of strings whose echo we want suppressed.") (defvar term-terminal-parameter) (defvar term-terminal-previous-parameter) =2D(defvar term-current-face 'default) +(defvar term-current-face 'term-face) (defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region= .") (defvar term-scroll-end) ; Number of line (zero-based) after scrolling reg= ion. (defvar term-pager-count nil @@ -796,27 +791,71 @@ Buffer local variable.") (defvar term-terminal-previous-parameter-4 -1) =20 ;;; faces -mm +(defvar ansi-term-color-vector + [term-face + term-color-black + term-color-red + term-color-green + term-color-yellow + term-color-blue + term-color-magenta + term-color-cyan + term-color-white]) + +(defface term-face + '((t :inherit default)) + "Default face to use in term." + :group 'term) =20 =2D(defcustom term-default-fg-color =2D ;; FIXME: This depends on the current frame, so depending on when =2D ;; it's loaded, the result may be different. =2D (face-foreground term-current-face) =2D "Default color for foreground in `term'." =2D :group 'term =2D :type 'string) +(defface term-bold + '((t :bold t)) + "Default face to use for bold text." + :group 'term) =20 =2D(defcustom term-default-bg-color =2D ;; FIXME: This depends on the current frame, so depending on when =2D ;; it's loaded, the result may be different. =2D (face-background term-current-face) =2D "Default color for background in `term'." =2D :group 'term =2D :type 'string) +(defface term-underline + '((t :underline t)) + "Default face to use for underlined text." + :group 'term) =20 =2D;; Use the same colors that xterm uses, see `xterm-standard-colors'. =2D(defvar ansi-term-color-vector =2D [unspecified "black" "red3" "green3" "yellow3" "blue2" =2D "magenta3" "cyan3" "white"]) +(defface term-color-black + '((t :foreground "black" :background "black")) + "Face used to render black color code." + :group 'term) + +(defface term-color-red + '((t :foreground "red3" :background "red3")) + "Face used to render red color code." + :group 'term) + +(defface term-color-green + '((t :foreground "green3" :background "green3")) + "Face used to render green color code." + :group 'term) + +(defface term-color-yellow + '((t :foreground "yellow3" :background "yellow3")) + "Face used to render yellow color code." + :group 'term) + +(defface term-color-blue + '((t :foreground "blue2" :background "blue2")) + "Face used to render blue color code." + :group 'term) + +(defface term-color-magenta + '((t :foreground "magenta3" :background "magenta3")) + "Face used to render magenta color code." + :group 'term) + +(defface term-color-cyan + '((t :foreground "cyan3" :background "cyan3")) + "Face used to render cyan color code." + :group 'term) + +(defface term-color-white + '((t :foreground "white" :background "white")) + "Face used to render white color code." + :group 'term) =20 ;; Inspiration came from comint.el -mm (defcustom term-buffer-maximum-size 2048 @@ -951,11 +990,7 @@ is buffer-local." dt)) =20 (defun term-ansi-reset () =2D (setq term-current-face (nconc =2D (if term-default-bg-color =2D (list :background term-default-bg-color)) =2D (if term-default-fg-color =2D (list :foreground term-default-fg-color))= )) + (setq term-current-face 'term-face) (setq term-ansi-current-underline nil) (setq term-ansi-current-bold nil) (setq term-ansi-current-reverse nil) @@ -3088,10 +3123,6 @@ See `term-prompt-regexp'." ;; New function to deal with ansi colorized output, as you can see you can ;; have any bold/underline/fg/bg/reverse combination. -mm =20 =2D(defvar term-bold-attribute '(:weight bold) =2D "Attribute to use for the bold terminal attribute. =2DSet it to nil to disable bold.") =2D (defun term-handle-colors-array (parameter) (cond =20 @@ -3153,46 +3184,32 @@ Set it to nil to disable bold.") ;; term-ansi-current-color ;; term-ansi-current-bg-color) =20 =2D (unless term-ansi-face-already-done (if term-ansi-current-invisible (let ((color (if term-ansi-current-reverse =2D (if (=3D term-ansi-current-color 0) =2D term-default-fg-color =2D (elt ansi-term-color-vector term-ansi-current-color= )) =2D (if (=3D term-ansi-current-bg-color 0) =2D term-default-bg-color =2D (elt ansi-term-color-vector term-ansi-current-bg-colo= r))))) + (face-foreground + (elt ansi-term-color-vector term-ansi-current-color)) + (face-background + (elt ansi-term-color-vector term-ansi-current-bg-color))= ))) (setq term-current-face (list :background color :foreground color)) ) ;; No need to bother with anything else if it's invisible. =2D (setq term-current-face =2D (if term-ansi-current-reverse =2D (if (=3D term-ansi-current-color 0) =2D (list :background term-default-fg-color =2D :foreground term-default-bg-color) =2D (list :background =2D (elt ansi-term-color-vector term-ansi-current-co= lor) =2D :foreground =2D (elt ansi-term-color-vector term-ansi-current-bg= -color))) =2D =2D (if (=3D term-ansi-current-color 0) =2D (list :foreground term-default-fg-color =2D :background term-default-bg-color) =2D (list :foreground =2D (elt ansi-term-color-vector term-ansi-current-colo= r) =2D :background =2D (elt ansi-term-color-vector term-ansi-current-bg-c= olor))))) + (list :foreground + (face-foreground (elt ansi-term-color-vector term-ansi-c= urrent-color)) + :background + (face-background (elt ansi-term-color-vector term-ansi-c= urrent-bg-color)) + :inverse-video term-ansi-current-reverse)) =20 (when term-ansi-current-bold (setq term-current-face =2D (append term-bold-attribute term-current-face))) + (list* term-current-face :inherit 'term-bold))) + (when term-ansi-current-underline (setq term-current-face =2D (list* :underline t term-current-face))))) + (list* term-current-face :inherit 'term-underline))))) =20 ;; (message "Debug %S" term-current-face) ;; FIXME: shouldn't we set term-ansi-face-already-done to t here? --Stef =2D-=20 1.7.10 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > Having defuns in a theme file is obnoxious. Could you explain what > these functions are needed for? If there is missing functionality, we > should incorporate that directly into Emacs; they should not be > naquadah-specific. It's a system we built to define faces with symbols and then expand into a real color value, depending on the terminal capability. This allows to define a face once with generic color and expand it: (naquadah-simple-face-to-multiple '(default (:background background :foreground aluminium-1)))) =3D> (default ((((class color) (min-colors 65535)) (:background "#252A2B" :foreground "#eeeeec")) (((class color) (min-colors 256)) (:background "color-234" :foreground "color-255")) (((class color) (min-colors 88)) (:background "color-80" :foreground "color-87")) (t (:background "black" :foreground "white")))) This way we just have to define the color "aluminium-1" to be a different color depending on the numbre of color available, and then define the font. The rest is expanded by this function. =2D-=20 Julien --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJP6ZNwAAoJEGEbqVCLeKXCuzcP/3w5nd1T/07/tP+EI97gfx5S A6hKPab64EA8XreyxJfki0yUD3v7XpD2AjMqT+o8ecU2oKG8tSjMAU64S1OgTkGv Po+ygHQVM3AyNUZsryPj8cgbi7oaBAvThI82m5JseoOV0+Vhpbf54dVW8ncdvhkm BI/YALDr8ZUVPKSjsG1PQYV6mkLTo9buAFAay+EKfyCvAGxcdkGI1tKozpcdZovd IZ/IQbU5jCnTx4l2sjoYiK+81qFfEkyloPo8G9YABMsIDJCgYqXHUFid3yVgKLOi bUsN/NVKxh/bnJr8iKINPdPn8rAsE5YevUV694rVL8nJdgdMhrk6mDFc9Qrevnjt RsgB9GeeWB290vVclIXTIm77O+OXU2m+M/tdYVgFU6uoCqmHDg2aB7MJs5SAbYaZ nTw82sDGS4vaIL+CbKbXGIeppajW6iM6uHwwCZktE6wEp4z6ZS5PuT9g7rgrTnAD dMYcvUMTxWfxytGgEUCqiK12ZKa2Eta1AGENM53QSVl7VAmVMBXszoJ1rBk+Kxsn ro69clcakj4R80GtUWnyvYFmkxBFKY8cjpCX51NTUdvhfPpjygguw/LSGBXGadvk fJ5Gs1P9KJK0YI8oGbrmDkIubbF/2ZzWbfo4SRH8m1U0VzGE+UrglzK1OYjrWXNn KMTnfdqqWAbC0mOdGX2C =hMqo -----END PGP SIGNATURE----- --==-=-=--