Emacs Smart Split

I spend a lot of time in front of Emacs in a terminal window, and I share my configuration across all my computers. At work I have a large monitor, so I split the emacs frame into 3 side-by-side 80-column windows. At home I have a smaller screen with room only enough for two windows. Sometimes I just use the laptop display. To share the same configuration file, I use the following snippet:

(defun smart-split ()
  "Split the frame into 80-column sub-windows, and make sure no window has
   fewer than 80 columns."
  (interactive)
  (cl-lables ((smart-split-helper (lambda (w)
                (if (> (window-width w) (* 2 81))
                  (let ((w2 (split-window w 82 t)))
                    (smart-split-helper w2))))))
    (smart-split-helper nil)))

(smart-split)

The smart-split function split the emacs frame into a maximum number of 80-column windows. A very portable solution.


LeanCloud 在招聘后端软件工程师(Clojure、Java、Node)。具体的需求以及其他正在招聘的职位请见我们的工作机会页面。除了在官网上可以看到的已经发布的产品外,我们也在开发让人兴奋的新产品,做有意义、有价值的工作。


评论