/[emacs]/emacs/lisp/textmodes/reftex-toc.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/reftex-toc.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by lektu, Wed Aug 31 10:34:40 2005 UTC revision 1.29 by cdominik, Fri Sep 16 10:01:33 2005 UTC
# Line 1  Line 1 
1  ;;; reftex-toc.el --- RefTeX's table of contents mode  ;;; reftex-toc.el --- RefTeX's table of contents mode
2    ;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
3  ;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,  ;;  Free Software Foundation, Inc.
 ;;   2005 Free Software Foundation, Inc.  
4    
5  ;; Author: Carsten Dominik <dominik@science.uva.nl>  ;; Author: Carsten Dominik <dominik@science.uva.nl>
6  ;; Version: 4.28  ;; Version: VERSIONTAG
7    
8  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
9    
# Line 20  Line 19 
19    
20  ;; You should have received a copy of the GNU General Public License  ;; You should have received a copy of the GNU General Public License
21  ;; along with GNU Emacs; see the file COPYING.  If not, write to the  ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22  ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  ;; Boston, MA 02110-1301, USA.  ;; Boston, MA 02111-1307, USA.
24    
25  ;;; Commentary:  ;;; Commentary:
26    
# Line 36  Line 35 
35    "Keymap used for *toc* buffer.")    "Keymap used for *toc* buffer.")
36    
37  (defvar reftex-toc-menu)  (defvar reftex-toc-menu)
38  (defvar zmacs-regions)  (eval-when-compile (defvar zmacs-regions))
39    (defvar reftex-last-window-height nil)
40    (defvar reftex-last-window-width nil)
41  (defvar reftex-toc-include-labels-indicator nil)  (defvar reftex-toc-include-labels-indicator nil)
42  (defvar reftex-toc-include-index-indicator nil)  (defvar reftex-toc-include-index-indicator nil)
43  (defvar reftex-toc-max-level-indicator nil)  (defvar reftex-toc-max-level-indicator nil)
# Line 79  Here are all local bindings. Line 79  Here are all local bindings.
79    (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)    (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
80    (add-hook 'pre-command-hook  'reftex-toc-pre-command-hook nil t)    (add-hook 'pre-command-hook  'reftex-toc-pre-command-hook nil t)
81    (easy-menu-add reftex-toc-menu reftex-toc-map)    (easy-menu-add reftex-toc-menu reftex-toc-map)
82    (run-mode-hooks 'reftex-toc-mode-hook))    (run-hooks 'reftex-toc-mode-hook))
83    
84  (defvar reftex-last-toc-file nil  (defvar reftex-last-toc-file nil
85    "Stores the file name from which `reftex-toc' was called.  For redo command.")    "Stores the file name from which `reftex-toc' was called.  For redo command.")
86    
 (defvar reftex-last-window-height nil)  
 (defvar reftex-last-window-width nil)  
