2

テキストモード コンソールの Emacs セッションで Flymake モードを実行している場合、Flymake にX と通信する代わりにテキスト コンソールにメッセージを表示するように指示するにはどうすればよいですか?

Debian や Ubuntu など、さまざまな環境で動作する Emacs 23。

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 を使用しないように指示するにはどうすればよいですか?

4

4 に答える 4

5

とにかく、「ツールチップ」エラーメッセージが単純に煩わしいことがわかったので、ミニバッファーにエラーメッセージ.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))) 
于 2011-04-20T07:54:57.100 に答える
2

以前のソリューションの改良。エラーメッセージをより 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)))
于 2011-11-25T05:34:54.550 に答える
2

これは基本的に Noufal Ibrahim の回答ですが、pyflakes の部分は削除されています。より具体的には、flymake-ler-text を直接使用して、エラーのテキスト部分を抽出しています。私はエピリントでのみ試しました。魅力のように機能します。

;; 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))) 
于 2011-06-03T06:51:55.813 に答える