Flymake жалуется, что X недоступен, даже если он настроен не использовать X - PullRequest
2 голосов
/ 20 апреля 2011

Запуск режима Flymake в сеансе Emacs текстовой консоли, как я могу сказать Flymake отображать свои сообщения в текстовой консоли вместо попытки связи с X?

Emacs23 работает в различных средах, включая Debian и Ubuntu.

У меня flymake-gui-warnings-enabled установлено nil, но когда я flymake-display-err-menu-for-current-line, он жалуется:

X windows are not in use or not initialized

Да, я знаютот;Emacs работает по SSH-соединению без X. Вот почему я отключил использование графического интерфейса от Flymake.Как я могу сказать Flymake , а не , чтобы попытаться использовать графический интерфейс, и вместо этого сказать, что он говорит в окнах Emacs ?

Ответы [ 4 ]

5 голосов
/ 20 апреля 2011

Я обнаружил, что сообщения об ошибках "всплывающей подсказки" в любом случае раздражают, поэтому у меня это есть в моем .emacs, который отображает сообщения об ошибках flymake в минибуфере. Это то, что я где-то вышел из сети. Он назывался flymake-cursor.el. Кредит принадлежит парню, который написал это первым. Вам не нужны биты pyflake, специфичные для инструмента Python, который я использую в качестве помощника flymake. Основная функция - 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))) 
2 голосов
/ 25 ноября 2011

Уточнение более ранних решений.Делает сообщения об ошибках похожими на сообщения eldoc.Сообщения не попадают в буфер сообщений, сообщения не мерцают, а сообщения не блокируют другой вывод.Использует лексически переменные области, а не глобальные переменные.

Требуется emacs 24. Я считаю, что комментарий лексической привязки должен идти вверху вашего файла.

У меня нет независимого репозитория, но самую последнюю версию можно получить из моего конфига emacs на 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)))
2 голосов
/ 03 июня 2011

Вот, в основном, ответ Нуфала Ибрагима, но часть "Пайфлейкс" удалена Более конкретно, я использую 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))) 
1 голос
/ 03 августа 2011

Более полную версию flymake-cursor.el можно загрузить по адресу:

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

Он имеет некоторые оптимизации, которые гарантируют, что он не будет спамить ваш мини-буфер, пока вы перемещаетесь с высокой скоростью.

...