]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/reftex-index.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / textmodes / reftex-index.el
index 2d395fe3df2fc20608cb8838625d53db3b20c153..0ed6f26699a512b6e05162d6d448012c3dad31f3 100644 (file)
@@ -1,11 +1,9 @@
 ;;; reftex-index.el --- index support with RefTeX
 
-;; Copyright (C) 1997-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2016 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
 ;; Maintainer: auctex-devel@gnu.org
-;; Version: 4.31
-;; Package: reftex
 
 ;; This file is part of GNU Emacs.
 
@@ -27,9 +25,9 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
-(provide 'reftex-index)
+(declare-function texmathp "ext:texmathp" ())
+
 (require 'reftex)
-;;;
 
 ;; START remove for XEmacs release
 (defvar mark-active)
@@ -37,8 +35,7 @@
 (defvar TeX-master)
 ;; END remove for XEmacs release
 
-(declare-function texmathp "ext:texmathp" ())
-
+;;;###autoload
 (defun reftex-index-selection-or-word (&optional arg phrase)
   "Put selection or the word near point into the default index macro.
 This uses the information in `reftex-index-default-macro' to make an index
@@ -52,9 +49,7 @@ which is part of AUCTeX, the string is first processed with the
   (interactive "P")
   (let* ((use-default (not (equal arg '(16))))  ; check for double prefix
          ;; check if we have an active selection
-         (active (if (featurep 'xemacs)
-                     (and zmacs-regions (region-exists-p))  ; XEmacs
-                   (and transient-mark-mode mark-active)))  ; Emacs
+         (active (reftex-region-active-p))
          (beg (if active
                   (region-beginning)
                 (save-excursion
@@ -93,6 +88,7 @@ which is part of AUCTeX, the string is first processed with the
         (delete-region beg end)
         (reftex-index def-char full-entry def-tag sel)))))
 
+;;;###autoload
 (defun reftex-index (&optional char key tag sel no-insert)
   "Query for an index macro and insert it along with its arguments.
 The index macros available are those defined in `reftex-index-macro' or
@@ -162,6 +158,7 @@ will prompt for other arguments."
                (member tag tag-list)))
       (put reftex-docstruct-symbol 'default-index-tag tag)))
 
+;;;###autoload
 (defun reftex-index-complete-tag (&optional itag opt-args)
   ;; Ask the user for a tag, completing on known tags.
   ;; ITAG is the argument number which contains the tag.
@@ -186,6 +183,7 @@ will prompt for other arguments."
     (reftex-update-default-index tag)
     tag))
 
+;;;###autoload
 (defun reftex-index-select-tag ()
   ;; Have the user select an index tag.
   ;; FIXME: should we cache tag-alist, prompt and help?
@@ -255,6 +253,7 @@ will prompt for other arguments."
             (error "No index tag associated with %c" rpl)))))
      (t (error "This should not happen (reftex-index-select-tag)")))))
 
