Function: reftex-nicify-text
reftex-nicify-text is a byte-compiled function defined in
reftex.el.gz.
Signature
(reftex-nicify-text TEXT)
Documentation
Make TEXT nice for inclusion as context into label menu.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex.el.gz
(defun reftex-nicify-text (text)
"Make TEXT nice for inclusion as context into label menu."
;; 1. remove line breaks and extra white space
(while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
(setq text (replace-match " " nil t text)))
;; 2. cut before the next `\end{' or `\item' or `\\'
(if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
(setq text (replace-match "" nil t text)))
;; 3. kill the embedded label
(if (string-match "\\\\label{[^}]*}" text)
(setq text (replace-match "" nil t text)))
;; 4. remove leading garbage
(if (string-match "\\`[ }]+" text)
(setq text (replace-match "" nil t text)))
;; 5. limit length
(cond
((> (length text) 100) (substring text 0 100))
((= (length text) 0) (make-string 1 ?\ ))
(t text)))