comparison lisp/textmodes/reftex-parse.el @ 47050:904fd28be439

Update to RefTeX 4.19
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 27 Aug 2002 09:58:05 +0000
parents 060f433ebf11
children 5ade352e8d1c
comparison
equal deleted inserted replaced
47049:b383699b81b6 47050:904fd28be439
549 ;; Return the docstruct entry above point. Actually returns a cons 549 ;; Return the docstruct entry above point. Actually returns a cons
550 ;; cell in which the cdr is a flag indicating if the information is 550 ;; cell in which the cdr is a flag indicating if the information is
551 ;; exact (t) or approximate (nil). 551 ;; exact (t) or approximate (nil).
552 552
553 (let ((docstruct (symbol-value reftex-docstruct-symbol)) 553 (let ((docstruct (symbol-value reftex-docstruct-symbol))
554 (cnt 0) rtn 554 (cnt 0) rtn rtn-if-no-other
555 found) 555 found)
556 (save-excursion 556 (save-excursion
557 (while (not rtn) 557 (while (not rtn)
558 (incf cnt) 558 (incf cnt)
559 (setq found (re-search-backward (reftex-everything-regexp) nil t)) 559 (setq found (re-search-backward (reftex-everything-regexp) nil t))
589 (nth 8 (car list)))) 589 (nth 8 (car list))))
590 ;; Fits with marker position or recorded position 590 ;; Fits with marker position or recorded position
591 (setq rtn1 (car list) list nil)) 591 (setq rtn1 (car list) list nil))
592 ((looking-at (reftex-make-regexp-allow-for-ctrl-m 592 ((looking-at (reftex-make-regexp-allow-for-ctrl-m
593 (nth 7 (car list)))) 593 (nth 7 (car list))))
594 ;; Same title 594 ;; Same title: remember, but keep looking
595 (setq rtn1 (car list) list nil cnt 2)))) 595 (setq rtn-if-no-other (car list)))))
596 (pop list)) 596 (pop list))
597 rtn1)) 597 rtn1))
598 ((match-end 7) 598 ((match-end 7)
599 ;; Input or include... 599 ;; Input or include...
600 (car 600 (car
635 (reftex-nth-arg-wrapper 635 (reftex-nth-arg-wrapper
636 (reftex-match-string 11))) 636 (reftex-match-string 11)))
637 (symbol-value reftex-docstruct-symbol)))) 637 (symbol-value reftex-docstruct-symbol))))
638 (t 638 (t
639 (error "This should not happen (reftex-where-am-I)")))))) 639 (error "This should not happen (reftex-where-am-I)"))))))
640 ;; Check if there was only a by-name match for the section.
641 (when (and (not rtn) rtn-if-no-other)
642 (setq rtn rtn-if-no-other
643 cnt 2))
640 (cons rtn (eq cnt 1)))) 644 (cons rtn (eq cnt 1))))
641 645
642 (defun reftex-notice-new (&optional n force) 646 (defun reftex-notice-new (&optional n force)
643 "Hook to handshake with RefTeX after something new has been inserted." 647 "Hook to handshake with RefTeX after something new has been inserted."
644 ;; Add a new entry to the docstruct list. If it is a section, renumber 648 ;; Add a new entry to the docstruct list. If it is a section, renumber
1000 1004
1001 (defun reftex-section-number (&optional level star) 1005 (defun reftex-section-number (&optional level star)
1002 ;; Return a string with the current section number. 1006 ;; Return a string with the current section number.
1003 ;; When LEVEL is non-nil, increase section numbers on that level. 1007 ;; When LEVEL is non-nil, increase section numbers on that level.
1004 (let* ((depth (1- (length reftex-section-numbers))) idx n (string "") 1008 (let* ((depth (1- (length reftex-section-numbers))) idx n (string "")
1005 (appendix (get 'reftex-section-numbers 'appendix))) 1009 (appendix (get 'reftex-section-numbers 'appendix))
1010 (partspecial (and (not reftex-part-resets-chapter)
1011 (equal level 0))))
1012 ;; partspecial means, this is a part statement.
1013 ;; Parts do not reset the chapter counter, and the part number is
1014 ;; not included in the numbering of other sectioning levels.
1006 (when level 1015 (when level
1007 (when (and (> level -1) (not star)) 1016 (when (and (> level -1) (not star))
1008 (aset reftex-section-numbers 1017 (aset reftex-section-numbers
1009 level (1+ (aref reftex-section-numbers level)))) 1018 level (1+ (aref reftex-section-numbers level))))
1010 (setq idx (1+ level)) 1019 (setq idx (1+ level))
1011 (when (not star) 1020 (when (not star)
1012 (while (<= idx depth) 1021 (while (<= idx depth)
1013 (aset reftex-section-numbers idx 0) 1022 (if (or (not partspecial)
1023 (not (= idx 1)))
1024 (aset reftex-section-numbers idx 0))
1014 (incf idx)))) 1025 (incf idx))))
1015 (setq idx 0) 1026 (if partspecial
1016 (while (<= idx depth) 1027 (setq string (concat "Part " (reftex-roman-number
1017 (setq n (aref reftex-section-numbers idx)) 1028 (aref reftex-section-numbers 0))))
1018 (setq string (concat string (if (not (string= string "")) "." "") 1029 (setq idx (if reftex-part-resets-chapter 0 1))
1019 (int-to-string n))) 1030 (while (<= idx depth)
1020 (incf idx)) 1031 (setq n (aref reftex-section-numbers idx))
1021 (save-match-data 1032 (if (not (and partspecial (not (equal string ""))))
1022 (if (string-match "\\`\\([@0]\\.\\)+" string) 1033 (setq string (concat string (if (not (string= string "")) "." "")
1023 (setq string (replace-match "" nil nil string))) 1034 (int-to-string n))))
1024 (if (string-match "\\(\\.0\\)+\\'" string) 1035 (incf idx))
1025 (setq string (replace-match "" nil nil string))) 1036 (save-match-data
1026 (if (and appendix 1037 (if (string-match "\\`\\([@0]\\.\\)+" string)
1027 (string-match "\\`[0-9]+" string)) 1038 (setq string (replace-match "" nil nil string)))
1028 (setq string 1039 (if (string-match "\\(\\.0\\)+\\'" string)
1029 (concat 1040 (setq string (replace-match "" nil nil string)))
1030 (char-to-string 1041 (if (and appendix
1031 (1- (+ ?A (string-to-int (match-string 0 string))))) 1042 (string-match "\\`[0-9]+" string))
1032 (substring string (match-end 0)))))) 1043 (setq string
1033 (if star 1044 (concat
1034 (concat (make-string (1- (length string)) ?\ ) "*") 1045 (char-to-string
1035 string))) 1046 (1- (+ ?A (string-to-int (match-string 0 string)))))
1047 (substring string (match-end 0))))))
1048 (if star
1049 (concat (make-string (1- (length string)) ?\ ) "*")
1050 string))))
1051
1052 (defun reftex-roman-number (n)
1053 ;; Return as a string the roman number equal to N.
1054 (let ((nrest n)
1055 (string "")
1056 (list '((1000 . "M") ( 900 . "CM") ( 500 . "D") ( 400 . "CD")
1057 ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
1058 ( 10 . "X") ( 9 . "IX") ( 5 . "V") ( 4 . "IV")
1059 ( 1 . "I")))
1060 listel i s)
1061 (while (>= nrest 1)
1062 (setq listel (pop list)
1063 i (car listel)
1064 s (cdr listel))
1065 (while (>= nrest i)
1066 (setq string (concat string s)
1067 nrest (- nrest i))))
1068 string))
1036 1069
1037 ;;; reftex-parse.el ends here 1070 ;;; reftex-parse.el ends here