+;;;###autoload
 (defun reftex-index-complete-key (&optional tag optional initial)
   ;; Read an index key, with completion.
   ;; Restrict completion table on index tag TAG.
@@ -440,6 +439,7 @@ _ ^        Add/Remove parent key (to make this item a subitem).
 } / {      Restrict Index to a single document section / Widen.
 < / >      When restricted, move restriction to previous/next section.")
 
+;;;###autoload
 (defun reftex-index-show-entry (data &optional no-revisit)
   ;; Find an index entry associated with DATA and display it highlighted
   ;; in another window.  NO-REVISIT means we are not allowed to visit
@@ -468,6 +468,7 @@ _ ^        Add/Remove parent key (to make this item a subitem).
       (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
     match))
 
+;;;###autoload
 (defun reftex-display-index (&optional tag overriding-restriction redo
                                        &rest locations)
   "Display a buffer with an index compiled from the current document.
@@ -543,18 +544,28 @@ With prefix 3, restrict index to region."
 
       (setq buffer-read-only nil)
       (insert (format
-"INDEX <%s> on %s
+               "INDEX <%s> on %s
 Restriction: <%s>
 SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
 ------------------------------------------------------------------------------
-" index-tag (abbreviate-file-name master)
-(if (eq (car (car reftex-index-restriction-data)) 'toc)
-    (nth 2 (car reftex-index-restriction-data))
-  reftex-index-restriction-indicator)))
+"
+               index-tag (abbreviate-file-name master)
+               (if (eq (car (car reftex-index-restriction-data)) 'toc)
+                   (nth 2 (car reftex-index-restriction-data))
+                 reftex-index-restriction-indicator)))
 
       (if (reftex-use-fonts)
-          (put-text-property 1 (point) 'face reftex-index-header-face))
-      (put-text-property 1 (point) 'intangible t)
+          (put-text-property (point-min) (point)
+                             'face reftex-index-header-face))
+      (if (fboundp 'cursor-intangible-mode)
+          (cursor-intangible-mode 1)
+        ;; If `cursor-intangible' is not available, fallback on the old
+        ;; intrusive `intangible' property.
+        (put-text-property (point-min) (point) 'intangible t))
+      (add-text-properties (point-min) (point)
+                           '(cursor-intangible t
+                             front-sticky (cursor-intangible)
+                             rear-nonsticky (cursor-intangible)))
 
       (reftex-insert-index docstruct index-tag)
       (goto-char (point-min))
@@ -585,9 +596,7 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
           (if (memq reftex-highlight-selection '(mouse both))
               reftex-mouse-selected-face
             nil))
-         (index-face (reftex-verified-face reftex-label-face
-                                           'font-lock-constant-face
-                                           'font-lock-reference-face))
+         (index-face reftex-label-face)
          sublist cell from to first-char)
 
     ;; Make the sublist and sort it
@@ -698,9 +707,10 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
 
 (defun reftex-index-post-command-hook ()
   ;; Used in the post-command-hook for the *Index* buffer
+  ;; FIXME: Lots of redundancy with reftex-toc-post-command-hook!
   (when (get-text-property (point) :data)
-    (and (> (point) 1)
-         (not (get-text-property (point) 'intangible))
+    (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing?
+         (not (get-text-property (point) 'cursor-intangible))
          (memq reftex-highlight-selection '(cursor both))
          (reftex-highlight 1
            (or (previous-single-property-change (1+ (point)) :data)
@@ -904,7 +914,7 @@ When index is restricted, select the previous section as restriction criterion."
   ;; If FINAL is t, stay there
   ;; If FINAL is 'hide, hide the *Index* window.
   ;; Otherwise, move cursor back into *Index* window.
-  ;; NO-REVISIT means don't visit files, just use live biffers.
+  ;; NO-REVISIT means don't visit files, just use live buffers.
 
   (let* ((data (get-text-property (point) :data))
          (index-window (selected-window))
@@ -1246,8 +1256,13 @@ This gets refreshed in every phrases command.")
 
     map)
   "Keymap used for *toc* buffer.")
+(defvar reftex-index-phrases-syntax-table
+  (let ((table (make-syntax-table)))
+    (modify-syntax-entry ?\" "." table)
+    table)
+  "Syntax table for RefTeX Index Phrases mode.")
 
-
+;;;###autoload
 (defun reftex-index-phrase-selection-or-word (arg)
   "Add current selection or word at point to the phrases buffer.
 When you are in transient-mark-mode and the region is active, the
@@ -1262,10 +1277,12 @@ You get a chance to edit the entry in the phrases buffer - finish with
        (substitute-command-keys
         "Return to LaTeX with \\[reftex-index-phrases-save-and-return]"))))
 
+;;;###autoload
 (defun reftex-index-visit-phrases-buffer ()
   "Switch to the phrases buffer, initialize if empty."
   (interactive)
   (reftex-access-scan-info)
+  (set-marker reftex-index-return-marker (point))
   (let* ((master (reftex-TeX-master-file))
          (name (concat (file-name-sans-extension master)
                        reftex-index-phrase-file-extension)))
@@ -1348,6 +1365,7 @@ If the buffer is non-empty, delete the old header first."
 (defvar reftex-index-phrases-menu)
 (defvar reftex-index-phrases-marker)
 (defvar reftex-index-phrases-restrict-file nil)
+;; NB this is a global autoload - see reftex.el.
 ;;;###autoload
 (define-derived-mode reftex-index-phrases-mode fundamental-mode "Phrases"
   "Major mode for managing the Index phrases of a LaTeX document.
@@ -1373,6 +1391,7 @@ For more information see the RefTeX User Manual.
 Here are all local bindings.
 
 \\{reftex-index-phrases-mode-map}"
+  :syntax-table reftex-index-phrases-syntax-table
   (set (make-local-variable 'font-lock-defaults)
        reftex-index-phrases-font-lock-defaults)
   (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map)
@@ -2095,5 +2114,10 @@ Does not do a save-excursion."
                                   reftex-index-phrases-macro-data "\n"))))
     (reftex-select-with-char prompt help delay)))
 
+(provide 'reftex-index)
 
 ;;; reftex-index.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex-loaddefs.el"
+;; End: