Browse Source

fix bug of modeline color

pull/1/head
10sr 12 years ago
parent
commit
fe9b57975d
1 changed files with 46 additions and 46 deletions
  1. +46
    -46
      emacs.el

+ 46
- 46
emacs.el View File

@@ -98,52 +98,6 @@
(setq mac-option-modifier 'control) (setq mac-option-modifier 'control)
(setq w32-apps-modifier 'meta) (setq w32-apps-modifier 'meta)


;; http://www.emacswiki.org/emacs/ChangingCursorDynamically
;; why saving buffer?
;; Change cursor color according to mode
(defvar hcz-set-cursor-color-color "")
(defvar hcz-set-cursor-color-buffer "")
(defun hcz-set-cursor-color-according-to-mode ()
"change cursor color according to some minor modes."
;; set-cursor-color is somewhat costly, so we only call it when needed:
(let ((color
(if buffer-read-only "blue"
(if overwrite-mode "yellow"
"black"))))
(unless (and
(string= color hcz-set-cursor-color-color)
(string= (buffer-name) hcz-set-cursor-color-buffer))
(set-cursor-color (setq hcz-set-cursor-color-color color))
(setq hcz-set-cursor-color-buffer (buffer-name)))))
(and window-system
(add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode))

(defun my-set-mode-line-color-read-only ()
""
(let ((state (if buffer-read-only
'readonly
(if overwrite-mode
'overwrite
'insert))))
(unless (eq state my-set-mode-line-color-state)
(set-face-foreground 'modeline
(nth 1
(assq state
my-set-mode-line-color-color)))
(set-face-background 'modeline
(nth 2
(assq state
my-set-mode-line-color-color)))
(setq my-set-mode-line-color-state state))))
(defvar my-set-mode-line-color-color nil "")
(setq my-set-mode-line-color-color
'((readonly "blue" "white")
(overwrite "red" "white")
(insert nil nil)))
(defvar my-set-mode-line-color-state nil "")
(add-hook 'post-command-hook 'my-set-mode-line-color-read-only)
(add-hook 'after-init-hook 'my-set-mode-line-color-read-only)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mode-line ;; mode-line


@@ -344,6 +298,52 @@
;; (my-set-ascii-and-jp-font-with-size '("ProggyCleanTTSZ" 120 "takaogothic" 11)) ;; (my-set-ascii-and-jp-font-with-size '("ProggyCleanTTSZ" 120 "takaogothic" 11))
;; あ a ;; あ a


;; http://www.emacswiki.org/emacs/ChangingCursorDynamically
;; why saving buffer?
;; Change cursor color according to mode
(defvar hcz-set-cursor-color-color "")
(defvar hcz-set-cursor-color-buffer "")
(defun hcz-set-cursor-color-according-to-mode ()
"change cursor color according to some minor modes."
;; set-cursor-color is somewhat costly, so we only call it when needed:
(let ((color
(if buffer-read-only "blue"
(if overwrite-mode "yellow"
"black"))))
(unless (and
(string= color hcz-set-cursor-color-color)
(string= (buffer-name) hcz-set-cursor-color-buffer))
(set-cursor-color (setq hcz-set-cursor-color-color color))
(setq hcz-set-cursor-color-buffer (buffer-name)))))
(and window-system
(add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode))

(defun my-set-mode-line-color-read-only ()
""
(let ((state (if buffer-read-only
'readonly
(if overwrite-mode
'overwrite
'insert))))
(unless (eq state my-set-mode-line-color-state)
(set-face-foreground 'modeline
(nth 1
(assq state
my-set-mode-line-color-color)))
(set-face-background 'modeline
(nth 2
(assq state
my-set-mode-line-color-color)))
(setq my-set-mode-line-color-state state))))
(defvar my-set-mode-line-color-color nil "")
(setq my-set-mode-line-color-color
`((readonly "blue" "white")
(overwrite "red" "white")
(insert ,(face-foreground 'modeline) ,(face-background 'modeline))))
(defvar my-set-mode-line-color-state nil "")
(add-hook 'post-command-hook 'my-set-mode-line-color-read-only)
(add-hook 'after-init-hook 'my-set-mode-line-color-read-only)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; file handling ;; file handling




Loading…
Cancel
Save