changeset 61938:5512015ae158

(cc-create-define-alist): Check that file exists. Initialise cc-define-alist. (c-mode): Add cc-create-define-alist locally to after-save-hook.
author Nick Roberts <nickrob@snap.net.nz>
date Fri, 29 Apr 2005 23:47:30 +0000
parents 8ad965b70dbf
children 6b3d5f6887e4
files lisp/progmodes/cc-mode.el
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cc-mode.el	Fri Apr 29 23:46:57 2005 +0000
+++ b/lisp/progmodes/cc-mode.el	Fri Apr 29 23:47:30 2005 +0000
@@ -649,9 +649,10 @@
 	  (with-output-to-string
 	    (with-current-buffer standard-output
 	      (call-process cc-mode-cpp-program
-			    file t nil "-dM"))))
+			    (if (file-exists-p file) file nil) t nil "-dM"))))
 	(define-list (split-string output "\n" t))
 	(name))
+    (setq cc-define-alist nil)
     (dolist (define define-list)
       (setq name (nth 1 (split-string define "[( ]")))
       (push (cons name define) cc-define-alist))))
@@ -686,6 +687,7 @@
   (easy-menu-add c-c-menu)
   (cc-imenu-init cc-imenu-c-generic-expression)
   (cc-create-define-alist)
+  (add-hook 'after-save-hook 'cc-create-define-alist nil t)
   (run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
   (c-update-modeline))