emacs 在 macOS 上能使用系统自带的 tab 吗?

类似于这种 iterm2 的这种 tab bar(下图的上半部分)。之前在 mailing list 里面看到最近有相关的 commit,但是没看明白是什么效果 :rofl:


UPDATE: 在 src/nsterm.m 里面看到了对应的注释……

      /* macOS Sierra automatically enables tabbed windows.  We can't
         allow this to be enabled until it's available on a Free system.
         Currently it only happens by accident and is buggy anyway.  */
#ifdef NS_IMPL_COCOA
      if ([self respondsToSelector:@selector(setTabbingMode:)])
        [self setTabbingMode:NSWindowTabbingModeDisallowed];
#endif


UPDATE2: emacs-mac 里面太复杂了,我选了条别的路径,把 tab-bar-mode 的 tab 给挪上去了,还没来得及改 tab-bar 的外观,不过总体的效果已经可以接受了。

Patch 在这里。 需要在 default-frame-alist 增加两项

(setq-default
 default-frame-alist
 '( ; Some other settings here
   (ns-title-hidden . 1) ; hide the window title
   (ns-fullsize-content . 1) ; make the contentView overlap with the titlebar
  )

另外 tab-bar 最好设置成默认启用,否则 buffer 内容可能与三个按钮重叠。

  (use-package tab-bar
    :config
    (defun tab-bar-padding-left()
      "                ") 
    (setq tab-bar-format
          '(tab-bar-padding-left ; 这个 padding 在 tab-bar 左边加了空白,把按钮的位置空出来
            tab-bar-format-history ; 剩下这些都是默认值
            tab-bar-format-tabs
            tab-bar-separator
            tab-bar-format-add-tab))
    (set-face-attribute
     'tab-bar nil
     :height 1.2) ; 高度至少要比原本的 titlebar 高,不然按钮可能与 buffer 内容重叠
    (tab-bar-mode 1)
    )
1 个赞

能, 用 emacs-mac

NS port 不能,因为自由平台没有这个功能。

谢谢,不过还是希望跟在主线上

请问一下,是因为理念冲突无法被合入,还是技术原因?

理念冲突,不是技术原因

1 个赞

我看 emacs mac 中有这个 patch,应该可以自己打一下

嗯,我也打算这么做。谢谢。

是理念问题。具体原因可以参考 Savannah Hosting Requirements

It is ok for the program to run on nonfree platforms or nonfree operating systems, and to work with well-known nonfree applications, in addition to working with free software, provided it gives the free software at least as good support as it gives to nonfree counterparts. In other words, at no time, in no way, should your program put free software users at a disadvantage compared to those willing to use proprietary software.

所以我不用tab,就没有纠结了 :joy:

2 个赞

我之前是想替换掉 iterm2,所以想把 tab 放上面,节省一些空间 :stuck_out_tongue_winking_eye:

反过来考虑,你在iterm2中用Emacs? :joy:

那就没法用 GUI 的 emacs 了,终端的和 GUI 的效果还是有些差别。不过现在已经搞定了,效果至少我自己能接受 :smirk: