; expand-acronym ; by Don Hopkins, Jan 9 '89 (defun (acronym-re &ar-acronym &ar-pattern (setq &ar-acronym (arg 1 ": acronym-re (acronym) ")) (setq &ar-pattern "\\W\\(") (while (length &ar-acronym) (setq &ar-pattern (concat &ar-pattern (substr &ar-acronym 1 1) "\\w*" (if (= (length &ar-acronym) 1) "\\)\\W" "\\W+") ) ) (setq &ar-acronym (substr &ar-acronym 2 -1)) ) &ar-pattern ) ) (defun (expand-acronym &ea-acronym &ea-pattern &ea-expansion &ea-syntax (setq &ea-acronym (arg 1 ": acronym-expansion (acronym) ")) (setq &ea-pattern (acronym-re &ea-acronym)) (setq &ea-syntax (current-syntax-table)) (save-excursion (temp-use-buffer "*acronym-expansions*" (erase-buffer) (use-syntax-table &ea-syntax) ) (beginning-of-file) (while (! (error-occurred (re-search-forward &ea-pattern))) (region-around-match 1) (setq &ea-expansion (region-to-string)) (temp-use-buffer "*acronym-expansions*" (end-of-file) (set-mark) (narrow-region) (insert-string &ea-expansion) (beginning-of-file) (error-occurred (re-replace-string "\\W+" " ")) (end-of-file) (insert-string "\n") (widen-region) ) ) ) (if (temp-use-buffer "*acronym-expansions*" (buffer-size)) (typeout-text (buffer-to-string "*acronym-expansions*")) (message (concat "No acronyms expansions for '" &ea-acronym "'."))) ) )