ㅈㅅㄹ

fill-column-indicator를 사용하다 보면 은근히 짜증나는 경우가 많다. 특히 company-modeflyspell-popup같은 popup overlay을 사용하는 것들이 뜰 때 아래 그림처럼 레이아웃이 깨져 보이는 경우가 발생한다.



일단은 이게 popup을 그리는 쪽에 문제가 있어서 그런 게 아니고, fci-mode쪽이 문제인 것이라, 일단 workaround로 popup이 뜰 때 fci-mode를 끄는 수 밖에 없다. 사실 popup overlay를 쓰는 것들이 많지가 않아서 내 경우는 flyspell-popupcompany-mode만 좀 만져주면 되었다. Workaround를 적용하는 것은 공통적인 뭔가 있는 것은 아니고 일일이 각 모드마다 popup을 띄우는 함수에 advice 함수를 거는 수 밖에 없다.

;; Fix the problem of distorted popup of company
(defun my:company-fci-workaround (command)
  (cond ((and fci-mode
              (string= command "show"))
         (setq-local my:fci-mode-suppressed t)
         (turn-off-fci-mode))
        ((and my:fci-mode-suppressed
              (string= command "hide"))
         (turn-on-fci-mode)
         (setq-local my:fci-mode-suppressed nil))))
(advice-add 'company-call-frontends :before #'my:company-fci-workaround)

;; Fix the problem of distorted popup of flyspell-popup-correct
(define-error 'my:flyspell-fci-workaround-trap
  "A custom signal to run trap in my:flyspell-fci-workaround.")

(defun my:flyspell-fci-workaround (orig-fun &rest args)
  (condition-case nil
      (if fci-mode
          (progn
            (turn-off-fci-mode)
            (unwind-protect
                (apply orig-fun args)
              (turn-on-fci-mode)))
        (signal 'my:flyspell-fci-workaround-trap nil))
    (my:flyspell-fci-workaround-trap (apply orig-fun args))))
(advice-add 'flyspell-popup-correct :around #'my:flyspell-fci-workaround)

위와 같이 설정해 주면, flyspell-popup이나 company-mode의 popup이 뜰 때 fci-mode가 활성화 되어 있다면, popup이 뜰 때 잠깐 껏다가 popup이 사라질 때 다시 켜 주게 된다. 이거 말고도 truncate-lines을 끌 때 짜증나는 문제도 좀 있긴 한 데, 그건 나중에....

'Emacs' 카테고리의 다른 글

mode-line-format 변경하기  (0) 2017.07.21
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