简体   繁体   English

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

[英]Flymake complains X is not available even when configured not to use X

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会话中运行Flymake模式,如何告诉Flymake 在文本控制台中显示其消息而不是尝试与X通信?

Emacs 23 running on various environments, including Debian and Ubuntu. Emacs 23运行在各种环境中,包括Debian和Ubuntu。

I have flymake-gui-warnings-enabled set to nil , but when I flymake-display-err-menu-for-current-line it complains: 我将flymake-gui-warnings-enabled设置为nil ,但是当我使用flymake-display-err-menu-for-current-line它会抱怨:

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. Emacs在没有X的情况下运行SSH连接。这就是我禁用Flymake使用GUI的原因。 How can I tell Flymake not to try using the GUI, and instead to say what it has to say in the Emacs windows ? 我如何告诉Flymake 不要尝试使用GUI,而是说出它在Emacs窗口中要说些什么

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. 我发现“工具提示”错误信息无论如何flymake烦人,所以我在.emacs中有这个,它在迷你缓冲区中显示flymake错误信息。 This is something which I got off the net somewhere. 这是我从某个地方下网的事情。 It was called flymake-cursor.el . 它被称为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. 您不需要特定于我用作flymake帮助器的Python工具的pyflake位。 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. 主要功能是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))) 

Here's basically the answer of Noufal Ibrahim but the pyflakes part has been removed. 这里基本上是Noufal Ibrahim的答案,但pyflakes部分已被删除。 More specifically I'm using flymake-ler-text directly to extract the text part of the error. 更具体地说,我直接使用flymake-ler-text来提取错误的文本部分。 I've only tried with epylint. 我只试过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))) 

A refinement of earlier solutions. 对早期解决方案的改进。 Makes the error messages behave more like eldoc messages. 使错误消息更像eldoc消息。 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. 需要emacs 24.我相信词汇绑定注释必须放在你文件的顶部。

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 . 我没有这个独立的存储库,但是最新版本可以从我在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)))

You can download a more complete version of flymake-cursor.el at: 您可以在以下位置下载更完整版本的flymake-cursor.el

http://www.emacswiki.org/emacs/flymake-cursor.el 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. 它具有一些优化功能,可确保您在高速光标时不会向迷你缓冲区发送垃圾邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM