comparison lisp/textmodes/reftex-ref.el @ 49599:5ade352e8d1c

Trailing whitespace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 13:30:45 +0000
parents 904fd28be439
children 78aa91f765c9 d7ddb3e565de
comparison
equal deleted inserted replaced
49598:0d8b17d428b5 49599:5ade352e8d1c
163 (string-match "SECTION HEADING NOT FOUND" default) 163 (string-match "SECTION HEADING NOT FOUND" default)
164 (string-match "HOOK ERROR" default) 164 (string-match "HOOK ERROR" default)
165 (string-match "^[ \t]*$" default)) 165 (string-match "^[ \t]*$" default))
166 (setq default prefix 166 (setq default prefix
167 force-prompt t) ; need to prompt 167 force-prompt t) ; need to prompt
168 (setq default 168 (setq default
169 (concat prefix 169 (concat prefix
170 (funcall reftex-string-to-label-function default))) 170 (funcall reftex-string-to-label-function default)))
171 171
172 ;; Make it unique. 172 ;; Make it unique.
173 (setq default (reftex-uniquify-label default nil "-")))) 173 (setq default (reftex-uniquify-label default nil "-"))))
174 174
210 210
211 ;; Look it up in the label list 211 ;; Look it up in the label list
212 ((setq entry (assoc label 212 ((setq entry (assoc label
213 (symbol-value reftex-docstruct-symbol))) 213 (symbol-value reftex-docstruct-symbol)))
214 (ding) 214 (ding)
215 (if (y-or-n-p 215 (if (y-or-n-p
216 (format "Label '%s' exists. Use anyway? " label)) 216 (format "Label '%s' exists. Use anyway? " label))
217 (setq valid t))) 217 (setq valid t)))
218 218
219 ;; Label is ok 219 ;; Label is ok
220 (t 220 (t
221 (setq valid t)))) 221 (setq valid t))))
222 (setq label default)) 222 (setq label default))
223 223
224 ;; Insert the label into the label list 224 ;; Insert the label into the label list
225 (let* ((here-I-am-info 225 (let* ((here-I-am-info
226 (save-excursion 226 (save-excursion
227 (if (and (or naked no-insert) 227 (if (and (or naked no-insert)
228 (integerp (cdr macro-cell))) 228 (integerp (cdr macro-cell)))
229 (goto-char (cdr macro-cell))) 229 (goto-char (cdr macro-cell)))
230 (reftex-where-am-I))) 230 (reftex-where-am-I)))
231 (here-I-am (car here-I-am-info)) 231 (here-I-am (car here-I-am-info))
232 (note (if (cdr here-I-am-info) 232 (note (if (cdr here-I-am-info)
277 277
278 (defun reftex-latin1-to-ascii (string) 278 (defun reftex-latin1-to-ascii (string)
279 ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents 279 ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents
280 (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy") 280 (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy")
281 (emacsp (not (featurep 'xemacs)))) 281 (emacsp (not (featurep 'xemacs))))
282 (mapconcat 282 (mapconcat
283 (lambda (c) 283 (lambda (c)
284 (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1 284 (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1
285 (char-to-string (aref tab (- c 128)))) 285 (char-to-string (aref tab (- c 128))))
286 ((and emacsp ; Not for XEmacs 286 ((and emacsp ; Not for XEmacs
287 (> c 2175) (< c 2304)) ; Mule Latin-1 287 (> c 2175) (< c 2304)) ; Mule Latin-1
405 (setq type (reftex-guess-label-type))) 405 (setq type (reftex-guess-label-type)))
406 (setq cut (cdr type) 406 (setq cut (cdr type)
407 type (car type)) 407 type (car type))
408 (setq type (reftex-query-label-type)))) 408 (setq type (reftex-query-label-type))))
409 409
410 (let* ((refstyle 410 (let* ((refstyle
411 (cond ((reftex-typekey-check type reftex-vref-is-default) "\\vref") 411 (cond ((reftex-typekey-check type reftex-vref-is-default) "\\vref")
412 ((reftex-typekey-check type reftex-fref-is-default) "\\fref") 412 ((reftex-typekey-check type reftex-fref-is-default) "\\fref")
413 (t "\\ref"))) 413 (t "\\ref")))
414 (reftex-format-ref-function reftex-format-ref-function) 414 (reftex-format-ref-function reftex-format-ref-function)
415 (form "\\ref{%s}") 415 (form "\\ref{%s}")
427 (setq labels (list (list (mapconcat 'car (cdr labels) ",") 427 (setq labels (list (list (mapconcat 'car (cdr labels) ",")
428 (cdr (nth 1 labels)))))) 428 (cdr (nth 1 labels))))))
429 (setq type (nth 1 (car labels)) 429 (setq type (nth 1 (car labels))
430 form (or (cdr (assoc type reftex-typekey-to-format-alist)) 430 form (or (cdr (assoc type reftex-typekey-to-format-alist))
431 form)) 431 form))
432 432
433 (cond 433 (cond
434 (no-insert 434 (no-insert
435 ;; Just return the first label 435 ;; Just return the first label
436 (car (car labels))) 436 (car (car labels)))
437 ((null labels) 437 ((null labels)
441 (while labels 441 (while labels
442 (setq label (car (car labels)) 442 (setq label (car (car labels))
443 sep (nth 2 (car labels)) 443 sep (nth 2 (car labels))
444 sep1 (cdr (assoc sep reftex-multiref-punctuation)) 444 sep1 (cdr (assoc sep reftex-multiref-punctuation))
445 labels (cdr labels)) 445 labels (cdr labels))
446 (when cut 446 (when cut
447 (backward-delete-char cut) 447 (backward-delete-char cut)
448 (setq cut nil)) 448 (setq cut nil))
449 449
450 ;; remove ~ if we do already have a space 450 ;; remove ~ if we do already have a space
451 (when (and (= ?~ (string-to-char form)) 451 (when (and (= ?~ (string-to-char form))
476 (case-fold-search t) 476 (case-fold-search t)
477 (bound (max (point-min) (- (point) 35))) 477 (bound (max (point-min) (- (point) 35)))
478 matched cell) 478 matched cell)
479 (save-excursion 479 (save-excursion
480 (while (and (setq cell (pop words)) 480 (while (and (setq cell (pop words))
481 (not (setq matched 481 (not (setq matched
482 (re-search-backward (car cell) bound t)))))) 482 (re-search-backward (car cell) bound t))))))
483 (if matched 483 (if matched
484 (cons (cdr cell) (- (match-end 0) (match-end 1))) 484 (cons (cdr cell) (- (match-end 0) (match-end 1)))
485 nil))) 485 nil)))
486 486
541 nil ; index 541 nil ; index
542 files 542 files
543 context 543 context
544 counter 544 counter
545 commented 545 commented
546 (or here-I-am offset) 546 (or here-I-am offset)
547 prefix 547 prefix
548 nil ; no a toc buffer 548 nil ; no a toc buffer
549 )))) 549 ))))
550 (here-I-am 550 (here-I-am
551 (setq offset (reftex-get-offset buf here-I-am typekey))) 551 (setq offset (reftex-get-offset buf here-I-am typekey)))
552 (t (setq offset t))) 552 (t (setq offset t)))
553 (setq buffer-read-only t) 553 (setq buffer-read-only t)
638 (throw 'exit t)) 638 (throw 'exit t))
639 (t (error "This should not happen (reftex-offer-label-menu)")))))) 639 (t (error "This should not happen (reftex-offer-label-menu)"))))))
640 (save-excursion 640 (save-excursion
641 (while reftex-buffers-with-changed-invisibility 641 (while reftex-buffers-with-changed-invisibility
642 (set-buffer (car (car reftex-buffers-with-changed-invisibility))) 642 (set-buffer (car (car reftex-buffers-with-changed-invisibility)))
643 (setq buffer-invisibility-spec 643 (setq buffer-invisibility-spec
644 (cdr (pop reftex-buffers-with-changed-invisibility))))) 644 (cdr (pop reftex-buffers-with-changed-invisibility)))))
645 (mapcar (lambda (buf) (and (buffer-live-p buf) (bury-buffer buf))) 645 (mapcar (lambda (buf) (and (buffer-live-p buf) (bury-buffer buf)))
646 selection-buffers) 646 selection-buffers)
647 (reftex-kill-temporary-buffers)) 647 (reftex-kill-temporary-buffers))
648 ;; Add the prefixes, put together the relevant information in the form 648 ;; Add the prefixes, put together the relevant information in the form
667 (file (nth 3 data))) 667 (file (nth 3 data)))
668 (reftex-access-scan-info arg file))))) 668 (reftex-access-scan-info arg file)))))
669 669
670 (defun reftex-query-label-type () 670 (defun reftex-query-label-type ()
671 ;; Ask for label type 671 ;; Ask for label type
672 (let ((key (reftex-select-with-char 672 (let ((key (reftex-select-with-char
673 reftex-type-query-prompt reftex-type-query-help 3))) 673 reftex-type-query-prompt reftex-type-query-help 3)))
674 (unless (member (char-to-string key) reftex-typekey-list) 674 (unless (member (char-to-string key) reftex-typekey-list)
675 (error "No such label type: %s" (char-to-string key))) 675 (error "No such label type: %s" (char-to-string key)))
676 (char-to-string key))) 676 (char-to-string key)))
677 677
678 (defun reftex-show-label-location (data forward no-revisit 678 (defun reftex-show-label-location (data forward no-revisit
679 &optional stay error) 679 &optional stay error)
680 ;; View the definition site of a label in another window. 680 ;; View the definition site of a label in another window.
681 ;; DATA is an entry from the docstruct list. 681 ;; DATA is an entry from the docstruct list.
682 ;; FORWARD indicates if the label is likely forward from current point. 682 ;; FORWARD indicates if the label is likely forward from current point.
683 ;; NO-REVISIT means do not load a file to show this label. 683 ;; NO-REVISIT means do not load a file to show this label.
695 (unless file 695 (unless file
696 (funcall errorf "Unknown label - reparse might help") 696 (funcall errorf "Unknown label - reparse might help")
697 (throw 'exit nil)) 697 (throw 'exit nil))
698 698
699 ;; Goto the file in another window 699 ;; Goto the file in another window
700 (setq buffer 700 (setq buffer
701 (if no-revisit 701 (if no-revisit
702 (reftex-get-buffer-visiting file) 702 (reftex-get-buffer-visiting file)
703 (reftex-get-file-buffer-force 703 (reftex-get-file-buffer-force
704 file (not reftex-keep-temporary-buffers)))) 704 file (not reftex-keep-temporary-buffers))))
705 (if buffer 705 (if buffer
761 (reftex-highlight 0 (1+ (- beg-hlt beg)) (1+ (- end-hlt beg))) 761 (reftex-highlight 0 (1+ (- beg-hlt beg)) (1+ (- end-hlt beg)))
762 (if (reftex-refontify) 762 (if (reftex-refontify)
763 (when (or (not (eq major-mode 'latex-mode)) 763 (when (or (not (eq major-mode 'latex-mode))
764 (not font-lock-mode)) 764 (not font-lock-mode))
765 (latex-mode) 765 (latex-mode)
766 (run-hook-with-args 766 (run-hook-with-args
767 'reftex-pre-refontification-functions 767 'reftex-pre-refontification-functions
768 reftex-call-back-to-this-buffer 'reftex-hidden) 768 reftex-call-back-to-this-buffer 'reftex-hidden)
769 (turn-on-font-lock)) 769 (turn-on-font-lock))
770 (when (or (not (eq major-mode 'fundamental-mode)) 770 (when (or (not (eq major-mode 'fundamental-mode))
771 font-lock-mode) 771 font-lock-mode)
827 (reftex-show-label-location selection t nil 'stay) 827 (reftex-show-label-location selection t nil 'stay)
828 (point-marker)))) 828 (point-marker))))
829 (unless other-window 829 (unless other-window
830 (set-window-configuration wcfg) 830 (set-window-configuration wcfg)
831 (switch-to-buffer (marker-buffer where)) 831 (switch-to-buffer (marker-buffer where))
832 (goto-char where)) 832 (goto-char where))
833 (reftex-unhighlight 0))) 833 (reftex-unhighlight 0)))
834 834
835 835
836 836
837 ;;; reftex-ref.el ends here 837 ;;; reftex-ref.el ends here