LoginSignup
5
5

More than 5 years have passed since last update.

popwinの出現位置をフレームサイズに応じて切り替える

Posted at

popwinの出現位置がフレームのサイズに応じて下になったり右になったり (上や左でもいいけど) したらいいなと思いました。フレームが縦長の時は下に、横長の時は右側に出るようにしてみました。

下に出るか横に出るかの正確な条件はコードを読んでくださいw

~/.emacs.d/init.el
;; フレームのサイズに応じてpopwinの出現位置を決める
(defun popwin-auto-set-popup-window-position ()
  (interactive)
  (let ((w (frame-width))
        (h (frame-height)))
    (setq popwin:popup-window-position
          (if (and (< 200 w)         ; フレームの幅が200桁より大きくて
                   (< h w))          ; 横長の時に
              'right                 ; 右へ出す
            'bottom))))              ; そうじゃないときは下へ出す
;; popwin表示時にフレームサイズに応じた表示位置にする
(defadvice  popwin:display-buffer (before popwin-auto-window-position activate)
  (popwin-auto-set-popup-window-position))
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5