[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex d86e95e 30/43: Support flymake in Emacs 26+ usin
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex d86e95e 30/43: Support flymake in Emacs 26+ using chktex |
Date: |
Tue, 20 Mar 2018 11:34:11 -0400 (EDT) |
branch: externals/auctex
commit d86e95e5c2c70cc1be5de85add8fc9698f08c396
Author: Alex Branham <address@hidden>
Commit: Mosè Giordano <address@hidden>
Support flymake in Emacs 26+ using chktex
* latex-flymake.el: New file.
* latex.el (require): Require `latex-flymake' in Emacs >= 26.
---
latex-flymake.el | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
latex.el | 3 ++
2 files changed, 89 insertions(+)
diff --git a/latex-flymake.el b/latex-flymake.el
new file mode 100644
index 0000000..e77e059
--- /dev/null
+++ b/latex-flymake.el
@@ -0,0 +1,86 @@
+;;; latex-flymake.el --- Flymake integration -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; This file provides flymake integration for latex documents using
+;; "chktex" as a backend. You must be running Emacs 26 or newer.
+;; Enable it by adding the following to your init file:
+
+;; (add-hook 'LaTeX-mode-hook flymake-mode)
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl-lib))
+(require 'flymake)
+
+(defvar-local LaTeX--flymake-proc nil)
+
+(defun LaTeX-flymake (report-fn &rest _args)
+ "Setup flymake integration.
+
+REPORT-FN is flymake's callback function."
+ (unless (executable-find "chktex")
+ (error "Cannot find chktex"))
+ (when (process-live-p LaTeX--flymake-proc)
+ (kill-process LaTeX--flymake-proc))
+ (let ((source (current-buffer)))
+ (save-restriction
+ (widen)
+ (setq
+ LaTeX--flymake-proc
+ (make-process
+ :name "LaTeX-flymake" :noquery t :connection-type 'pipe
+ :buffer (generate-new-buffer " *LaTeX-flymake*")
+ :command '("chktex" "--verbosity=0" "--quiet" "--inputfiles")
+ :sentinel
+ (lambda (proc _event)
+ (when (eq 'exit (process-status proc))
+ (unwind-protect
+ (if (with-current-buffer source (eq proc LaTeX--flymake-proc))
+ (with-current-buffer (process-buffer proc)
+ (goto-char (point-min))
+ (cl-loop
+ while (search-forward-regexp
+ (rx line-start "stdin:"
+ ;; line
+ (group-n 1 (one-or-more num))
+ ":"
+ ;; column
+ (group-n 2 (one-or-more num))
+ ":"
+ ;; This is information about the
+ ;; number of the warning, which we
+ ;; probably don't care about:
+ (one-or-more num)
+ ":"
+ ;; Warning message:
+ (group-n 3 (one-or-more not-newline))
line-end)
+ nil t)
+ for msg = (match-string 3)
+ for (beg . end) = (flymake-diag-region
+ source
+ (string-to-number (match-string 1))
+ (string-to-number (match-string 2)))
+ for type = :warning
+ collect (flymake-make-diagnostic source
+ beg
+ end
+ type
+ msg)
+ into diags
+ finally (funcall report-fn diags)))
+ (flymake-log :warning "Canceling obsolete check %s"
+ proc))
+ (kill-buffer (process-buffer proc)))))))
+ (process-send-region LaTeX--flymake-proc (point-min) (point-max))
+ (process-send-eof LaTeX--flymake-proc))))
+
+(defun LaTeX-setup-flymake-backend ()
+ "Setup flymake backend for LaTeX."
+ (add-hook 'flymake-diagnostic-functions 'LaTeX-flymake nil t))
+
+(when (< 25 emacs-major-version)
+ (add-hook 'LaTeX-mode-hook #'LaTeX-setup-flymake-backend))
+
+(provide 'latex-flymake)
+;;; latex-flymake.el ends here
diff --git a/latex.el b/latex.el
index 05d6f55..411db0e 100644
--- a/latex.el
+++ b/latex.el
@@ -31,6 +31,9 @@
(require 'tex)
(require 'tex-style)
(require 'tex-ispell)
+(when (<= 26 emacs-major-version)
+ ;; latex-flymake requires Emacs 26.
+ (require 'latex-flymake))
(eval-when-compile
(require 'cl-lib))
- [elpa] externals/auctex 9ba765e 04/43: Remove TeX-deactivate-mark, (continued)
- [elpa] externals/auctex 9ba765e 04/43: Remove TeX-deactivate-mark, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 12618af 09/43: Remove code for compatibility with old Emacsens in tex.el, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 77c2cda 15/43: Remove XEmacs compatibility code in tex-jp.el, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 6861a88 10/43: Change encoding of Elisp source files to UTF-8, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 62d3606 18/43: Remove compatibility code for XEmacs in tex-fold.el, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 05c09bd 06/43: Remove TeX-how-many function, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex f366130 03/43: Remove old compat functions for commenting and uncommenting, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex f8290fc 21/43: Restore loading of prv-emacs, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 39d4959 23/43: * texmathp.el (texmathp-tex-commands-default): Add entries for breqn.sty., Tassilo Horn, 2018/03/20
- [elpa] externals/auctex d3d321a 05/43: Remove TeX-assoc-string, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex d86e95e 30/43: Support flymake in Emacs 26+ using chktex,
Tassilo Horn <=
- [elpa] externals/auctex 7f9d64b 39/43: * font-latex.el (font-latex--get-script-props): Use `cl-case' instead of `case'., Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 5592c69 35/43: Improve flymake documentation, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex f7a4622 16/43: Delte prv-xemacs.el, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 3cdfdc8 19/43: Remove compatibility code for XEmacs in font-latex.el, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 45d9e1b 13/43: Make sure `LaTeX-default-options' is honored, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 4b66b9f 27/43: Do not actually write bug report instructions, Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 657c338 40/43: * tex.el (TeX-dwim-master): Prefer `cl-return' over `return'., Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 8779f2d 33/43: * style/babel.el (LaTeX-babel-active-languages): Use `cl-pushnew'., Tassilo Horn, 2018/03/20
- [elpa] externals/auctex c1f04df 41/43: * style/amsmath.el ("amsmath"): Correct \cfrac spec., Tassilo Horn, 2018/03/20
- [elpa] externals/auctex 430025d 20/43: Remove compatibility code for XEmacs in toolbar-x.el, Tassilo Horn, 2018/03/20