ㅈㅅㄹ

잠깐 powerline같은 걸로 갈아타 보기도 했으나 이쁘기만 하지 실속은 그다지 없어서 기본 mode-line을 써 왔다. 그러나 nyan-mode를 쓰다 보면 아무래도 필요 공간이 많아지는데, 별 쓸 데 없는 마이너 모드 리스트가 쌓이다 보면 정작 필요한 게 안보이는 사태가 발생하더라. 그래서 아예 내 입맞에 맞도록 싹 뜯어 보기로 했다.


일단 버퍼가 read-only인지는 확실하게 구분이 가능해야 한다. 오죽하면 기본 mode-line 쓸 때도 아예 my:read-only-mode라는 마이너 모드를 만들어 놓고 lighter도 씨뻘건 색으로 달아 놓도록 해 놨겠느냐 말이지. 이번에도 비슷하게 구별이 가능하도록 read-only일 경우 버퍼 이름의 배경색을 빨갛게 만들어 두었다. 사실 모르는 사람이 보면 이게 뭔가 하겠지만, 어차피 나만 잘 알아먹으면 됐지.


뭐 그 외에 내 경우 Emacs에서 System IME를 사용하지 않고 자체 IME를 사용하니까, 현재 버퍼의 IME 모드도 표시될 필요가 있고.... nyan-mode(!!!)와 vc-mode는 포기할 수 없는 것들 이다. 그래서 나름 간단하게 구성해 본 mode-line은 아래와 같다:


그리고 mode-line-format은 다음과 같다:

;; my custom mode-line (inspired from emacs-fu)
(defface my:mode-line-readonly-buffer-id
  '((t :inherit mode-line-buffer-id :background "red" :foreground "yellow"))
  "Used for highlight readonly buffer")

(setq-default
 mode-line-format
 (list
  " %I "        ; buffer size
  ;; modified
  '(:eval (propertize (if (buffer-modified-p) "* " "  ")
                      'face 'compilation-mode-line-fail))
  ;; relative position, size of file

  ;; buffer name
  '(:eval (propertize " %20b "
                      'face (if buffer-read-only
                                'my:mode-line-readonly-buffer-id
                              'mode-line-buffer-id)
                      'help-echo (buffer-file-name)))

  " "
  ;; line/column
  (propertize "%02l" 'face 'font-lock-type-face)
  ":"
  (propertize "%02c" 'face 'font-lock-type-face)
  " "
  ;; input method
  '(:eval (propertize (if current-input-method-title
                          current-input-method-title
                        "ENG")
                      'face '(:height 0.8)))
  " "
  ;; major mode
  (propertize "%m" 'face 'bold)
  ;; process status; eg. compilation buffer
  '("" mode-line-process)

  " "
  ;; nyan-mode!!!!!
  '(:eval (list (nyan-create)))
  " %p "        ; percent of buffer
  ;; vc-mode
  '(:eval (propertize (if vc-mode vc-mode "")
                      'face '(:foreground "sky blue" :height 0.9 :weight bold)))
  ))

(when (display-graphic-p)
  (setq-default nyan-wavy-trail t)
  (setq-default nyan-bar-length 24)
  (nyan-mode 1)
  (nyan-start-animation))

%-constructs 라고 하는 특수 문자열은 %b이면 버퍼 이름을 찍는다든가 하는 특수한 기능을 가지고 있다. C-h v mode-line-format RET 으로 살펴 보면 어떤 %-constructs가 정의되었는지 살펴 볼 수 있다.

'Emacs' 카테고리의 다른 글

fill-column-indicator를 쓸 때 popup이 깨지는 문제 수정  (0) 2017.07.03
Tramp Mode 소개  (0) 2016.10.31
rfcview.el : Emacs RFC Viewer  (0) 2016.10.31
framemove.el : Emacs frame간 이동  (0) 2016.06.25
ido에서 helm으로 넘어오다  (0) 2016.05.17