Function: srecode-map-update-map

srecode-map-update-map is an interactive and byte-compiled function defined in map.el.gz.

Signature

(srecode-map-update-map &optional FAST)

Documentation

Update the current map from srecode-map-load-path.

Scans all the files on the path, and makes sure we have entries for them. If option FAST is non-nil, then only parse a file for the mode-string if that file is NEW, otherwise assume the mode has not changed.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/srecode/map.el.gz
(defun srecode-map-update-map (&optional fast)
  "Update the current map from `srecode-map-load-path'.
Scans all the files on the path, and makes sure we have entries
for them.
If option FAST is non-nil, then only parse a file for the mode-string
if that file is NEW, otherwise assume the mode has not changed."
  (interactive)

  ;; When no map file, we are configured to not use a save file.
  (if (not srecode-map-save-file)
      ;; 0) Create a MAP when in no save file mode.
      (when (not srecode-current-map)
	(setq srecode-current-map (srecode-map))
	(message "SRecode map created in non-save mode.")
	)

    ;; 1) Do we even have a MAP or save file?
    (when (and (not srecode-current-map)
	       (not (file-exists-p srecode-map-save-file)))
      (when (not (file-exists-p (file-name-directory srecode-map-save-file)))
	;; Only bother with this interactively, not during a build
	;; or test.
	(when (not noninteractive)
	  ;; No map, make the dir?
	  (if (y-or-n-p (format "Create dir %s? "
				(file-name-directory srecode-map-save-file)))
	      (make-directory (file-name-directory srecode-map-save-file))
	    ;; No make, change save file
	    (customize-variable 'srecode-map-save-file)
	    (error "Change your SRecode map file"))))
      ;; Have a dir.  Make the object.
      (setq srecode-current-map
	    (srecode-map :file srecode-map-save-file)))

    ;; 2) Do we not have a current map?  If so load.
    (when (not srecode-current-map)
      (condition-case nil
	  (setq srecode-current-map
		(eieio-persistent-read srecode-map-save-file 'srecode-map))
	(error
	 ;; There was an error loading the old map.  Create a new one.
	 (setq srecode-current-map
	       (srecode-map :file srecode-map-save-file))))
      )

    )

  ;;
  ;; We better have a MAP object now.
  ;;
  (let ((dirty nil))
    ;; 3) - Purge dead files from the file list.
    (dolist (entry (copy-sequence (oref srecode-current-map files)))
      (when (not (srecode-map-file-still-valid-p
		  (car entry) srecode-current-map))
	(srecode-map-delete-file-entry srecode-current-map (car entry))
	(setq dirty t)
	))
    (dolist (app (copy-sequence (oref srecode-current-map apps)))
      (dolist (entry (copy-sequence (cdr app)))
	(when (not (srecode-map-file-still-valid-p
		    (car entry) srecode-current-map))
	  (srecode-map-delete-file-entry-from-app
	   srecode-current-map (car entry) (car app))
	  (setq dirty t)
	  )))
    ;; 4) - Find new files and add them to the map.
    (dolist (dir srecode-map-load-path)
      (when (file-exists-p dir)
	(dolist (f (directory-files dir t "\\.srt\\'"))
	  (when (and (not (backup-file-name-p f))
		     (not (auto-save-file-name-p f))
		     (file-readable-p f))
	    (let ((fdirty (srecode-map-validate-file-for-mode f fast)))
	      (setq dirty (or dirty fdirty))))
	  )))
    ;; Only do the save if we are dirty, or if we are in an interactive
    ;; Emacs.
    (when (and dirty (not noninteractive)
	       (slot-boundp srecode-current-map 'file))
      (eieio-persistent-save srecode-current-map))
    ))