gpt4 book ai didi

emacs - Flymake 提示 X 不可用,即使配置为不使用 X

转载 作者:行者123 更新时间:2023-12-02 06:23:00 26 4
gpt4 key购买 nike

在文本模式控制台 Emacs session 中运行 Flymake 模式,我如何告诉 Flymake 在文本控制台中显示其消息而不是尝试与 X 通信?

Emacs 23 运行在各种环境中,包括 Debian 和 Ubuntu。

我将flymake-gui-warnings-enabled设置为nil,但是当我flymake-display-err-menu-for-current-line 它提示:

X windows are not in use or not initialized

是的,我知道; Emacs 在没有 X 的情况下通过 SSH 连接运行。这就是我禁用 Flymake 使用 GUI 的原因。我怎样才能告诉 Flymake 不要尝试使用 GUI,而是在 Emacs 窗口中说出它必须说的话

最佳答案

我发现“工具提示”错误消息无论如何都很烦人,所以我在我的 .emacs 中有这个,它在迷你缓冲区中显示 flymake 错误消息。这是我在某个地方从网上得到的东西。它被称为 flymake-cursor.el。信用属于第一个写它的人。您不需要我用作 flymake 助手的 Python 工具特有的 pyflake 位。主要功能是 show-fly-err-at-point,它允许您使用常规光标悬停在消息的突出显示行上。

;; License: Gnu Public License
;;
;; Additional functionality that makes flymake error messages appear
;; in the minibuffer when point is on a line containing a flymake
;; error. This saves having to mouse over the error, which is a
; ; keyboard user's annoyance

;;flymake-ler(file line type text &optional full-file)
(defun show-fly-err-at-point ()
"If the cursor is sitting on a flymake error, display the
message in the minibuffer"
(interactive)
(let ((line-no (line-number-at-pos)))
(dolist (elem flymake-err-info)
(if (eq (car elem) line-no)
(let ((err (car (second elem))))
(message "%s" (fly-pyflake-determine-message err)))))))

(defun fly-pyflake-determine-message (err)
"pyflake is flakey if it has compile problems, this adjusts the
message to display, so there is one ;)"
(cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t)))
((null (flymake-ler-file err))
;; normal message do your thing
(flymake-ler-text err))
(t ;; could not compile err
(format "compile error, problem on line %s" (flymake-ler-line err)))))

(defadvice flymake-goto-next-error (after display-message activate compile)
"Display the error in the mini-buffer rather than having to mouse over it"
(show-fly-err-at-point))

(defadvice flymake-goto-prev-error (after display-message activate compile)
"Display the error in the mini-buffer rather than having to mouse over it"
(show-fly-err-at-point))

(defadvice flymake-mode (before post-command-stuff activate compile)
"Add functionality to the post command hook so that if the
cursor is sitting on a flymake error the error information is
displayed in the minibuffer (rather than having to mouse over
it)"
(set (make-local-variable 'post-command-hook)
(cons 'show-fly-err-at-point post-command-hook)))

关于emacs - Flymake 提示 X 不可用,即使配置为不使用 X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5726988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com