Mercurial > emacs
comparison lisp/textmodes/reftex-parse.el @ 110450:9b627013b805
* lisp/textmodes/reftex-parse.el (reftex-what-macro)
(reftex-context-substring): Let-bind forward-sexp-function to nil
since we don't need/want to treat \begin...\end as a block.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 21 Sep 2010 00:42:47 +0200 |
parents | 6cf93d8fc391 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
110449:45304f108596 | 110450:9b627013b805 |
---|---|
383 (setcdr (nthcdr (1- (length new)) new) (cdr eof-list))) | 383 (setcdr (nthcdr (1- (length new)) new) (cdr eof-list))) |
384 new)))) | 384 new)))) |
385 | 385 |
386 (defun reftex-section-info (file) | 386 (defun reftex-section-info (file) |
387 ;; Return a section entry for the current match. | 387 ;; Return a section entry for the current match. |
388 ;; Carefull: This function expects the match-data to be still in place! | 388 ;; Careful: This function expects the match-data to be still in place! |
389 (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) | 389 (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) |
390 (macro (reftex-match-string 3)) | 390 (macro (reftex-match-string 3)) |
391 (prefix (save-match-data | 391 (prefix (save-match-data |
392 (if (string-match "begin{\\([^}]+\\)}" macro) | 392 (if (string-match "begin{\\([^}]+\\)}" macro) |
393 (match-string 1 macro)))) | 393 (match-string 1 macro)))) |
776 (save-restriction | 776 (save-restriction |
777 (save-excursion | 777 (save-excursion |
778 (narrow-to-region (max (point-min) bound) (point-max)) | 778 (narrow-to-region (max (point-min) bound) (point-max)) |
779 ;; move back out of the current parenthesis | 779 ;; move back out of the current parenthesis |
780 (while (condition-case nil | 780 (while (condition-case nil |
781 (progn (up-list -1) t) | 781 (let ((forward-sexp-function nil)) |
782 (up-list -1) t) | |
782 (error nil)) | 783 (error nil)) |
783 (setq cnt 1 cnt-opt 0) | 784 (setq cnt 1 cnt-opt 0) |
784 ;; move back over any touching sexps | 785 ;; move back over any touching sexps |
785 (while (and (reftex-move-to-previous-arg bound) | 786 (while (and (reftex-move-to-previous-arg bound) |
786 (condition-case nil | 787 (condition-case nil |
787 (progn (backward-sexp) t) | 788 (let ((forward-sexp-function nil)) |
789 (backward-sexp) t) | |
788 (error nil))) | 790 (error nil))) |
789 (if (eq (following-char) ?\[) (incf cnt-opt)) | 791 (if (eq (following-char) ?\[) (incf cnt-opt)) |
790 (incf cnt)) | 792 (incf cnt)) |
791 (setq pos (point)) | 793 (setq pos (point)) |
792 (when (and (or (= (following-char) ?\[) | 794 (when (and (or (= (following-char) ?\[) |
963 (save-match-data | 965 (save-match-data |
964 ;; FIXME: This is not perfect | 966 ;; FIXME: This is not perfect |
965 (if (re-search-forward "\\\\end{" nil t) | 967 (if (re-search-forward "\\\\end{" nil t) |
966 (match-beginning 0) | 968 (match-beginning 0) |
967 (point-max)))))) | 969 (point-max)))))) |
968 ((or (= (preceding-char) ?\{) | 970 ((memq (preceding-char) '(?\{ ?\[)) |
969 (= (preceding-char) ?\[)) | |
970 ;; Inside a list - get only the list. | 971 ;; Inside a list - get only the list. |
971 (buffer-substring-no-properties | 972 (buffer-substring-no-properties |
972 (point) | 973 (point) |
973 (min (+ (point) 150) | 974 (min (+ (point) 150) |
974 (point-max) | 975 (point-max) |
975 (condition-case nil | 976 (condition-case nil |
976 (progn | 977 (let ((forward-sexp-function nil)) ;Unneeded fanciness. |
977 (up-list 1) | 978 (up-list 1) |
978 (1- (point))) | 979 (1- (point))) |
979 (error (point-max)))))) | 980 (error (point-max)))))) |
980 (t | 981 (t |
981 ;; no list - just grab 150 characters | 982 ;; no list - just grab 150 characters |