From c28e9a7b1ff888a5c27eff97245a6e96301f5512 Mon Sep 17 00:00:00 2001 From: Ambrevar Date: Tue, 17 Jul 2012 17:32:15 +0100 Subject: [PATCH] Emacs: colors improvements (digits, hex). Shell: highlight theme viewer. Xresources: fixes. --- .Xresources | 33 ++++------ .config/ranger/options.py | 2 +- .config/ranger/scope.sh | 2 + .emacs | 124 +++++++++++++++++++++++++++++--------- .shell.d/funs_rc | 47 +++++++++++++++ README | 12 +++- 6 files changed, 169 insertions(+), 51 deletions(-) diff --git a/.Xresources b/.Xresources index ba448fd9..f64bb74f 100644 --- a/.Xresources +++ b/.Xresources @@ -3,7 +3,8 @@ !! 2012-07-12 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! TODO: what is charclass ? +!! TODO: set up charclass. +!! TODO: check Xft options. !! TODO: prevent URxvt from intercepting ALT+Arrows and PageUp/Down. !! Xft options @@ -17,12 +18,12 @@ !!------------------------------------------------------------------------------ ! URxvt*modifier: alt -URxvt*saveLines: 1000 +URxvt*saveLines: 5000 URxvt*scrollBar: false !! Plugins !! clipboard and keyboard-select are not provided by default. -URxvt.perl-ext-common : default,matcher,keyboard-select,clipboard +URxvt.perl-ext-common : default,matcher,keyboard-select ! URxvt.keysym.M-v: perl:clipboard:paste ! URxvt.keysym.M-C-v: perl:clipboard:paste_escaped @@ -38,10 +39,9 @@ URxvt.keysym.M-Delete : perl:matcher:list URxvt.urlLauncher : luakit URxvt.underlineURLs : true - +!! TODO: Does not work. URxvt*keysym.M-Left: \033[1;3D - !! Font ! URxvt*letterSpace: -1 @@ -118,29 +118,20 @@ URxvt.color15 : #FFFFFF !! Tangoesque style !*background: #111111 -!*background: #000000 !*foreground: #babdb6 -!! Black (not tango) + DarkGrey ! *color0: #000000 -! *color8: #555753 -!! DarkRed + Red ! *color1: #ff6565 -! *color9: #ff8d8d -!! DarkGreen + Green ! *color2: #93d44f -! *color10: #c8e7a8 -!! DarkYellow + Yellow ! *color3: #eab93d -! *color11: #ffc123 -!! DarkBlue + Blue ! *color4: #204a87 -! *color12: #3465a4 -!! DarkMangenta + Mangenta ! *color5: #ce5c00 -! *color13: #f57900 -!! DarkCyan + Cyan (both not tango) ! *color6: #89b6e2 -! *color14: #46a4ff -!! LightGrey + White ! *color7: #cccccc +! *color8: #555753 +! *color9: #ff8d8d +! *color10: #c8e7a8 +! *color11: #ffc123 +! *color12: #3465a4 +! *color13: #f57900 +! *color14: #46a4ff ! *color15: #ffffff diff --git a/.config/ranger/options.py b/.config/ranger/options.py index a5e8c2cb..68a6bbda 100644 --- a/.config/ranger/options.py +++ b/.config/ranger/options.py @@ -19,7 +19,7 @@ # Which colorscheme to use? These colorschemes are available by default: # default, default88, jungle, snow # Snow is monochrome and default88 uses 88 colors. -# colorscheme = 'jungle' +# colorscheme = 'default' # Display the directory name in tabs? dirname_in_tabs = True diff --git a/.config/ranger/scope.sh b/.config/ranger/scope.sh index 616f4164..f7ffae1f 100755 --- a/.config/ranger/scope.sh +++ b/.config/ranger/scope.sh @@ -72,6 +72,8 @@ case "$mimetype" in # Syntax highlight for text files: text/* | */xml) highlight --out-format=ansi "$path" | head -n $maxln + # FIXME: does not work! + # highlight --out-format=xterm256 -s zmrok "$path" | head -n $maxln success && exit 5 || exit 2;; # Ascii-previews of images: image/*) diff --git a/.emacs b/.emacs index ac3d1ce2..1e55e65a 100644 --- a/.emacs +++ b/.emacs @@ -19,8 +19,9 @@ ;; Line numbers (autoload 'linum-mode "linum" "toggle line numbers on/off" t) (global-set-key (kbd "C-") 'linum-mode) +;; (setq linum-format "%-4d ") (setq linum-format "%d ") -(global-linum-mode 1) ; This may generate warnings. Bug? +(global-linum-mode 1) ;; FIXME: This may generate warnings. Bug? ;; Indentation ;(setq standard-indent 4) ;; Set standard indent to 2 rather that 4 @@ -84,26 +85,78 @@ ;; Theme ;;============================================================================== -(set-face-foreground 'font-lock-builtin-face "red" ) -(set-face-foreground 'font-lock-comment-delimiter-face "color-240" ) -(set-face-foreground 'font-lock-comment-face "color-240" ) -(set-face-foreground 'font-lock-constant-face "magenta" ) -(set-face-foreground 'font-lock-doc-face "brightgreen" ) -(set-face-foreground 'font-lock-function-name-face "brightcyan" ) -(set-face-bold-p 'font-lock-function-name-face t ) -(set-face-foreground 'font-lock-keyword-face "brightred" ) -(set-face-foreground 'font-lock-preprocessor-face "green" ) -(set-face-foreground 'font-lock-string-face "color-39" ) -(set-face-foreground 'font-lock-type-face "color-166" ) -(set-face-foreground 'font-lock-variable-name-face "brightyellow" ) +(set-face-foreground 'font-lock-builtin-face "brightmagenta" ) +(set-face-bold-p 'font-lock-builtin-face t ) +(set-face-foreground 'font-lock-comment-delimiter-face "color-242" ) +(set-face-foreground 'font-lock-comment-face "color-242" ) +(set-face-foreground 'font-lock-constant-face "color-105" ) +(set-face-foreground 'font-lock-doc-face "color-28" ) +;; (set-face-underline-p 'font-lock-doc-face t ) +(set-face-foreground 'font-lock-function-name-face "brightcyan" ) +(set-face-bold-p 'font-lock-function-name-face t ) +(set-face-foreground 'font-lock-keyword-face "brightred" ) +(set-face-bold-p 'font-lock-keyword-face t ) +(set-face-foreground 'font-lock-preprocessor-face "color-99" ) +(set-face-foreground 'font-lock-string-face "color-39" ) +(set-face-foreground 'font-lock-type-face "color-166" ) +(set-face-foreground 'font-lock-variable-name-face "brightyellow" ) +(set-face-foreground 'font-lock-warning-face "DarkOrange" ) -(set-face-foreground 'link "brightblue" ) -(set-face-underline-p 'link t) -(set-face-foreground 'minibuffer-prompt "cyan" ) -(set-face-background 'region "color-17") -(set-face-foreground 'error "red") -(set-face-bold-p 'error t) +;; General +(set-face-foreground 'link "brightblue" ) +(set-face-underline-p 'link t) +(set-face-foreground 'minibuffer-prompt "brightcyan" ) +(set-face-background 'region "color-17") +(set-face-foreground 'error "red") +(set-face-bold-p 'error t) +(set-face-background 'shadow "color-234" ) ;; For line numbers. + +;; FIXME: fix C functions color. +(font-lock-add-keywords + 'c-mode + '( + ("&" . font-lock-keyword-face) + ("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face) + )) + +(mapcar + (lambda (mode) + (font-lock-add-keywords + mode + '( + ("[^[:digit:][:space:]][[:space:]]*\\(-\\)[[:digit:]]+" 1 font-lock-constant-face) + ("\\(0x[[:digit:]a-fA-F]+\\)[^[:alnum:]_]" 1 font-lock-constant-face) + ("\\([[:digit:]]+\\)[^[:alnum:]_]" 1 font-lock-constant-face) + ("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend) + ("\\<\\(TODO\\):" 1 font-lock-warning-face prepend) + ))) + '( text-mode mail-mode + sh-mode emacs-lisp-mode lua-mode + c-mode + latex-mode html-mode texinfo-mode)) + +;; C-mode printf highlight. +(defvar font-lock-format-specifier-face 'font-lock-format-specifier-face + "Face name to use for format specifiers.") + +(defface font-lock-format-specifier-face + '((t (:foreground "OrangeRed1"))) + "Font Lock mode face used to highlight format specifiers." + :group 'font-lock-faces) + +;; FIXME: disable highlighting outside of string. +(add-hook + 'c-mode-common-hook + (lambda () + (font-lock-add-keywords + nil + '(("[^%]\\(%\\([[:digit:]]+\\$\\)?[-+' #0*]*\\([[:digit:]]*\\|\\*\\|\\*[[:digit:]]+\\$\\)\\(\\.\\([[:digit:]]*\\|\\*\\|\\*[[:digit:]]+\\$\\)\\)?\\([hlLjzt]\\|ll\\|hh\\)?\\([aAbdiuoxXDOUfFeEgGcCsSpn]\\|\\[\\^?.[^]]*\\]\\)\\)" + 1 font-lock-format-specifier-face t) + ("\\(%%\\)" + 1 font-lock-format-specifier-face t)) ))) + +;; FIXME: Does not work. ;; (set-face-foreground 'compilation-column-number "magenta") ;; (set-face-background 'lazy-highlight "brightgreen" ) @@ -113,7 +166,6 @@ ;; (set-face-foreground 'warning "DarkOrange") ;; (set-face-bold-p 'warning t) ;; (set-face-foreground 'nobreak-space "cyan") -;; (set-face-foreground 'shadow "grey70" ) ;; For line numbers. ;; (set-face-foreground 'success "Green1") ;; (set-face-bold-p 'success t) @@ -168,6 +220,14 @@ auto-mode-alist) ) +;; README +(setq auto-mode-alist + (append + '(("README" . text-mode) + ) + auto-mode-alist) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -254,19 +314,20 @@ ;; Original idea from ;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html (defun comment-dwim-line (&optional arg) - "Replacement for the comment-dwim command. - If no region is selected and current line is not blank and we are not at the end of the line, - then comment current line. - Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line." + "Replacement for the comment-dwim command. If no region is +selected and current line is not blank and we are not at the end +of the line, then comment current line. Replaces default +behaviour of comment-dwim, when it inserts comment at the end of +the line." (interactive "*P") (comment-normalize-vars) - (if (and (not (region-active-p)) (not (looking-at "[ \t]*$"))) + ;; (if (and (not (region-active-p)) (not (looking-at "[ \t]*$"))) + (if (and (not (region-active-p)) ) (comment-or-uncomment-region (line-beginning-position) (line-end-position)) (comment-dwim arg))) + (global-set-key "\M-;" 'comment-dwim-line) - - ;;============================================================================== ;; My Keys Minor-Mode ;;============================================================================== @@ -455,6 +516,14 @@ (add-hook 'TeX-mode-hook 'my-tex-mode-hook) +;; Theme +(defun my-tex-font-hook () + (set-face-foreground 'font-latex-sedate-face "brightred" ) + (set-face-bold-p 'font-latex-sedate-face t) +) +(add-hook 'TeX-mode-hook 'my-tex-font-hook) + + ;;============================================================================== ;; Lua ;;============================================================================== @@ -487,3 +556,4 @@ ;;============================================================================== ;;============================================================================== +;; diff --git a/.shell.d/funs_rc b/.shell.d/funs_rc index 7db2fa07..c8b1c338 100644 --- a/.shell.d/funs_rc +++ b/.shell.d/funs_rc @@ -232,6 +232,53 @@ man() man "$@" } +## Highlight themes viewer for 256-colors terminals. +hlt-viewer () +{ + print_help() + { + echo "Synopsis:" + echo -e " $1" + echo + echo "This script displays a preview for every highlight's theme." + echo "Press ENTER to display next preview. Press anything else then ENTER to quit." + } + + if [ ! -f "/usr/bin/highlight" ];then + echo "Please install 'highlight'." + return + fi + + if [ $# -gt 0 ]; then + print_help "$0" + return + fi + + + LIST=$(highlight -w | grep -v "\s\|^$") + SAMPLE="void function(char* pointer, int &ref) +{ + int integer=3; + char* string=\"Hello!\"; + + // Line comment + for ( i=0; i<10; i++) + { + printf(\"Sum: %d\\\n\", i*( integer+14 ) ); + } +}" + + unset DUMMY + for i in $(highlight -w | grep -v "\s\|^$"); do + echo "******************** $i ********************" + highlight -S c -O xterm256 <(echo $SAMPLE) -s "$i" + read -s DUMMY + if [ ! "$DUMMY" = "" ];then + return + fi + done +} + ## Extractor -- Useless when using 'atool'. if [ ! -e "/usr/bin/atool" ]; then extract () { diff --git a/README b/README index 2c60aadb..0535676b 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ ################################################################################ # Unix Home Configuration # # Author: Ambrevar # -# Date: 2012-07-05 # +# Date: 2012-07-17 # ################################################################################ Synopsis @@ -57,7 +57,9 @@ Emacs ***** Extra deps: auctex, auto-complete, emacs-lua-mode, emacs-yasnippet, -Not much personal work, mostly use of plugins. Still very powerful. +Some keybindings and custom colors. (I find it more convenient on a 256-colors +terminal.) Some customization -- columns, kill whole line, etc. Some plugins +customization too. Luakit ****** @@ -84,6 +86,8 @@ custom theme, various tweaks. Ranger ****** +Extra deps: antiword, atool, highlight, img2txt, mediainfo, pdftotext, w3m. + Custom bindings, file association, tweaked a few options. Scripts @@ -106,6 +110,10 @@ folder .shell.d/, whose files get sourced by both bash and zsh. Bash-specific and zsh-specific options are in dedicated files ending with the apropriate shell name. +URxvt +***** +Custom font and colors, no scroll bar, url-matcher and keyboard-select. + Vim *** I've only been a casual Vim user, so do not expect too much from it.