comparison lisp/progmodes/antlr-mode.el @ 112389:75fb060ecbc3

Don't mess with *temp*. * lisp/obsolete/spell.el: Move from textmodes/spell.el. (spell-string): * lisp/term.el (term-read-input-ring): * lisp/startup.el (display-startup-echo-area-message): * lisp/progmodes/antlr-mode.el (antlr-directory-dependencies): * lisp/gnus/message.el (message-mailer-swallows-blank-line): * lisp/comint.el (comint-read-input-ring): Use with-temp-buffer. * lisp/international/mule.el (ctext-pre-write-conversion): Don't hardcode point-min==1. * lisp/gnus/mm-util.el (mm-find-buffer-file-coding-system): Don't forget to kill the temp buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 20 Jan 2011 17:36:12 -0500
parents ef719132ddfa
children
comparison
equal deleted inserted replaced
112388:e5e8faa33346 112389:75fb060ecbc3
2180 `antlr-file-dependencies'. For each grammar class CLASS, FILE is a 2180 `antlr-file-dependencies'. For each grammar class CLASS, FILE is a
2181 grammar file in which CLASS is defined and EVOCAB is the name of the 2181 grammar file in which CLASS is defined and EVOCAB is the name of the
2182 export vocabulary specified in that file." 2182 export vocabulary specified in that file."
2183 (let ((grammar (directory-files dirname t "\\.g\\'"))) 2183 (let ((grammar (directory-files dirname t "\\.g\\'")))
2184 (when grammar 2184 (when grammar
2185 (let ((temp-buffer (get-buffer-create 2185 (let ((antlr-imenu-name nil) ; dynamic-let: no imenu
2186 (generate-new-buffer-name " *temp*"))) 2186 (expanded-regexp
2187 (antlr-imenu-name nil) ; dynamic-let: no imenu 2187 (concat (format (regexp-quote
2188 (expanded-regexp (concat (format (regexp-quote 2188 (cadr antlr-special-file-formats))
2189 (cadr antlr-special-file-formats)) 2189 ".+")
2190 ".+") 2190 "\\'"))
2191 "\\'"))
2192 classes dependencies) 2191 classes dependencies)
2193 (unwind-protect 2192 (with-temp-buffer
2194 (with-current-buffer temp-buffer 2193 (dolist (file grammar)
2195 (widen) ; just in case... 2194 (when (and (file-regular-p file)
2196 (dolist (file grammar) 2195 (null (string-match expanded-regexp file)))
2197 (when (and (file-regular-p file) 2196 (insert-file-contents file t nil nil t)
2198 (null (string-match expanded-regexp file))) 2197 (normal-mode t) ; necessary for major-mode, syntax
2199 (insert-file-contents file t nil nil t)
2200 (normal-mode t) ; necessary for major-mode, syntax
2201 ; table and `antlr-language' 2198 ; table and `antlr-language'
2202 (when (derived-mode-p 'antlr-mode) 2199 (when (derived-mode-p 'antlr-mode)
2203 (let* ((file-deps (antlr-file-dependencies)) 2200 (let* ((file-deps (antlr-file-dependencies))
2204 (file (car file-deps))) 2201 (file (car file-deps)))
2205 (when file-deps 2202 (when file-deps
2206 (dolist (class-def (caadr file-deps)) 2203 (dolist (class-def (caadr file-deps))
2207 (let ((file-evocab (cons file (cdr class-def))) 2204 (let ((file-evocab (cons file (cdr class-def)))
2208 (class-spec (assoc (car class-def) classes))) 2205 (class-spec (assoc (car class-def) classes)))
2209 (if class-spec 2206 (if class-spec
2210 (nconc (cdr class-spec) (list file-evocab)) 2207 (nconc (cdr class-spec) (list file-evocab))
2211 (push (list (car class-def) file-evocab) 2208 (push (list (car class-def) file-evocab)
2212 classes)))) 2209 classes))))
2213 (push file-deps dependencies))))))) 2210 (push file-deps dependencies)))))))
2214 (kill-buffer temp-buffer))
2215 (cons (nreverse classes) (nreverse dependencies)))))) 2211 (cons (nreverse classes) (nreverse dependencies))))))
2216 2212
2217 2213
2218 ;;;=========================================================================== 2214 ;;;===========================================================================
2219 ;;; Compilation: run ANTLR tool 2215 ;;; Compilation: run ANTLR tool