more emacs

未だにChromebook Flip C100PAの環境整備中。前回から便利になった点は

  • croshclipを使ってcrouton上のEmacs(tty)からChrome OS上のChromeにリンクを飛ばせるようになった。以前はコピペしてたので、すごく便利になった。
  • terminal上のEmacsだとdark系のcolor themeの色がおかしくなることがあり、今までfont-lock-mode-hookで無理やり変えていたけど、解決方法(というかworkaround)が見つかった。どうもtty-color-approximateが暗いRGB値に対して変な色を返しているぽかったので、該当部分をコメントアウトして解決(多分。実はよく見ていない)。以下のpatchあてバージョンをinitファイルに入れた。
;; Workaround to make atom-one-dark theme work on tty
(defun tty-color-approximate (rgb &optional frame)
  "Find the color in `tty-color-alist' that best approximates RGB.
Value is a list of the form (NAME INDEX R G B).
The argument RGB should be an rgb value, that is, a list of three
integers in the 0..65535 range.
FRAME defaults to the selected frame."
  (let* ((color-list (tty-color-alist frame))
         (candidate (car color-list))
         (best-distance 195076) ;; 3 * 255^2 + 15
         (r (ash (car rgb) -8))
         (g (ash (cadr rgb) -8))
         (b (ash (nth 2 rgb) -8))
    (while candidate
      (let ((try-rgb (cddr candidate))
            ;; If the approximated color is not close enough to the
            ;; gray diagonal of the RGB cube, favor non-gray colors.
            ;; (The number 0.065 is an empirical ad-hoc'ery.)
            (favor-non-gray (>= (tty-color-off-gray-diag r g b) 0.065))
            try-r try-g try-b
            dif-r dif-g dif-b dist)
        ;; If the RGB values of the candidate color are unknown, we
        ;; never consider it for approximating another color.
        (if try-rgb
              (setq try-r (lsh (car try-rgb) -8)
                    try-g (lsh (cadr try-rgb) -8)
                    try-b (lsh (nth 2 try-rgb) -8))
              (setq dif-r (- r try-r)
                    dif-g (- g try-g)
                    dif-b (- b try-b))
              (setq dist (+ (* dif-r dif-r) (* dif-g dif-g) (* dif-b dif-b)))
              (if (and (< dist best-distance)
                       ;; Comment out to make some dark themes look better
                       ;; ;; The candidate color is on the gray diagonal
                       ;; if its RGB components are all equal.
                       ;; (or (/= try-r try-g) (/= try-g try-b)
                       ;;     (not favor-non-gray)))
                  (setq best-distance dist
                        best-color candidate)))))
      (setq color-list (cdr color-list))
      (setq candidate (car color-list)))
more emacs

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s