Start fixing tramp completion user-error for emacs-24.4. #225

merged 3 commits into from Mar 29, 2013
@@ -1127,10 +1127,10 @@ or hitting C-z on \"..\"."
(defun helm-ff-move-to-first-real-candidate ()
"When candidate is an incomplete file name move to first real candidate."
- (let ((cand (helm-get-selection)))
+ (helm-aif (helm-get-selection)
(when (and (helm-file-completion-source-p)
- (not (file-remote-p cand))
- (not (file-exists-p cand)))
+ (not (string-match tramp-file-name-regexp it))
+ (not (file-exists-p it)))
(add-hook 'helm-after-update-hook 'helm-ff-move-to-first-real-candidate)
@@ -1322,6 +1322,7 @@ purpose."
(file-name-as-directory path)
(file-name-directory path)))
+ non-essential
(tramp-verbose helm-tramp-verbose)) ; No tramp message when 0.
(set-text-properties 0 (length path) nil path)
;; Issue #118 allow creation of newdir+newfile.
@@ -1626,7 +1627,8 @@ is non--nil."
(if helm-ff-transformer-show-only-basename
(loop for i in files collect
(if (helm-dir-is-dot i)
- i (cons (helm-basename i) i)))
+ i (cons (or (helm-ff-get-host-from-tramp-invalid-fname i)
+ (helm-basename i)) i)))
(helm-ff-highlight-files files)))
@@ -1637,9 +1639,11 @@ Don't use it directly in `filtered-candidate-transformer' use instead
(loop for i in files
for disp = (if (and helm-ff-transformer-show-only-basename
(not (helm-dir-is-dot i))
- (not (and ffap-url-regexp (string-match ffap-url-regexp i)))
+ (not (and ffap-url-regexp
+ (string-match ffap-url-regexp i)))
(not (string-match helm-ff-url-regexp i)))
- (helm-basename i) i)
+ (or (helm-ff-get-host-from-tramp-invalid-fname i)
+ (helm-basename i)) i)
for attr = (file-attributes i)
for type = (car attr)
@@ -175,13 +175,6 @@ Return nil if DIR is not an existing directory."
concat (if p (concat "/" i) (concat i "/")) into root
finally return (file-equal-p (file-truename root) f2)))))))
-(when (and (require 'tramp)
- (fboundp 'tramp-compat-user-error))
- (defadvice tramp-dissect-file-name (around disable-user-error activate)
- "Disable `user-error'."
- (flet ((tramp-compat-user-error (format &rest objects) nil))
- ad-do-it)))
;; CUA workaround
(defadvice cua-delete-region (around helm-avoid-cua activate)
@@ -492,11 +485,21 @@ Argument MATCH can be a predicate or a regexp."
(defun helm-basename (fname &optional ext)
"Print FNAME with any leading directory components removed.
If specified, also remove filename extension EXT."
- (if (and ext (or (string= (file-name-extension fname) ext)
- (string= (file-name-extension fname t) ext))
- (not (file-directory-p fname)))
- (file-name-sans-extension (file-name-nondirectory fname))
- (file-name-nondirectory (directory-file-name fname))))
+ (let ((non-essential t))
+ (if (and ext (or (string= (file-name-extension fname) ext)
+ (string= (file-name-extension fname t) ext))
+ (not (file-directory-p fname)))
+ (file-name-sans-extension (file-name-nondirectory fname))
+ (file-name-nondirectory (directory-file-name fname)))))
+(defun helm-ff-get-host-from-tramp-invalid-fname (fname)
+ "Extract hostname from an incomplete tramp file name.
+Return nil on valid file name remote or not."
+ (let* ((str (helm-basename fname))
+ (split (split-string str ":"))
+ (meth (car (member (car split) (mapcar 'car tramp-methods)))))
+ (when (and meth (<= (length split) 2))
+ (cadr split))))
(defun helm-file-human-size (size)
"Return a string showing SIZE of a file in human readable form.
@@ -1479,6 +1479,7 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'."
;; #163 no cursor in minibuffer in <=Emacs-24.2.
;; This is not needed in emacs-24.3+
(cursor-in-echo-area t)
+ (non-essential t)
(or helm-maybe-use-default-as-input ; it is let-bounded so use it.
(loop for s in (helm-normalize-sources any-sources)