Function: srecode-map-validate-file-for-mode

srecode-map-validate-file-for-mode is a byte-compiled function defined in map.el.gz.

Signature

(srecode-map-validate-file-for-mode FILE FAST)

Documentation

Read and validate FILE via the parser. Return the mode.

Argument FAST implies that the file should not be reparsed if there is already an entry for it. Return non-nil if the map changed.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/srecode/map.el.gz
(defun srecode-map-validate-file-for-mode (file fast)
  "Read and validate FILE via the parser.  Return the mode.
Argument FAST implies that the file should not be reparsed if there
is already an entry for it.
Return non-nil if the map changed."
  (unless (and fast
               (srecode-map-entry-for-file-anywhere srecode-current-map file))
    (let ((buff-orig (get-file-buffer file))
	  (dirty nil))
      (save-excursion
	(if buff-orig
	    (set-buffer buff-orig)
	  (set-buffer (get-buffer-create " *srecode-map-tmp*"))
	  (insert-file-contents file nil nil nil t)
	  ;; Force it to be ready to parse.
	  (srecode-template-mode)
	  (let ((semantic-init-hook nil))
	    (semantic-new-buffer-fcn))
	  )
	;; Force semantic to be enabled in this buffer.
	(unless (semantic-active-p)
	  (semantic-new-buffer-fcn))

	(semantic-fetch-tags)
	(let* ((mode-tag
		(semantic-find-first-tag-by-name "mode" (current-buffer)))
	       (val nil)
	       (app-tag
		(semantic-find-first-tag-by-name "application" (current-buffer)))
	       (app nil))
	  (if mode-tag
	      (setq val (car (semantic-tag-variable-default mode-tag)))
	    (error "There should be a mode declaration in %s" file))
	  (when app-tag
	    (setq app (car (semantic-tag-variable-default app-tag))))

	  (setq dirty
		(if app
		    (srecode-map-update-app-file-entry srecode-current-map
						       file
						       (read val)
						       (read app))
		  (srecode-map-update-file-entry srecode-current-map
						 file
						 (read val))))
	  )
	)
      dirty)))