[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex-cont-latexmk 5d724b7b9d 007/100: cleanup, docs
From: |
ELPA Syncer |
Subject: |
[elpa] externals/auctex-cont-latexmk 5d724b7b9d 007/100: cleanup, docs |
Date: |
Thu, 6 Jun 2024 03:57:50 -0400 (EDT) |
branch: externals/auctex-cont-latexmk
commit 5d724b7b9db195ded3c4f7e4c2560eccd05b7edf
Author: Paul Nelson <ultrono@gmail.com>
Commit: Paul Nelson <ultrono@gmail.com>
cleanup, docs
---
czm-tex-compile.el | 149 ++++++++++++++++++++++++-----------------------------
1 file changed, 67 insertions(+), 82 deletions(-)
diff --git a/czm-tex-compile.el b/czm-tex-compile.el
index 84e3bd7934..98b0ec0486 100644
--- a/czm-tex-compile.el
+++ b/czm-tex-compile.el
@@ -23,77 +23,58 @@
;;; Commentary:
-;; Convenience functions for compiling LaTeX. Under construction.
+;; This package provides convenience functions for compiling a LaTeX
+;; document continuously via latexmk and navigating the errors and
+;; warnings recorded in the log file. Customize the variable
+;; `czm-tex-compile-command' to change the command used to compile the
+;; document.
+;;
+;; Sample use-package declaration:
+;;
+;; (use-package czm-tex-compile
+;; :vc (:url "https://github.com/ultronozm/czm-tex-compile.el.git"
+;; :rev :newest)
+;; :after latex
+;; :bind
+;; ("C-c k" . czm-tex-compile)
+;; ("M-]" . czm-tex-compile-next-error)
+;; ("M-[" . czm-tex-compile-previous-error))
;;; Code:
(require 'esh-mode)
-;;;###autoload
-(defun czm-tex-compile-start-latexmk-eshell ()
- (interactive)
- (if (string-match "\\([^\.]+\\)\.tex" (buffer-name))
- (let ((name (match-string 1 (buffer-name))))
- (let ((bufname (concat "*eshell-" name "*")))
- (if (get-buffer bufname)
- (switch-to-buffer bufname)
- (save-window-excursion
- (eshell "new")
- (rename-buffer bufname)
- (insert (concat "latexmk -shell-escape -pvc -pdf -view=none "
name ".tex"))
- (eshell-send-input)))))))
-
-;; next three are experimental
-
-(defun czm-tex-compile-my-latexmk-this-0 ()
- (interactive)
- (if (string-match "\\([^\.]+\\)\.tex" (buffer-name))
- (let ((name (match-string 1 (buffer-name)))
- (default-directory (file-name-directory (buffer-file-name))))
- (let ((bufname (concat "*latexmk-" name "*")))
- (with-current-buffer (get-buffer-create bufname)
- (compilation-start (format "latexmk -shell-escape -pvc -pdf
-view=none %s.tex" name) 'compilation-mode)
- (display-buffer bufname))))))
-
-(defun czm-tex-compile-my-latexmk-this ()
- (interactive)
- (if (string-match "\\([^\.]+\\)\.tex" (buffer-name))
- (let ((name (match-string 1 (buffer-name)))
- (default-directory (file-name-directory (buffer-file-name))))
- (let ((bufname (concat "*latexmk-" name "*")))
- (with-current-buffer (get-buffer-create bufname)
- (unless (eq major-mode 'compilation-mode)
- (compilation-mode))
- (compilation-start (format "latexmk -shell-escape -pvc -pdf
-view=none %s.tex" name) nil
- (lambda (_mode-name) bufname))
- (display-buffer bufname)
- (local-set-key (kbd "x") 'czm-tex-compile-my-kill-compilation))))))
-
-(defun czm-tex-compile-my-kill-compilation ()
- "Kill the current compilation process."
- (interactive)
- (when (get-buffer-process (current-buffer))
- (interrupt-process (get-buffer-process (current-buffer)))
- (message "Compilation process killed.")))
-
-;; Maybe improve this at some point using the following:
-;; (let ((entry (save-excursion
-;; (bibtex-beginning-of-entry)
-;; (bibtex-parse-entry))))
-;; (cdr (assoc "=key=" entry))
+(defcustom czm-tex-compile-command
+ "latexmk -shell-escape -pvc -pdf -view=none -e '$pdflatex=q/pdflatex %O
-interaction=nonstopmode %S/'"
+ "Command to compile LaTeX documents."
+ :type 'string
+ :group 'czm-tex-compile)
-(defun czm-tex-compile-my-paragraph-as-line ()
+;;;###autoload
+(defun czm-tex-compile ()
+ "Compile the current LaTeX document in an eshell buffer.
+If the eshell buffer already exists, switch to it. Otherwise,
+create a new eshell buffer and compile the document in it. The
+eshell buffer is named *eshell-<name>*, where <name>.tex is the
+name of the current LaTeX file."
(interactive)
- (let ((beg (point))
- (end (save-excursion
- (forward-paragraph)
- (point))))
- (replace-regexp-in-string "\n" "" (buffer-substring-no-properties beg
end))))
-
-(defvar-local czm-tex-compile-log-state nil
+ (when (string-match "\\([^\.]+\\)\.tex" (buffer-name))
+ (let* ((name (match-string 1 (buffer-name)))
+ (bufname (concat "*eshell-" name "*")))
+ (if (get-buffer bufname)
+ (switch-to-buffer bufname)
+ (save-window-excursion
+ (eshell "new")
+ (rename-buffer bufname)
+ (insert (concat czm-tex-compile-command " " name ".tex"))
+ (eshell-send-input))))))
+
+(defvar-local czm-tex-compile--log-state nil
"Cons containing last navigation time and log file position.")
(defun czm-tex-compile--paragraph-as-line ()
+ "Return the current paragraph as a single line.
+Used for navigating LaTeX warnings in the log file."
(interactive)
(let ((beg (point))
(end (save-excursion
@@ -101,7 +82,7 @@
(point))))
(replace-regexp-in-string "\n" "" (buffer-substring-no-properties beg
end))))
-(defun czm-tex-compile-navigate-log-error (direction)
+(defun czm-tex-compile--navigate-log-error (direction)
"Helper function to navigate warnings in the log file.
DIRECTION should be either \='next or \='previous."
(let* ((tex-file (buffer-file-name))
@@ -109,8 +90,8 @@ DIRECTION should be either \='next or \='previous."
(already-open (find-buffer-visiting log-file))
(buf (or already-open (find-file-noselect log-file)))
(file-modification-time (nth 5 (file-attributes log-file)))
- (last-navigation-time (car czm-tex-compile-log-state))
- (log-pos (cdr czm-tex-compile-log-state))
+ (last-navigation-time (car czm-tex-compile--log-state))
+ (log-pos (cdr czm-tex-compile--log-state))
line description)
(with-current-buffer buf
(save-excursion)
@@ -150,34 +131,38 @@ DIRECTION should be either \='next or \='previous."
(setq log-pos (point))))))
(unless already-open
(kill-buffer buf))
- (setq-local czm-tex-compile-log-state (cons last-navigation-time log-pos))
+ (setq-local czm-tex-compile--log-state (cons last-navigation-time log-pos))
(when line
- (if (consp line)
- (progn
- ;; TODO: should probably widen first?
- (goto-char (point-min))
- (forward-line (1- (car line)))
- (let* ((search-string (cdr line))
- (truncated-search-string
- (if (< (length search-string) 3)
- search-string
- (substring search-string 3))))
- (search-forward truncated-search-string nil t)))
- (goto-char (point-min))
- (forward-line (1- line))))
+ (let ((pos
+ (save-excursion
+ (save-restriction
+ (goto-char (point-min))
+ (forward-line (1- (if (consp line) (car line) line)))
+ (when (consp line)
+ (let* ((search-string (cdr line))
+ (truncated-search-string
+ (if (< (length search-string) 3)
+ search-string
+ (substring search-string 3))))
+ (search-forward truncated-search-string nil t)))
+ (point)))))
+ (unless (<= (point-min) pos (point-max))
+ (widen))
+ (goto-char pos)
+ (recenter)))
(message (or description "No further errors or warnings."))))
;;;###autoload
-(defun czm-tex-compile-previous-log-error ()
+(defun czm-tex-compile-previous-error ()
"Move point to the previous LaTeX-warning line."
(interactive)
- (czm-tex-compile-navigate-log-error 'previous))
+ (czm-tex-compile--navigate-log-error 'previous))
;;;###autoload
-(defun czm-tex-compile-next-log-error ()
+(defun czm-tex-compile-next-error ()
"Move point to the next LaTeX-warning line."
(interactive)
- (czm-tex-compile-navigate-log-error 'next))
+ (czm-tex-compile--navigate-log-error 'next))
(provide 'czm-tex-compile)
;;; czm-tex-compile.el ends here
- [elpa] branch externals/auctex-cont-latexmk created (now a769d92a2c), ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk e32ff4bc0f 001/100: Initial commit, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 962365441a 005/100: Update czm-tex-compile.el, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk febe275533 003/100: Add autoloads, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk fb414265c0 009/100: Add czm-tex-compile--kill-buffer-hook, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 447b9f3be2 018/100: add synctex to default options, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 27c1ef5c71 002/100: Add files via upload, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 09e362e9f6 006/100: fixed some silly bugs, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 5d724b7b9d 007/100: cleanup, docs,
ELPA Syncer <=
- [elpa] externals/auctex-cont-latexmk 45bd7a6c32 012/100: switch back to previous reverse-direction style, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk c2d7e5cb90 015/100: delete resolved TODO from comments, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk d052e767e6 016/100: Add synctex=1 to default compile command, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 8633c833d9 020/100: Update README.org, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 6cd49a0317 027/100: about to hack stuff up, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 2762ee8084 037/100: polish, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk e5cce65c36 040/100: readme tweaks, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 989be1a7a9 043/100: flycheck warnings, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 7e2cbfbc88 046/100: fix defcustom groups, ELPA Syncer, 2024/06/06
- [elpa] externals/auctex-cont-latexmk 2639003039 059/100: tweaks, ELPA Syncer, 2024/06/06