1263 |
;;;; LaTeX syntax navigation |
;;;; LaTeX syntax navigation |
1264 |
;;;; |
;;;; |
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 |
|
|
1277 |
(defun tex-last-unended-begin () |
(defun tex-last-unended-begin () |
1278 |
"Leave point at the beginning of the last `\\begin{...}' that is unended." |
"Leave point at the beginning of the last `\\begin{...}' that is unended." |
1279 |
(condition-case nil |
(condition-case nil |
1280 |
(while (and (re-search-backward "\\\\\\(begin\\|end\\)\\s *{") |
(while (and (tex-search-noncomment |
1281 |
|
(re-search-backward "\\\\\\(begin\\|end\\)\\s *{")) |
1282 |
(looking-at "\\\\end")) |
(looking-at "\\\\end")) |
1283 |
(tex-last-unended-begin)) |
(tex-last-unended-begin)) |
1284 |
(search-failed (error "Couldn't find unended \\begin")))) |
(search-failed (error "Couldn't find unended \\begin")))) |
1285 |
|
|
1286 |
(defun tex-next-unmatched-end () |
(defun tex-next-unmatched-end () |
1287 |
"Leave point at the end of the next `\\end' that is unended." |
"Leave point at the end of the next `\\end' that is unended." |
1288 |
(while (and (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}") |
(while (and (tex-search-noncomment |
1289 |
|
(re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}")) |
1290 |
(save-excursion (goto-char (match-beginning 0)) |
(save-excursion (goto-char (match-beginning 0)) |
1291 |
(looking-at "\\\\begin"))) |
(looking-at "\\\\begin"))) |
1292 |
(tex-next-unmatched-end))) |
(tex-next-unmatched-end))) |
1826 |
;; FIXME: Use time-stamps on files to decide the next op. |
;; FIXME: Use time-stamps on files to decide the next op. |
1827 |
(interactive |
(interactive |
1828 |
(let* ((file (tex-main-file)) |
(let* ((file (tex-main-file)) |
1829 |
(dir (prog1 (file-name-directory (expand-file-name file)) |
(default-directory |
1830 |
(setq file (file-name-nondirectory file)))) |
(prog1 (file-name-directory (expand-file-name file)) |
1831 |
|
(setq file (file-name-nondirectory file)))) |
1832 |
(root (file-name-sans-extension file)) |
(root (file-name-sans-extension file)) |
1833 |
(fspec (list (cons ?r (comint-quote-filename root)) |
(fspec (list (cons ?r (comint-quote-filename root)) |
1834 |
(cons ?f (comint-quote-filename file)))) |
(cons ?f (comint-quote-filename file)))) |
1835 |
(default (tex-compile-default fspec))) |
(default (tex-compile-default fspec))) |
1836 |
(list dir |
(list default-directory |
1837 |
(completing-read |
(completing-read |
1838 |
(format "Command [%s]: " (tex-summarize-command default)) |
(format "Command [%s]: " (tex-summarize-command default)) |
1839 |
(mapcar (lambda (x) |
(mapcar (lambda (x) |