=== modified file 'semantic/bovine/semantic-el.el'
--- semantic/bovine/semantic-el.el	2010-03-26 22:18:07 +0000
+++ semantic/bovine/semantic-el.el	2011-12-20 14:39:39 +0000
@@ -473,8 +473,8 @@
 	   (name (if lib (file-name-sans-extension lib) nil))
 	   (nameel (concat name ".el")))
       (cond
-       ((and name (file-exists-p nameel)) nameel)
-       ((and name (file-exists-p (concat name ".el.gz")))
+       ((and name (semantic-safe-file-exists-p nameel)) nameel)
+       ((and name (semantic-safe-file-exists-p (concat name ".el.gz")))
 	;; This is the linux distro case.
 	(concat name ".el.gz"))
        ;; source file does not exists

=== modified file 'semantic/semantic-adebug.el'
--- semantic/semantic-adebug.el	2010-03-15 13:40:55 +0000
+++ semantic/semantic-adebug.el	2011-12-20 14:39:23 +0000
@@ -332,7 +332,7 @@
       (princ startfile)
       (princ "\nTrueName is: ")
       (princ file)
-      (when (not (file-exists-p file))
+      (when (not (semantic-safe-file-exists-p file))
 	(princ "\nFile does not exist!"))
       (princ "\nDirectory Part is: ")
       (princ default-directory)

=== modified file 'semantic/semantic-decorate-include.el'
--- semantic/semantic-decorate-include.el	2011-02-28 03:35:43 +0000
+++ semantic/semantic-decorate-include.el	2011-12-20 14:39:22 +0000
@@ -454,7 +454,7 @@
       (error "Point is not on an include tag"))
     (let ((file (semantic-dependency-tag-file tag)))
       (cond
-       ((or (not file) (not (file-exists-p file)))
+       ((or (not file) (not (semantic-safe-file-exists-p file)))
 	(error "Could not location include %s"
 	       (semantic-tag-name tag)))
        ((get-file-buffer file)

=== modified file 'semantic/semantic-dep.el'
--- semantic/semantic-dep.el	2010-03-15 13:40:55 +0000
+++ semantic/semantic-dep.el	2011-12-20 14:36:29 +0000
@@ -201,7 +201,7 @@
 	  (found nil))
       (while (and p (not found))
         (let ((f (expand-file-name file (car p))))
-	  (if (file-exists-p f)
+	  (if (semantic-safe-file-exists-p f)
 	      (setq found f)))
         (setq p (cdr p)))
       found))
@@ -224,7 +224,7 @@
 	(locp (mode-local-value
 	       mode 'semantic-dependency-include-path))
 	(found nil))
-    (when (file-exists-p file)
+    (when (semantic-safe-file-exists-p file)
       (setq found file))
     (when (and (not found) (not systemp))
       (setq found (semantic--dependency-find-file-on-path file locp)))

=== modified file 'semantic/semantic-ede-grammar.el'
--- semantic/semantic-ede-grammar.el	2010-03-15 13:40:55 +0000
+++ semantic/semantic-ede-grammar.el	2011-12-20 14:39:19 +0000
@@ -136,7 +136,7 @@
 		(semantic-grammar-create-package))
 	      (save-buffer)
 	      (let ((cf (concat (semantic-grammar-package) ".el")))
-		(if (or (not (file-exists-p cf))
+		(if (or (not (semantic-safe-file-exists-p cf))
 			(file-newer-than-file-p src cf))
 		    (byte-compile-file cf)))))
 	    (oref obj source)))

=== modified file 'semantic/semantic-grammar.el'
--- semantic/semantic-grammar.el	2010-08-19 23:28:10 +0000
+++ semantic/semantic-grammar.el	2011-12-20 14:39:21 +0000
@@ -987,7 +987,7 @@
         (find-file-hooks (delete 'vc-find-file-hook find-file-hooks)))
     (message "Compiling Grammars from: %s" (locate-library "semantic-grammar"))
     (dolist (arg command-line-args-left)
-      (unless (and arg (file-exists-p arg))
+      (unless (and arg (semantic-safe-file-exists-p arg))
         (error "Argument %s is not a valid file name" arg))
       (setq arg (expand-file-name arg))
       (if (file-directory-p arg)

=== modified file 'semantic/semantic-ia-utest.el'
--- semantic/semantic-ia-utest.el	2011-08-07 02:00:48 +0000
+++ semantic/semantic-ia-utest.el	2011-12-20 14:40:00 +0000
@@ -91,7 +91,7 @@
       (while fl
 
 	;; Make sure we have the files we think we have.
-	(when (not (file-exists-p (car fl)))
+	(when (not (semantic-safe-file-exists-p (car fl)))
 	  (error "Cannot find unit test file: %s" (car fl)))
 
 	;; Run the tests.

=== modified file 'semantic/semantic-idle.el'
--- semantic/semantic-idle.el	2011-11-30 08:31:53 +0000
+++ semantic/semantic-idle.el	2011-12-20 15:01:48 +0000
@@ -149,17 +149,12 @@
   "Return non-nil if idle-scheduler is enabled for this buffer.
 idle-scheduler is disabled when debugging or if the buffer size
 exceeds the `semantic-idle-scheduler-max-buffer-size' threshold."
-  (let* ((remote-file? (when (stringp buffer-file-name) (file-remote-p buffer-file-name))))
-    (and semantic-idle-scheduler-mode
-	 (not semantic-debug-enabled)
-	 (not semantic-lex-debug)
-	 ;; local file should exist on disk
-	 ;; remote file should have active connection
-	 (or (and (null remote-file?) (stringp buffer-file-name)
-		  (file-exists-p buffer-file-name))
-	     (and remote-file? (file-remote-p buffer-file-name nil t)))
-	 (or (<= semantic-idle-scheduler-max-buffer-size 0)
-	     (< (buffer-size) semantic-idle-scheduler-max-buffer-size)))))
+  (and semantic-idle-scheduler-mode
+       (not semantic-debug-enabled)
+       (not semantic-lex-debug)
+       (semantic-safe-file-exists-p buffer-file-name)
+       (or (<= semantic-idle-scheduler-max-buffer-size 0)
+	   (< (buffer-size) semantic-idle-scheduler-max-buffer-size))))
 
 (defun semantic-idle-scheduler-mode-setup ()
   "Setup option `semantic-idle-scheduler-mode'.

=== modified file 'semantic/semantic-inc.el'
--- semantic/semantic-inc.el	2005-09-30 20:26:27 +0000
+++ semantic/semantic-inc.el	2011-12-20 14:39:17 +0000
@@ -50,7 +50,7 @@
   (save-excursion
     (if buffer (set-buffer buffer))
     (let ((name (semantic-token-name semantic-include-token)))
-      (cond ((file-exists-p name)
+      (cond ((semantic-safe-file-exists-p name)
 	     (expand-file-name name))
 	    ((and (symbolp semantic-inc-include-path)
 		  (fboundp semantic-inc-include-path))
@@ -59,7 +59,7 @@
 	     (let ((p semantic-inc-include-path)
 		   (found nil))
 	       (while (and p (not found))
-		 (if (file-exists-p (concat (car p) "/" name))
+		 (if (semantic-safe-file-exists-p (concat (car p) "/" name))
 		     (setq found (concat (car p) "/" name)))
 		 (setq p (cdr p)))
 	       found))))))

=== modified file 'semantic/semantic-load.el'
--- semantic/semantic-load.el	2011-08-22 01:45:06 +0000
+++ semantic/semantic-load.el	2011-12-20 14:44:03 +0000
@@ -27,6 +27,7 @@
 ;;; Code:
 ;;
 
+(require 'semantic)
 (require 'semantic-fw)
 
 ;;; Add parser and doc directories
@@ -88,7 +89,7 @@
     (when (and (not (featurep 'xemacs))
 	       (boundp 'semanticdb-default-system-save-directory)
 	       (stringp semanticdb-default-system-save-directory)
-	       (file-exists-p semanticdb-default-system-save-directory))
+	       (semantic-safe-file-exists-p semanticdb-default-system-save-directory))
       (semanticdb-load-ebrowse-caches))
     )
   )

=== modified file 'semantic/semantic-regtest.el'
--- semantic/semantic-regtest.el	2005-09-30 20:26:27 +0000
+++ semantic/semantic-regtest.el	2011-12-20 14:39:16 +0000
@@ -215,7 +215,7 @@
 The user will be asked for the file-name of the created test-output-file \(see
 `semantic-regtest-create-output--internal')."
   (interactive)
-  (let ((file (if (file-exists-p (concat (buffer-file-name) ".ro"))
+  (let ((file (if (semantic-safe-file-exists-p (concat (buffer-file-name) ".ro"))
                   (concat (buffer-file-name) ".to")
                 (concat (buffer-file-name) ".ro"))))
     (setq file (read-file-name "Test-output: " nil file nil
@@ -501,10 +501,10 @@
   (interactive "P")
   (let* ((source-file (if (semantic-active-p) (buffer-file-name)))
          (test-file (and source-file
-                         (file-exists-p (concat source-file ".to"))
+                         (semantic-safe-file-exists-p (concat source-file ".to"))
                          (concat source-file ".to")))
          (ref-file (and source-file
-                        (file-exists-p (concat source-file ".ro"))
+                        (semantic-safe-file-exists-p (concat source-file ".ro"))
                         (concat source-file ".ro")))
          (result-file (and source-file (concat source-file ".res"))))
     (setq source-file (read-file-name "Source-file: " nil source-file nil

=== modified file 'semantic/semantic-util.el'
--- semantic/semantic-util.el	2010-09-24 00:53:54 +0000
+++ semantic/semantic-util.el	2011-12-20 14:35:18 +0000
@@ -103,12 +103,12 @@
    ;; Tag with a file name in it
    ((and (semantic-tag-p something)
 	 (semantic-tag-file-name something)
-	 (file-exists-p (semantic-tag-file-name something)))
+	 (semantic-safe-file-exists-p (semantic-tag-file-name something)))
     (semantic-file-tag-table
      (semantic-tag-file-name something)))
    ;; A file name
    ((and (stringp something)
-	 (file-exists-p something))
+	 (semantic-safe-file-exists-p something))
     (semantic-file-tag-table something))
    ;; A Semanticdb table
    ((and (featurep 'semanticdb)

=== modified file 'semantic/semantic.el'
--- semantic/semantic.el	2011-01-27 20:42:06 +0000
+++ semantic/semantic.el	2011-12-20 14:33:24 +0000
@@ -328,6 +328,13 @@
 ;; Test the above hook.
 ;;(add-hook 'semantic-init-hook (lambda () (message "init for semantic")))
 
+(defun semantic-safe-file-exists-p (file)
+  "Function that safely checks does file exists or not, taking into account remote files
+with closed tramp connection."
+  (let ((remote-file? (when (stringp file) (file-remote-p file))))
+    (or (and (null remote-file?) (stringp file) (file-exists-p file))
+	(and remote-file? (file-remote-p file nil t)))))
+
 (defun semantic-fetch-tags-fast ()
   "For use in a hook.  When only a partial reparse is needed, reparse."
   (condition-case nil

=== modified file 'semantic/semanticdb-ebrowse.el'
--- semantic/semanticdb-ebrowse.el	2010-03-26 22:18:07 +0000
+++ semantic/semanticdb-ebrowse.el	2011-12-20 14:35:43 +0000
@@ -210,7 +210,7 @@
 	  (princ "\n")
 	  (princ BFL)
 	  (princ "\n")
-	  (when (file-exists-p BFLB)
+	  (when (semantic-safe-file-exists-p BFLB)
 	    (princ BFLB)
 	    (princ "\n"))
 	  )
@@ -219,7 +219,7 @@
 			 directory))
 	  (delete-file BF)
 	  (delete-file BFL)
-	  (when (file-exists-p BFLB)
+	  (when (semantic-safe-file-exists-p BFLB)
 	    (delete-file BFLB))
 	  )))))
 
@@ -270,7 +270,7 @@
   (let* ((B (semanticdb-ebrowse-file-for-directory dir))
 	 (buf (get-buffer-create "*semanticdb ebrowse*")))
     (message "semanticdb-ebrowse %s" B)
-    (when (file-exists-p B)
+    (when (semantic-safe-file-exists-p B)
       (set-buffer buf)
       (buffer-disable-undo buf)
       (erase-buffer)

=== modified file 'semantic/semanticdb-el.el'
--- semantic/semanticdb-el.el	2011-08-18 18:01:16 +0000
+++ semantic/semanticdb-el.el	2011-12-20 14:36:44 +0000
@@ -159,15 +159,15 @@
 		 ;; Older [X]Emacs don't have a 2nd argument.
 		 (error (symbol-file sym))))
 	 )
-    (if (or (not file) (not (file-exists-p file)))
+    (if (or (not file) (not (semantic-safe-file-exists-p file)))
 	;; The file didn't exist.  Return nil.
 	;; We can't normalize this tag.  Fake it out.
 	(cons obj tag)
       (when (string-match "\\.elc" file)
 	(setq file (concat (file-name-sans-extension file)
 			   ".el"))
-	(when (and (not (file-exists-p file))
-		   (file-exists-p (concat file ".gz")))
+	(when (and (not (semantic-safe-file-exists-p file))
+		   (semantic-safe-file-exists-p (concat file ".gz")))
 	  ;; Is it a .gz file?
 	  (setq file (concat file ".gz"))))
 

=== modified file 'semantic/semanticdb-file.el'
--- semantic/semanticdb-file.el	2010-04-18 20:22:08 +0000
+++ semantic/semanticdb-file.el	2011-12-20 14:34:57 +0000
@@ -135,7 +135,7 @@
   (setq directory (file-truename directory))
   (let* ((fn (semanticdb-cache-filename dbc directory))
 	 (db (or (semanticdb-file-loaded-p fn)
-		 (if (file-exists-p fn)
+		 (if (semantic-safe-file-exists-p fn)
 		     (progn
 		       (semanticdb-load-database fn))))))
     (unless db
@@ -202,7 +202,7 @@
     (cond ((null dest)
 	   ;; @TODO - If it was never set up... what should we do ?
 	   nil)
-	  ((file-exists-p dest) t)
+	  ((semantic-safe-file-exists-p dest) t)
 	  ((or supress-questions
 	       (and (boundp 'semanticdb--inhibit-make-directory)
 		    semanticdb--inhibit-make-directory))
@@ -261,14 +261,14 @@
   "Return non-nil if the file associated with OBJ is live.
 Live databases are objects associated with existing directories."
   (and (slot-boundp obj 'reference-directory)
-       (file-exists-p (oref obj reference-directory))))
+       (semantic-safe-file-exists-p (oref obj reference-directory))))
 
 (defmethod semanticdb-live-p ((obj semanticdb-table))
   "Return non-nil if the file associated with OBJ is live.
 Live files are either buffers in Emacs, or files existing on the filesystem."
   (let ((full-filename (semanticdb-full-filename obj)))
     (or (find-buffer-visiting full-filename)
-	(file-exists-p full-filename))))
+	(semantic-safe-file-exists-p full-filename))))
 
 (defvar semanticdb-data-debug-on-write-error nil
   "Run the data debugger on tables that issue errors.
@@ -420,7 +420,7 @@
       (dolist (F files)
 	(setq orig (cedet-file-name-to-directory-name
 		    (file-name-nondirectory F)))
-	(when (not (file-exists-p (file-name-directory orig)))
+	(when (not (semantic-safe-file-exists-p (file-name-directory orig)))
 	  (setq to-delete (cons F to-delete))
 	  ))
       (if to-delete

=== modified file 'semantic/semanticdb-find.el'
--- semantic/semanticdb-find.el	2011-10-06 17:13:59 +0000
+++ semantic/semanticdb-find.el	2011-12-20 14:38:57 +0000
@@ -393,7 +393,7 @@
 		      semanticdb-current-table)
 		     ((bufferp path)
 		      (semantic-buffer-local-value 'semanticdb-current-table path))
-		     ((and (stringp path) (file-exists-p path))
+		     ((and (stringp path) (semantic-safe-file-exists-p path))
 		      (semanticdb-file-table-object path t))
 		     ((semanticdb-abstract-table-child-p path)
 		      path)
@@ -637,7 +637,7 @@
      ;; to the source file that this tag originated in, and be fast.
      ;;
      ((and (semanticdb-find-throttle-active-p 'local)
-	   (file-exists-p (expand-file-name name originfiledir)))
+	   (semantic-safe-file-exists-p (expand-file-name name originfiledir)))
 
       (setq ans (semanticdb-find-load-unloaded
 		 (expand-file-name name originfiledir)))
@@ -690,9 +690,9 @@
 	(let* ((ref (if (slot-boundp (car roots) 'reference-directory)
 			(oref (car roots) reference-directory)))
 	       (fname (cond ((null ref) nil)
-			    ((file-exists-p (expand-file-name name ref))
+			    ((semantic-safe-file-exists-p (expand-file-name name ref))
 			     (expand-file-name name ref))
-			    ((file-exists-p (expand-file-name (file-name-nondirectory name) ref))
+			    ((semantic-safe-file-exists-p (expand-file-name (file-name-nondirectory name) ref))
 			     (expand-file-name (file-name-nondirectory name) ref)))))
 	  (when (and ref fname)
 	    ;; There is an actual file.  Grab it.

=== modified file 'semantic/semanticdb-javap.el'
--- semantic/semanticdb-javap.el	2011-08-06 15:59:14 +0000
+++ semantic/semanticdb-javap.el	2011-12-20 14:39:22 +0000
@@ -112,7 +112,7 @@
 	  (push P cpaths))
 	 ;; Jar files need a special database
 	 ((and (string= "jar" (file-name-extension P))
-	       (file-exists-p P))
+	       (semantic-safe-file-exists-p P))
 	  (push
 	   (semanticdb-create-database semanticdb-java-jar-database P)
 	   cpaths))
@@ -145,7 +145,7 @@
 	     ((stringp P)
 	      (let ((pksub (expand-file-name pkfile P))
 		    (tab nil))
-		(when (file-exists-p pksub)
+		(when (semantic-safe-file-exists-p pksub)
 		  (setq tab (semanticdb-javap-dir-to-compound-table pksub))
 		  (push tab ans))))
 
@@ -171,7 +171,7 @@
        ;; Return something from the cache.
        (found found)
        ;; Not found by default.  Does this thing exist at all?  Make one.
-       ((and (file-exists-p packagedir) (file-directory-p packagedir))
+       ((and (semantic-safe-file-exists-p packagedir) (file-directory-p packagedir))
 	(semanticdb-table-java-directory
 	 (file-name-nondirectory (directory-file-name finddir))
 	 :directory finddir))
@@ -207,10 +207,10 @@
 		  (let ((java  (concat expanded ".java"))
 			(class (concat expanded ".class")))
 		    (cond 
-		     ((file-exists-p java)
+		     ((semantic-safe-file-exists-p java)
 		      (setq def (semanticdb-file-table-object java))
 		      (throw 'foo nil))
-		     ((file-exists-p class)
+		     ((semantic-safe-file-exists-p class)
 		      ;; need to javap the thing, but w/out the db...
 		      nil)))))
 	       
@@ -881,7 +881,7 @@
 JARFILE is the full filename to some jar file.
 QUALIFIEDCLASSFILE is a filename with package qualifiers
 to some class in JARFILE."
-  (when (not (file-exists-p jarfile))
+  (when (not (semantic-safe-file-exists-p jarfile))
     (error "Javap: Cannot find %S" jarfile))
   (let ((javapbuff (cedet-javap-get-class
 		    jarfile

=== modified file 'semantic/semanticdb-ref.el'
--- semantic/semanticdb-ref.el	2010-01-07 02:24:52 +0000
+++ semantic/semanticdb-ref.el	2011-12-20 14:35:24 +0000
@@ -86,7 +86,7 @@
 	     )
 
 	;; The file was deleted
-	(when (and f (not (file-exists-p f)))
+	(when (and f (not (semantic-safe-file-exists-p f)))
 	  (setq ok nil))
 
 	;; The reference no longer includes the textual reference?

=== modified file 'semantic/semanticdb-system.el'
--- semantic/semanticdb-system.el	2010-04-09 01:52:15 +0000
+++ semantic/semanticdb-system.el	2011-12-20 14:39:18 +0000
@@ -146,7 +146,7 @@
 	  (customize-variable 'semanticdb-default-system-save-directory)
 	(error ""))
     ;; Get a dir if needed
-    (if (not (file-exists-p semanticdb-default-system-save-directory))
+    (if (not (semantic-safe-file-exists-p semanticdb-default-system-save-directory))
 	(if (y-or-n-p
 	     (format "Create %s now? " semanticdb-default-system-save-directory))
 	    (make-directory semanticdb-default-system-save-directory)

=== modified file 'semantic/semanticdb.el'
--- semantic/semanticdb.el	2011-09-13 01:15:21 +0000
+++ semantic/semanticdb.el	2011-12-20 14:39:20 +0000
@@ -880,7 +880,7 @@
 then load the tags for FILE, and create a new table object for it.
 DONTLOAD does not affect the creation of new database objects."
   ;; (message "Object Translate: %s" file)
-  (when (file-exists-p file)
+  (when (semantic-safe-file-exists-p file)
     (let* ((default-directory (file-name-directory file))
 	   (tab (semanticdb-file-table-object-from-hash file))
 	   (fullfile nil))

=== modified file 'semantic/senator.el'
--- semantic/senator.el	2011-06-09 20:42:21 +0000
+++ semantic/senator.el	2011-12-20 14:39:12 +0000
@@ -1351,7 +1351,7 @@
 	(switch-to-buffer result)
 	(pulse-momentary-highlight-one-line (point)))
        ;; Files
-       ((and (stringp result) (file-exists-p result))
+       ((and (stringp result) (semantic-safe-file-exists-p result))
 	(find-file result)
 	(pulse-momentary-highlight-one-line (point)))
        (t
@@ -1381,7 +1381,7 @@
         ((eq (semantic-tag-class tag) 'include)
 	 (let ((file (semantic-dependency-tag-file tag)))
 	   (cond
-	    ((or (not file) (not (file-exists-p file)))
+	    ((or (not file) (not (semantic-safe-file-exists-p file)))
 	     (error "Could not location include %s"
 		    (semantic-tag-name tag)))
 	    ((get-file-buffer file)

=== modified file 'semantic/symref/semantic-symref.el'
--- semantic/symref/semantic-symref.el	2010-04-09 01:59:06 +0000
+++ semantic/symref/semantic-symref.el	2011-12-20 14:36:19 +0000
@@ -79,11 +79,11 @@
 ;;; TOOL SETUP
 ;;
 (defvar semantic-symref-tool-alist
-  '( ( (lambda (rootdir) (file-exists-p (expand-file-name "GPATH" rootdir))) .
+  '( ( (lambda (rootdir) (semantic-safe-file-exists-p (expand-file-name "GPATH" rootdir))) .
        global)
-     ( (lambda (rootdir) (file-exists-p (expand-file-name "ID" rootdir))) .
+     ( (lambda (rootdir) (semantic-safe-file-exists-p (expand-file-name "ID" rootdir))) .
        idutils)
-     ( (lambda (rootdir) (file-exists-p (expand-file-name "cscope.out" rootdir))) .
+     ( (lambda (rootdir) (semantic-safe-file-exists-p (expand-file-name "cscope.out" rootdir))) .
        cscope )
     )
   "Alist of tools usable by `semantic-symref'.
