ses-modeでセルに色を付けてみる

emacs22からses-modeっていうスプレッドシートが追加された。便利そうなんだけど実は全然使ってないw
使わない理由はセルがはっきり判らないからな気がしたから色を付けてみた。

ついでに行番号も表示するとスプレッドシートっぽくていい感じ。行番号を表示するのには、http://stud4.tuwien.ac.at/~e0225855/linum/linum.htmlを使ってる。


これで使うようになるかも…しれない。もし使うようになったらまた記事書きます。

before

after


ソース

(defface ses-cell
  '((t (:underline "gray70")))
  "A face of cell."
  :group 'ses)

(defun ses-highlight-region (start end)
  (setq start (or (previous-single-property-change start 'intangible)
                  (point-min)))
  (setq end (or (next-single-property-change end 'intangible)
                (point-max)))
  (save-restriction
    (narrow-to-region start end)
    (goto-char (point-min))
    (let (pos)
      (while (setq pos (next-single-property-change (point) 'intangible))
        (put-text-property (point) (1- pos) 'face 'ses-cell)
        (goto-char pos)))))

(defun ses-register-highlight ()
  (jit-lock-register 'ses-highlight-region))

(add-hook 'ses-mode-hook 'ses-register-highlight)
(add-hook 'ses-mode-hook 'linum-mode)