emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/reftex-toc.el


From: Carsten Dominik
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/reftex-toc.el
Date: Tue, 27 Aug 2002 05:54:42 -0400

Index: emacs/lisp/textmodes/reftex-toc.el
diff -c emacs/lisp/textmodes/reftex-toc.el:1.14 
emacs/lisp/textmodes/reftex-toc.el:1.15
*** emacs/lisp/textmodes/reftex-toc.el:1.14     Thu Jul 25 03:03:41 2002
--- emacs/lisp/textmodes/reftex-toc.el  Tue Aug 27 05:54:41 2002
***************
*** 95,101 ****
  q / k      Hide/Kill *toc* buffer, return to position of reftex-toc command.
  l i c F    Toggle display of  [l]abels,  [i]ndex,  [c]ontext,  [F]ile borders.
  t          Change maximum toc depth (e.g. `3 t' hides levels greater than 3).
! f / g      Toggle follow mode on and off  / Refresh *toc* buffer.
  r / C-u r  Reparse the LaTeX document     / Reparse entire LaTeX document.
  .          In other window, show position from where `reftex-toc' was called.
  x          Switch to TOC of external document (with LaTeX package `xr').
--- 95,101 ----
  q / k      Hide/Kill *toc* buffer, return to position of reftex-toc command.
  l i c F    Toggle display of  [l]abels,  [i]ndex,  [c]ontext,  [F]ile borders.
  t          Change maximum toc depth (e.g. `3 t' hides levels greater than 3).
! f / a / g  Toggle follow mode / toggle auto recenter / Refresh *toc* buffer.
  r / C-u r  Reparse the LaTeX document     / Reparse entire LaTeX document.
  .          In other window, show position from where `reftex-toc' was called.
  x          Switch to TOC of external document (with LaTeX package `xr').
***************
*** 132,138 ****
         (docstruct-symbol reftex-docstruct-symbol)
         (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
         (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
!        (here-I-am (if rebuild
                        (get 'reftex-toc :reftex-data)
                      (car (reftex-where-am-I))))
         offset)
--- 132,138 ----
         (docstruct-symbol reftex-docstruct-symbol)
         (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
         (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
!        (here-I-am (if (boundp 'reftex-rebuilding-toc)
                        (get 'reftex-toc :reftex-data)
                      (car (reftex-where-am-I))))
         offset)
***************
*** 218,227 ****
      (reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line))
      (setq reftex-last-follow-point (point))))
  
  (defun reftex-toc-pre-command-hook ()
    ;; used as pre command hook in *toc* buffer
    (reftex-unhighlight 0)
!   (reftex-unhighlight 1))
  
  (defun reftex-toc-post-command-hook ()
    ;; used in the post-command-hook for the *toc* buffer
--- 218,248 ----
      (reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line))
      (setq reftex-last-follow-point (point))))
  
+ (defun reftex-toc-recenter (&optional arg)
+   "Display the TOC window and highlight line corresponding to current 
position."
+   (interactive "P")
+   (let ((buf (current-buffer)))
+     (reftex-toc arg)
+     (if (= (count-lines 1 (point)) 2)
+       (let ((current-prefix-arg nil))
+         (select-window (get-buffer-window buf))
+         (reftex-toc nil)))
+     (and (> (point) 1)
+        (not (get-text-property (point) 'intangible))
+        (memq reftex-highlight-selection '(cursor both))
+        (reftex-highlight 2
+          (or (previous-single-property-change 
+               (min (point-max) (1+ (point))) :data)
+              (point-min))
+          (or (next-single-property-change (point) :data)
+              (point-max))))
+     (select-window (get-buffer-window buf))))
+ 
  (defun reftex-toc-pre-command-hook ()
    ;; used as pre command hook in *toc* buffer
    (reftex-unhighlight 0)
! ;;  (reftex-unhighlight 1)  ;; remove highlight on leaving buffer.
!   )
  
  (defun reftex-toc-post-command-hook ()
    ;; used in the post-command-hook for the *toc* buffer
***************
*** 230,236 ****
      (and (> (point) 1)
         (not (get-text-property (point) 'intangible))
         (memq reftex-highlight-selection '(cursor both))
!        (reftex-highlight 1
           (or (previous-single-property-change (1+ (point)) :data)
               (point-min))
           (or (next-single-property-change (point) :data)
--- 251,257 ----
      (and (> (point) 1)
         (not (get-text-property (point) 'intangible))
         (memq reftex-highlight-selection '(cursor both))
!        (reftex-highlight 2
           (or (previous-single-property-change (1+ (point)) :data)
               (point-min))
           (or (next-single-property-change (point) :data)
***************
*** 410,425 ****
            (switch-to-buffer-other-window
             (reftex-get-file-buffer-force file))
          (setq current-prefix-arg '(4))
!           (reftex-toc t)))
      (reftex-toc-Rescan))
    (reftex-kill-temporary-buffers))
  (defun reftex-toc-Rescan (&rest ignore)
    "Regenerate the *toc* buffer by reparsing the entire document."
    (interactive)
    (switch-to-buffer-other-window
     (reftex-get-file-buffer-force reftex-last-toc-file))
    (setq current-prefix-arg '(16))
!   (reftex-toc t))
  (defun reftex-toc-revert (&rest ignore)
    "Regenerate the *toc* from the internal lists."
    (interactive)
--- 431,450 ----
            (switch-to-buffer-other-window
             (reftex-get-file-buffer-force file))
          (setq current-prefix-arg '(4))
!         (let ((reftex-rebuilding-toc t))
!           (reftex-toc))))
      (reftex-toc-Rescan))
    (reftex-kill-temporary-buffers))
  (defun reftex-toc-Rescan (&rest ignore)
    "Regenerate the *toc* buffer by reparsing the entire document."
    (interactive)
+   (let* ((line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
+     (put 'reftex-toc :reftex-line line))
    (switch-to-buffer-other-window
     (reftex-get-file-buffer-force reftex-last-toc-file))
    (setq current-prefix-arg '(16))
!   (let ((reftex-rebuilding-toc t))
!     (reftex-toc)))
  (defun reftex-toc-revert (&rest ignore)
    "Regenerate the *toc* from the internal lists."
    (interactive)
***************
*** 427,433 ****
     (reftex-get-file-buffer-force reftex-last-toc-file))
    (reftex-erase-buffer "*toc*")
    (setq current-prefix-arg nil)
!   (reftex-toc t))
  (defun reftex-toc-external (&rest ignore)
    "Switch to table of contents of an external document."
    (interactive)
--- 452,459 ----
     (reftex-get-file-buffer-force reftex-last-toc-file))
    (reftex-erase-buffer "*toc*")
    (setq current-prefix-arg nil)
!   (let ((reftex-rebuilding-toc t))
!     (reftex-toc t)))
  (defun reftex-toc-external (&rest ignore)
    "Switch to table of contents of an external document."
    (interactive)
***************
*** 573,578 ****
--- 599,636 ----
        (setq old (substring old (match-end 0))))
      new))
  
+ 
+ (defun reftex-recenter-toc-when-idle ()
+   (and (> (buffer-size) 5)
+        reftex-mode
+        (not (active-minibuffer-window))
+        (fboundp 'reftex-toc-mode)
+        (get-buffer-window "*toc*")
+        (string= reftex-last-toc-master (reftex-TeX-master-file))
+        (reftex-toc-recenter)))
+ 
+ (defun reftex-toggle-auto-toc-recenter ()
+   "Toggle the automatic recentering of the toc window.
+ When active, leaving point idle will make the toc window jump to the correct
+ section."
+   (interactive)
+   (if reftex-toc-auto-recenter-timer
+       (progn
+       (if (featurep 'xemacs)
+           (delete-itimer reftex-toc-auto-recenter-timer)
+         (cancel-timer reftex-toc-auto-recenter-timer))
+       (setq reftex-toc-auto-recenter-timer nil)
+       (message "Automatic recentering of toc buffer was turned off"))
+     (setq reftex-toc-auto-recenter-timer
+         (if (featurep 'xemacs)
+             (start-itimer "RefTeX Idle Timer for recenter"
+                           'reftex-recenter-toc-when-idle
+                           reftex-idle-time reftex-idle-time t)
+           (run-with-idle-timer
+            reftex-idle-time t 'reftex-recenter-toc-when-idle)))
+     (message "Automatic recentering of toc window was turned on")))
+ 
+ 
  ;; Table of Contents map
  (define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
    'reftex-toc-mouse-goto-line-and-hide)
***************
*** 596,601 ****
--- 654,660 ----
        ("q"    . reftex-toc-quit)
        ("k"    . reftex-toc-quit-and-kill)
        ("f"    . reftex-toc-toggle-follow)
+       ("a"    . reftex-toggle-auto-toc-recenter)
        ("F"    . reftex-toc-toggle-file-boundary)
        ("i"    . reftex-toc-toggle-index)
        ("l"    . reftex-toc-toggle-labels)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]