colors

Fri, 03 Jun 2016 23:44:44 +0200

> Certain keywords display with an unreadable
> dark blue, on a black background. Like:
> getopts or echo or source, with emacs mode
> Shell-script[bash]. Other things are too dark
> in sql-mode: SQL[ansi]
>
> Is it best to change the dark blue in PuTTY
> settings or in emacs?

Both!

Start by setting up the terminal colors.

It is a good help to have a test function to
output all colors.

For example the below zsh. Here is a dump what
it shows for me:

    http://user.it.uu.se/~embe8573/figures/shell/test-colors.png

Then get the colors right. I don't know how to
do that for PuTTY - for the Linux VTs and
X (e.g., xterm) tho there are some material
here:

    http://user.it.uu.se/~embe8573/cols/www/index.html
    http://user.it.uu.se/~embe8573/cols/www/COLORS
    http://user.it.uu.se/~embe8573/scripts/cols

After you have done this, nine out of ten
colors in Emacs should look good. If you see
one that doesn't, place point at it and use
this function to find out what face it is:

    (defun what-face (pos)
      (interactive "d")
      (let((face (or (get-char-property pos 'face)
                     (get-char-property pos 'read-cf-name) )))
        (message " Face: %s" (or face "(no face!)")) ))

Then re-assign the face some other color which
is better in that context.

Oh, the zsh - change into bash if needed:

set-fg-color () { tput setaf $1 } # color ($1) is 0-7
set-bg-color () { tput setab $1 }
set-bold     () { tput bold }
reset-color  () { tput sgr0 }

test-colors () {
    local color_number
    local color

    local -a color_names
    color_names=(black red green yellow blue magenta cyan white)

    echo
    for color_number in {0..7}; do
        echo -n "   $color_number   "
        set-fg-color $color_number
        color=$color_names[(( $color_number + 1 ))]
        echo -n $color "	"; tput bold; echo $color
        reset-color
    done
    echo
}

From the file: http://user.it.uu.se/~embe8573/conf/.zsh/vt

Good luck!

Back to Blogomatic.