Flymake 抱怨即使配置为不使用 X,X 也不可用

发布于 2024-11-02 07:19:15 字数 496 浏览 2 评论 0原文

在文本模式控制台 Emacs 会话中运行 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 窗口中说出它必须说的内容

Running the Flymake mode in a text-mode console Emacs session, how can I tell Flymake to display its messages in the text console instead of trying to communicate with X?

Emacs 23 running on various environments, including Debian and Ubuntu.

I have flymake-gui-warnings-enabled set to nil, but when I flymake-display-err-menu-for-current-line it complains:

X windows are not in use or not initialized

Yes, I know that; Emacs is running across an SSH connection without X. That's why I disabled GUI use by Flymake. How can I tell Flymake not to try using the GUI, and instead to say what it has to say in the Emacs windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无声情话 2024-11-09 07:19:15

我发现“工具提示”错误消息无论如何都很烦人,所以我在 .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))) 

I've found the "tooltip" error messages plain annoying anyway so I have this in my .emacs that displays flymake error messages in the minibuffer. This is something which I got off the net somewhere. It was called flymake-cursor.el. Credit belongs to the chap who wrote it first. You don't need the pyflake bits which are specific to the Python tool I use as a flymake helper. The main function is show-fly-err-at-point which allows you to use your regular cursor to hover on a highlighted line for the message.

;; 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))) 
网白 2024-11-09 07:19:15

这基本上是 Noufal Ibrahim 的答案,但 pyflakes 部分已被删除。更具体地说,我直接使用 Flymake-ler-text 来提取错误的文本部分。我只尝试过 epylint。就像魅力一样。

;; show error in the mini buffer instead of in the menu.
;; 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" (flymake-ler-text 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))) 

Here's basically the answer of Noufal Ibrahim but the pyflakes part has been removed. More specifically I'm using flymake-ler-text directly to extract the text part of the error. I've only tried with epylint. Works like a charm.

;; show error in the mini buffer instead of in the menu.
;; 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" (flymake-ler-text 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))) 
惯饮孤独 2024-11-09 07:19:15

对早期解决方案的改进。使错误消息的行为更像 eldoc 消息。消息不会最终出现在消息缓冲区中,消息不会闪烁,并且消息不会阻塞其他输出。使用词法作用域变量而不是全局变量。

需要 emacs 24。我相信词法绑定注释必须位于文件的顶部。

我没有独立的存储库,但可以从 我在 github 上的 emacs 配置

;;; -*- lexical-binding: t -*-
;; Make flymake show eldoc style error messages.
(require 'eldoc)
(defun c5-flymake-ler-at-point ()
  (caar (flymake-find-err-info flymake-err-info (line-number-at-pos))))

(defun c5-flymake-show-ler (ler)
  (when ler
    ;; Don't log message.
    (let ((message-log-max nil)) 
      (message (flymake-ler-text ler)))))

(let ((timer nil)
      (ler nil))
 (defalias 'c5-flymake-post-command-action (lambda ()
    (when timer
      (cancel-timer timer)
      (setq timer nil))
    (setq ler (c5-flymake-ler-at-point))
    (when ler
      (setq timer (run-at-time "0.9 sec" nil
                               (lambda ()
                                 (when (let ((eldoc-mode t))
                                         (eldoc-display-message-p))
                                   (c5-flymake-show-ler ler))))))))

 (defalias 'c5-flymake-pre-command-action (lambda ()
    (when (let ((eldoc-mode t)) (eldoc-display-message-no-interference-p))
      (c5-flymake-show-ler ler)))))

(defadvice flymake-mode (before c5-flymake-post-command activate compile)
  (add-hook 'post-command-hook 'c5-flymake-post-command-action nil t)
  (add-hook 'pre-command-hook 'c5-flymake-pre-command-action nil t))

(defadvice flymake-goto-next-error (after display-message activate compile)
  (c5-flymake-show-ler (c5-flymake-ler-at-point)))

(defadvice flymake-goto-prev-error (after display-message activate compile)
  (c5-flymake-show-ler (c5-flymake-ler-at-point)))

A refinement of earlier solutions. Makes the error messages behave more like eldoc messages. Messages don't end up in the message buffer, messages don't flicker, and messages don't block other output. Uses lexically scoped variables rather than global variables.

Requires emacs 24. I believe the lexical binding comment must go at the top of your file.

I don't have an independent repository for this, but the most up to date version can be got from my emacs config on github.

;;; -*- lexical-binding: t -*-
;; Make flymake show eldoc style error messages.
(require 'eldoc)
(defun c5-flymake-ler-at-point ()
  (caar (flymake-find-err-info flymake-err-info (line-number-at-pos))))

(defun c5-flymake-show-ler (ler)
  (when ler
    ;; Don't log message.
    (let ((message-log-max nil)) 
      (message (flymake-ler-text ler)))))

(let ((timer nil)
      (ler nil))
 (defalias 'c5-flymake-post-command-action (lambda ()
    (when timer
      (cancel-timer timer)
      (setq timer nil))
    (setq ler (c5-flymake-ler-at-point))
    (when ler
      (setq timer (run-at-time "0.9 sec" nil
                               (lambda ()
                                 (when (let ((eldoc-mode t))
                                         (eldoc-display-message-p))
                                   (c5-flymake-show-ler ler))))))))

 (defalias 'c5-flymake-pre-command-action (lambda ()
    (when (let ((eldoc-mode t)) (eldoc-display-message-no-interference-p))
      (c5-flymake-show-ler ler)))))

(defadvice flymake-mode (before c5-flymake-post-command activate compile)
  (add-hook 'post-command-hook 'c5-flymake-post-command-action nil t)
  (add-hook 'pre-command-hook 'c5-flymake-pre-command-action nil t))

(defadvice flymake-goto-next-error (after display-message activate compile)
  (c5-flymake-show-ler (c5-flymake-ler-at-point)))

(defadvice flymake-goto-prev-error (after display-message activate compile)
  (c5-flymake-show-ler (c5-flymake-ler-at-point)))
墨落成白 2024-11-09 07:19:15

您可以在以下位置下载更完整的 flymake-cursor.el 版本:

http://www.emacswiki.org/emacs/flymake-cursor.el

它有一些优化,确保当您高速移动光标时它不会向您的迷你缓冲区发送垃圾邮件。

You can download a more complete version of flymake-cursor.el at:

http://www.emacswiki.org/emacs/flymake-cursor.el

It has some optimizations that ensure it doesn't spam your mini-buffer while you cursor around at high speed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文