diff options
| author | Stefan Monnier | 2003-06-09 17:42:22 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-06-09 17:42:22 +0000 |
| commit | 5e56fb538040c979575a27a88c3bfbfde4bf88d4 (patch) | |
| tree | 440527d703d724dc1d309abd0c8c14159b1b8456 | |
| parent | 9b341343a9bdd70c6a8fc1abf166785acad460f8 (diff) | |
| download | emacs-5e56fb538040c979575a27a88c3bfbfde4bf88d4.tar.gz emacs-5e56fb538040c979575a27a88c3bfbfde4bf88d4.zip | |
(tex-search-noncomment): New macro.
(tex-last-unended-begin, tex-next-unmatched-end): Use it
so we don't get confused by \begin and \end in comments.
(tex-compile): Change dir before calling tex-compile-default.
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index e06e98ba4cf..583c106c173 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -1263,17 +1263,30 @@ Puts point on a blank line between them." | |||
| 1263 | ;;;; LaTeX syntax navigation | 1263 | ;;;; LaTeX syntax navigation |
| 1264 | ;;;; | 1264 | ;;;; |
| 1265 | 1265 | ||
| 1266 | (defmacro tex-search-noncomment (&rest body) | ||
| 1267 | "Execute BODY as long as it return non-nil and point is in a comment. | ||
| 1268 | Return the value returned by the last execution of BODY." | ||
| 1269 | (declare (debug t)) | ||
| 1270 | (let ((res-sym (make-symbol "result"))) | ||
| 1271 | `(let (,res-sym) | ||
| 1272 | (while | ||
| 1273 | (and (setq ,res-sym (progn ,@body)) | ||
| 1274 | (save-excursion (skip-chars-backward "^\n%") (not (bolp))))) | ||
| 1275 | ,res-sym))) | ||
| 1276 | |||
| 1266 | (defun tex-last-unended-begin () | 1277 | (defun tex-last-unended-begin () |
| 1267 | "Leave point at the beginning of the last `\\begin{...}' that is unended." | 1278 | "Leave point at the beginning of the last `\\begin{...}' that is unended." |
| 1268 | (condition-case nil | 1279 | (condition-case nil |
| 1269 | (while (and (re-search-backward "\\\\\\(begin\\|end\\)\\s *{") | 1280 | (while (and (tex-search-noncomment |
| 1281 | (re-search-backward "\\\\\\(begin\\|end\\)\\s *{")) | ||
| 1270 | (looking-at "\\\\end")) | 1282 | (looking-at "\\\\end")) |
| 1271 | (tex-last-unended-begin)) | 1283 | (tex-last-unended-begin)) |
| 1272 | (search-failed (error "Couldn't find unended \\begin")))) | 1284 | (search-failed (error "Couldn't find unended \\begin")))) |
| 1273 | 1285 | ||
| 1274 | (defun tex-next-unmatched-end () | 1286 | (defun tex-next-unmatched-end () |
| 1275 | "Leave point at the end of the next `\\end' that is unended." | 1287 | "Leave point at the end of the next `\\end' that is unended." |
| 1276 | (while (and (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}") | 1288 | (while (and (tex-search-noncomment |
| 1289 | (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}")) | ||
| 1277 | (save-excursion (goto-char (match-beginning 0)) | 1290 | (save-excursion (goto-char (match-beginning 0)) |
| 1278 | (looking-at "\\\\begin"))) | 1291 | (looking-at "\\\\begin"))) |
| 1279 | (tex-next-unmatched-end))) | 1292 | (tex-next-unmatched-end))) |
| @@ -1813,13 +1826,14 @@ FILE is typically the output DVI or PDF file." | |||
| 1813 | ;; FIXME: Use time-stamps on files to decide the next op. | 1826 | ;; FIXME: Use time-stamps on files to decide the next op. |
| 1814 | (interactive | 1827 | (interactive |
| 1815 | (let* ((file (tex-main-file)) | 1828 | (let* ((file (tex-main-file)) |
| 1816 | (dir (prog1 (file-name-directory (expand-file-name file)) | 1829 | (default-directory |
| 1817 | (setq file (file-name-nondirectory file)))) | 1830 | (prog1 (file-name-directory (expand-file-name file)) |
| 1831 | (setq file (file-name-nondirectory file)))) | ||
| 1818 | (root (file-name-sans-extension file)) | 1832 | (root (file-name-sans-extension file)) |
| 1819 | (fspec (list (cons ?r (comint-quote-filename root)) | 1833 | (fspec (list (cons ?r (comint-quote-filename root)) |
| 1820 | (cons ?f (comint-quote-filename file)))) | 1834 | (cons ?f (comint-quote-filename file)))) |
| 1821 | (default (tex-compile-default fspec))) | 1835 | (default (tex-compile-default fspec))) |
| 1822 | (list dir | 1836 | (list default-directory |
| 1823 | (completing-read | 1837 | (completing-read |
| 1824 | (format "Command [%s]: " (tex-summarize-command default)) | 1838 | (format "Command [%s]: " (tex-summarize-command default)) |
| 1825 | (mapcar (lambda (x) | 1839 | (mapcar (lambda (x) |