首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >管理Emacs *Man*缓冲区位置?

管理Emacs *Man*缓冲区位置?
EN

Stack Overflow用户
提问于 2015-02-03 21:43:46
回答 1查看 525关注 0票数 2

Emacs最近的行为让我很恼火:

  • 我编辑文件,需要帮助
  • 男的什么的
  • emacs礼貌地将框架分成两个窗口,并在那里打开命令页,我看到了源和人,太棒了。
  • 在阅读“人”的时候,我发现我需要进一步的跟进,所以我给出了另一个主题。
  • emacs在以前由我的源代码占用的窗口中打开新的手册页,我在屏幕上看到两个手册页,无法再编辑(直到切换缓冲区)。

是否有可能使人更喜欢重用现有的城域网窗口?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-04 00:59:42

通过调整display-buffer-reuse-window来创建display-buffer-reuse-major-mode-window,我们可以使用display-buffer-alist来指定用于在Man-mode中显示缓冲区。

显然,第一种形式也可以进行轻微的修改,以适用于除Man-mode之外的任意数量的模式。

代码语言:javascript
复制
(add-to-list 'display-buffer-alist
             (cons (lambda (buffer alist)
                     (with-current-buffer buffer
                       (eq major-mode 'Man-mode)))
                   (cons 'display-buffer-reuse-major-mode-window
                         '((inhibit-same-window . nil)
                           (reusable-frames . visible)
                           (inhibit-switch-frame . nil)))))

(defun display-buffer-reuse-major-mode-window (buffer alist)
  "Return a window displaying a buffer in BUFFER's major mode.
Return nil if no usable window is found.

If ALIST has a non-nil `inhibit-same-window' entry, the selected
window is not eligible for reuse.

If ALIST contains a `reusable-frames' entry, its value determines
which frames to search for a reusable window:
  nil -- the selected frame (actually the last non-minibuffer frame)
  A frame   -- just that frame
  `visible' -- all visible frames
  0   -- all frames on the current terminal
  t   -- all frames.

If ALIST contains no `reusable-frames' entry, search just the
selected frame if `display-buffer-reuse-frames' and
`pop-up-frames' are both nil; search all frames on the current
terminal if either of those variables is non-nil.

If ALIST has a non-nil `inhibit-switch-frame' entry, then in the
event that a window on another frame is chosen, avoid raising
that frame."
  (let* ((alist-entry (assq 'reusable-frames alist))
         (frames (cond (alist-entry (cdr alist-entry))
                       ((if (eq pop-up-frames 'graphic-only)
                            (display-graphic-p)
                          pop-up-frames)
                        0)
                       (display-buffer-reuse-frames 0)
                       (t (last-nonminibuffer-frame))))
         (window (let ((mode (with-current-buffer buffer major-mode)))
                   (if (and (eq mode (with-current-buffer (window-buffer)
                                       major-mode))
                            (not (cdr (assq 'inhibit-same-window alist))))
                       (selected-window)
                     (catch 'window
                       (walk-windows
                        (lambda (w)
                          (and (window-live-p w)
                               (eq mode (with-current-buffer (window-buffer w)
                                          major-mode))
                               (not (eq w (selected-window)))
                               (throw 'window w)))
                        'nomini frames))))))
    (when (window-live-p window)
      (prog1 (window--display-buffer buffer window 'reuse alist)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame (window-frame window)))))))
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28309340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档