Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* helm-files.el (helm-find-files-transformer): Fix basename on invali…

…d tramp entries.

(helm-ff-highlight-files): same
* helm-utils.el (helm-ff-get-host-from-tramp-invalid-fname): New.
(helm-basename): Always use non-essential.
  • Loading branch information...
commit 4a740426ab9ffc6e201d17dfe3162d811c0f02f9 1 parent 58dfea8
@thierryvolpiatto thierryvolpiatto authored
Showing with 21 additions and 15 deletions.
  1. +6 −3 helm-files.el
  2. +15 −12 helm-utils.el
View
9 helm-files.el
@@ -1627,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)))
files)
(helm-ff-highlight-files files)))
@@ -1638,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)
collect
View
27 helm-utils.el
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.