87    
88  (defvar reftex-toc-return-marker (make-marker)  (defvar reftex-toc-return-marker (make-marker)
89    "Marker which makes it possible to return from toc to old position.")    "Marker which makes it possible to return from toc to old position.")
# Line 152  When called with a raw C-u prefix, resca Line 150  When called with a raw C-u prefix, resca
150                           (frame-parameter (selected-frame) 'unsplittable)))                           (frame-parameter (selected-frame) 'unsplittable)))
151           offset toc-window)           offset toc-window)
152    
153      (if (setq toc-window (get-buffer-window      (if (setq toc-window (get-buffer-window
154                            "*toc*"                            "*toc*"
155                            (if reuse 'visible)))                            (if reuse 'visible)))
156          (select-window toc-window)          (select-window toc-window)
# Line 168  When called with a raw C-u prefix, resca Line 166  When called with a raw C-u prefix, resca
166              (split-window-horizontally              (split-window-horizontally
167               (floor (* (window-width)               (floor (* (window-width)
168                         reftex-toc-split-windows-fraction)))                         reftex-toc-split-windows-fraction)))
169            (split-window-vertically            (split-window-vertically
170             (floor (* (window-height)             (floor (* (window-height)
171                       reftex-toc-split-windows-fraction)))))                       reftex-toc-split-windows-fraction)))))
172    
# Line 213  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 211  SPC=view TAB=goto RET=goto+hide [q]uit [
211               reftex-toc-include-context               reftex-toc-include-context
212               nil ; counter               nil ; counter
213               nil ; commented               nil ; commented
214               here-I-am               here-I-am
215               ""     ; xr-prefix               ""     ; xr-prefix
216               t      ; a toc buffer               t      ; a toc buffer
217               ))               ))
218          
219        (run-hooks 'reftex-display-copied-context-hook)        (run-hooks 'reftex-display-copied-context-hook)
220        (message "Building *toc* buffer...done.")        (message "Building *toc* buffer...done.")
221        (setq buffer-read-only t))        (setq buffer-read-only t))
# Line 229  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 227  SPC=view TAB=goto RET=goto+hide [q]uit [
227                                     t                                     t
228                                     reftex-toc-include-index-entries                                     reftex-toc-include-index-entries
229                                     reftex-toc-include-file-boundaries)                                     reftex-toc-include-file-boundaries)
230                  (reftex-last-assoc-before-elt                  (reftex-last-assoc-before-elt
231                   'toc here-I-am                   'toc here-I-am
232                   (symbol-value reftex-docstruct-symbol))))                   (symbol-value reftex-docstruct-symbol))))
233        (put 'reftex-toc :reftex-line 3)        (put 'reftex-toc :reftex-line 3)
# Line 254  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 252  SPC=view TAB=goto RET=goto+hide [q]uit [
252           (not (get-text-property (point) 'intangible))           (not (get-text-property (point) 'intangible))
253           (memq reftex-highlight-selection '(cursor both))           (memq reftex-highlight-selection '(cursor both))
254           (reftex-highlight 2           (reftex-highlight 2
255                             (or (previous-single-property-change                             (or (previous-single-property-change
256                                  (min (point-max) (1+ (point))) :data)                                  (min (point-max) (1+ (point))) :data)
257                                 (point-min))                                 (point-min))
258                             (or (next-single-property-change (point) :data)                             (or (next-single-property-change (point) :data)
# Line 301  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 299  SPC=view TAB=goto RET=goto+hide [q]uit [
299                 (window-height))))))                 (window-height))))))
300    
301  (defun reftex-toc-dframe-p (&optional frame error)  (defun reftex-toc-dframe-p (&optional frame error)
302    ;; Check if FRAME is the dedicated TOC frame.    ;; Check if FRAME is the dedicated TOC frame.  
303    ;; If yes, and ERROR is non-nil, throw an error.    ;; If yes, and ERROR is non-nil, throw an error.
304    (setq frame (or frame (selected-frame)))    (setq frame (or frame (selected-frame)))
305    (let ((res (equal    (let ((res (equal
306                (if (fboundp 'frame-property)                (if (fboundp 'frame-property)
307                    (frame-property frame 'name)                    (frame-property frame 'name)
308                  (frame-parameter  frame 'name))                  (frame-parameter  frame 'name))
# Line 330  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 328  SPC=view TAB=goto RET=goto+hide [q]uit [
328    (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))    (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
329    (setq reftex-callback-fwd t)    (setq reftex-callback-fwd t)
330    (or (eobp) (forward-char 1))    (or (eobp) (forward-char 1))
331    (goto-char (or (next-single-property-change (point) :data)    (goto-char (or (next-single-property-change (point) :data)
332                   (point))))                   (point))))
333  (defun reftex-toc-previous (&optional arg)  (defun reftex-toc-previous (&optional arg)
334    "Move to previous selectable item."    "Move to previous selectable item."
# Line 367  SPC=view TAB=goto RET=goto+hide [q]uit [ Line 365  SPC=view TAB=goto RET=goto+hide [q]uit [
365  With prefix ARG, prompt for a label type and include only labels of  With prefix ARG, prompt for a label type and include only labels of
366  that specific type."  that specific type."
367    (interactive "P")    (interactive "P")
368    (setq reftex-toc-include-labels    (setq reftex-toc-include-labels
369          (if arg (reftex-query-label-type)          (if arg (reftex-query-label-type)
370            (not reftex-toc-include-labels)))            (not reftex-toc-include-labels)))
371    (reftex-toc-revert))    (reftex-toc-revert))
# Line 471  With prefix arg 1, restrict index to the Line 469  With prefix arg 1, restrict index to the
469  (defun reftex-toc-rescan (&rest ignore)  (defun reftex-toc-rescan (&rest ignore)
470    "Regenerate the *toc* buffer by reparsing file of section at point."    "Regenerate the *toc* buffer by reparsing file of section at point."
471    (interactive)    (interactive)
472    (if (and reftex-enable-partial-scans    (if (and reftex-enable-partial-scans
473             (null current-prefix-arg))             (null current-prefix-arg))
474        (let* ((data (get-text-property (point) :data))        (let* ((data (get-text-property (point) :data))
475               (what (car data))               (what (car data))
# Line 505  With prefix arg 1, restrict index to the Line 503  With prefix arg 1, restrict index to the
503  (defun reftex-toc-revert (&rest ignore)  (defun reftex-toc-revert (&rest ignore)
504    "Regenerate the *toc* from the internal lists."    "Regenerate the *toc* from the internal lists."
505    (interactive)    (interactive)
506    (let ((unsplittable    (let ((unsplittable
507           (if (fboundp 'frame-property)           (if (fboundp 'frame-property)
508               (frame-property (selected-frame) 'unsplittable)               (frame-property (selected-frame) 'unsplittable)
509             (frame-parameter (selected-frame) 'unsplittable)))             (frame-parameter (selected-frame) 'unsplittable)))
# Line 547  Useful for large TOC's." Line 545  Useful for large TOC's."
545    
546  ;; Promotion/Demotion stuff  ;; Promotion/Demotion stuff
547    
548    (defvar delta)
549    (defvar mpos)
550    (defvar pro-or-de)
551    (defvar start-pos)
552    (defvar start-line)
553    (defvar mark-line)
554    
555  (defun reftex-toc-demote (&optional arg)  (defun reftex-toc-demote (&optional arg)
556    "Demote section at point.  If region is active, apply to all in region."    "Demote section at point.  If region is active, apply to all in region."
557    (interactive "p")    (interactive "p")
# Line 592  point." Line 597  point."
597              (goto-char start-pos)              (goto-char start-pos)
598              (setq sections (reftex-toc-extract-section-number (car entries)))              (setq sections (reftex-toc-extract-section-number (car entries)))
599              (if (> (setq nsec (length entries)) 1)              (if (> (setq nsec (length entries)) 1)
600                  (setq sections                  (setq sections
601                        (concat sections "-"                        (concat sections "-"
602                                (reftex-toc-extract-section-number                                (reftex-toc-extract-section-number
603                                 (nth (1- nsec) entries)))))                                 (nth (1- nsec) entries)))))
# Line 617  point." Line 622  point."
622              (save-window-excursion              (save-window-excursion
623                (reftex-toc-Rescan))                (reftex-toc-Rescan))
624              (reftex-toc-restore-region start-line mark-line)              (reftex-toc-restore-region start-line mark-line)
625              (message "%d section%s %smoted"              (message "%d section%s %smoted"
626                       nsec (if (= 1 nsec) "" "s") pro-or-de)                       nsec (if (= 1 nsec) "" "s") pro-or-de)
627              nil))              nil))
628      (if msg (progn (ding) (message msg)))))      (if msg (progn (ding) (message msg)))))
629    
 (defvar delta)  
 (defvar mpos)  
 (defvar pro-or-de)  
 (defvar start-pos)  
 (defvar start-line)  
 (defvar mark-line)  
630    
631  (defun reftex-toc-restore-region (point-line &optional mark-line)  (defun reftex-toc-restore-region (point-line &optional mark-line)
632    (if mark-line    (if mark-line
# Line 642  point." Line 641  point."
641            (setq mark-active t            (setq mark-active t
642                  deactivate-mark nil)))))                  deactivate-mark nil)))))
643    
644    (defvar name1)
645    (defvar dummy)
646    (defvar dummy2)
647    
648  (defun reftex-toc-promote-prepare (x)  (defun reftex-toc-promote-prepare (x)
649    "Look at a toc entry and see if we could pro/demote it.    "Look at a toc entry and see if we could pro/demote it.
650  Expects the level change DELTA to be dynamically scoped into this function.  Expects the level change DELTA to be dynamically scoped into this function.
# Line 670  promotion/demotion later." Line 673  promotion/demotion later."
673                          (beginning-of-line 1)                          (beginning-of-line 1)
674                          (if (looking-at reftex-section-regexp)                          (if (looking-at reftex-section-regexp)
675                              (setq name (reftex-match-string 2))                              (setq name (reftex-match-string 2))
676                            (error "Something is wrong!  Contact maintainer!")))                            (error "Something is wrong! Contact maintainer!")))
677                      ;; Section has changed, request scan and loading                      ;; Section has changed, request scan and loading
678                      ;; We use a variable to delay until after the safe-exc.                      ;; We use a variable to delay until after the safe-exc.
679                      ;; because otherwise we loose the region.                      ;; because otherwise we loose the region.
# Line 779  label prefix determines the wording of a Line 782  label prefix determines the wording of a
782          (error "This is not a label entry."))          (error "This is not a label entry."))
783      (setq newlabel (read-string (format "Rename label \"%s\" to:" label)))      (setq newlabel (read-string (format "Rename label \"%s\" to:" label)))
784      (if (assoc newlabel (symbol-value reftex-docstruct-symbol))      (if (assoc newlabel (symbol-value reftex-docstruct-symbol))
785          (if (not (y-or-n-p          (if (not (y-or-n-p
786                    (format "Label '%s' exists. Use anyway? " label)))                    (format "Label '%s' exists. Use anyway? " label)))
787              (error "Abort")))              (error "Abort")))
788      (save-excursion      (save-excursion
# Line 789  label prefix determines the wording of a Line 792  label prefix determines the wording of a
792              (reftex-query-replace-document              (reftex-query-replace-document
793               (concat "{" (regexp-quote label) "}")               (concat "{" (regexp-quote label) "}")
794               (format "{%s}" newlabel))               (format "{%s}" newlabel))
795            (error t))))            (error t))))        
796      (reftex-toc-rescan)))      (reftex-toc-rescan)))
797    
798    
# Line 808  label prefix determines the wording of a Line 811  label prefix determines the wording of a
811           show-window show-buffer match)           show-window show-buffer match)
812    
813      (unless toc (error "Don't know which toc line to visit"))      (unless toc (error "Don't know which toc line to visit"))
814        
815      (cond      (cond
816      
817       ((eq (car toc) 'toc)       ((eq (car toc) 'toc)
818        ;; a toc entry        ;; a toc entry
819        (setq match (reftex-toc-find-section toc no-revisit)))        (setq match (reftex-toc-find-section toc no-revisit)))
# Line 826  label prefix determines the wording of a Line 829  label prefix determines the wording of a
829                    (file (nth 1 toc)))                    (file (nth 1 toc)))
830                (if (or (not no-revisit) (reftex-get-buffer-visiting file))                (if (or (not no-revisit) (reftex-get-buffer-visiting file))
831                    (progn                    (progn
832                      (switch-to-buffer-other-window                      (switch-to-buffer-other-window
833                       (reftex-get-file-buffer-force file nil))                       (reftex-get-file-buffer-force file nil))
834                      (goto-char (if (eq where 'bof) (point-min) (point-max))))                      (goto-char (if (eq where 'bof) (point-min) (point-max))))
835                  (message reftex-no-follow-message) nil))))                  (message reftex-no-follow-message) nil))))
# Line 879  label prefix determines the wording of a Line 882  label prefix determines the wording of a
882                  (looking-at (reftex-make-desperate-section-regexp literal))                  (looking-at (reftex-make-desperate-section-regexp literal))
883                  (looking-at (concat "\\\\"                  (looking-at (concat "\\\\"
884                                      (regexp-quote                                      (regexp-quote
885                                       (car                                       (car
886                                        (rassq level                                        (rassq level
887                                               reftex-section-levels-all)))                                               reftex-section-levels-all)))
888                                      "[[{]?"))))                                      "[[{]?"))))
889             ((or (not no-revisit)             ((or (not no-revisit)
# Line 1050  always show the current section in conne Line 1053  always show the current section in conne
1053        (define-key reftex-toc-map (vector (list key)) 'digit-argument))        (define-key reftex-toc-map (vector (list key)) 'digit-argument))
1054  (define-key reftex-toc-map "-" 'negative-argument)  (define-key reftex-toc-map "-" 'negative-argument)
1055    
1056  (easy-menu-define  (easy-menu-define
1057   reftex-toc-menu reftex-toc-map   reftex-toc-menu reftex-toc-map
1058   "Menu for Table of Contents buffer"   "Menu for Table of Contents buffer"
1059   '("TOC"   '("TOC"
# Line 1083  always show the current section in conne Line 1086  always show the current section in conne
1086      ["Context" reftex-toc-toggle-context :style toggle      ["Context" reftex-toc-toggle-context :style toggle
1087       :selected reftex-toc-include-context]       :selected reftex-toc-include-context]
1088      "--"      "--"
1089      ["Follow Mode" reftex-toc-toggle-follow :style toggle      ["Follow Mode" reftex-toc-toggle-follow :style toggle
1090       :selected reftex-toc-follow-mode]       :selected reftex-toc-follow-mode]
1091      ["Auto Recenter" reftex-toggle-auto-toc-recenter :style toggle      ["Auto Recenter" reftex-toggle-auto-toc-recenter :style toggle
1092       :selected reftex-toc-auto-recenter-timer]       :selected reftex-toc-auto-recenter-timer]

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26