Function: reftex-get-offset

reftex-get-offset is an autoloaded and byte-compiled function defined in reftex-sel.el.gz.

Signature

(reftex-get-offset BUF HERE-AM-I &optional TYPEKEY TOC INDEX FILE)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-sel.el.gz
;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
;;   ;; Find the correct offset data, like insert-docstruct would, but faster.
;;   ;; Buffer BUF knows the correct docstruct to use.
;;   ;; Basically this finds the first docstruct entry after HERE-I-AM which
;;   ;; is of allowed type.  The optional arguments specify what is allowed.
;;   (catch 'exit
;;     (with-current-buffer buf
;;       (reftex-access-scan-info)
;;       (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
;;          entry)
;;     (while (setq entry (pop rest))
;;       (if (or (and typekey
;;                    (stringp (car entry))
;;                    (or (equal typekey " ")
;;                        (equal typekey (nth 1 entry))))
;;               (and toc (eq (car entry) 'toc))
;;               (and index (eq (car entry) 'index))
;;               (and file
;;                    (memq (car entry) '(bof eof file-error))))
;;           (throw 'exit entry)))
;;     nil))))

;;;###autoload
(defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
  ;; Find the correct offset data, like insert-docstruct would, but faster.
  ;; Buffer BUF knows the correct docstruct to use.
  ;; Basically this finds the first docstruct entry before HERE-I-AM which
  ;; is of allowed type.  The optional arguments specify what is allowed.
  (catch 'exit
    (with-current-buffer buf
      (reftex-access-scan-info)
      (let* ((rest (symbol-value reftex-docstruct-symbol))
             lastentry entry)
        (while (setq entry (pop rest))
          (if (or (and typekey
                       (stringp (car entry))
                       (or (equal typekey " ")
                           (equal typekey (nth 1 entry))))
                  (and toc (eq (car entry) 'toc))
                  (and index (eq (car entry) 'index))
                  (and file
                       (memq (car entry) '(bof eof file-error))))
              (setq lastentry entry))
          (if (eq entry here-am-I)
              (throw 'exit (or lastentry entry))))
        nil))))