[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm 2dc2e98c01 1/2: Fix highlighting matches on invalid t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm 2dc2e98c01 1/2: Fix highlighting matches on invalid tramp names |
Date: |
Sat, 22 Oct 2022 17:58:54 -0400 (EDT) |
branch: elpa/helm
commit 2dc2e98c01a97d337037c65718851088bc2a6d3c
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Fix highlighting matches on invalid tramp names
This also avoid calling twice
helm-ff--get-host-from-tramp-invalid-fname.
---
helm-core.el | 13 +++++----
helm-files.el | 89 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/helm-core.el b/helm-core.el
index c1d8d88dbd..9fb768a046 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -4587,6 +4587,7 @@ useful when the order of the candidates is meaningful,
e.g. with
(let* ((pair (and (consp candidate) candidate))
(display (helm-stringify (if pair (car pair) candidate)))
(real (cdr pair))
+ (host (and file-comp (get-text-property 0 'host display)))
(regex (helm--maybe-get-migemo-pattern pattern diacritics))
(mpart (get-text-property 0 'match-part display))
(mp (cond ((and mpart (string= display mpart)) nil)
@@ -4594,9 +4595,10 @@ useful when the order of the candidates is meaningful,
e.g. with
;; FIXME: This may be wrong when match-on-real
;; is nil, so we should flag match-on-real on
;; top and use it.
- (file-comp (file-name-nondirectory (or real
display)))))
+ (file-comp (file-name-nondirectory (or host real
display)))))
(count 0)
beg-str end-str)
+ (when host (setq pattern (cadr (split-string pattern ":"))))
;; Extract all parts of display keeping original properties.
(when (and mp (ignore-errors
;; Avoid error when candidate is a huge line.
@@ -4612,10 +4614,11 @@ useful when the order of the candidates is meaningful,
e.g. with
(condition-case nil
(progn
;; Try first matching against whole pattern.
- (while (re-search-forward regex nil t)
- (cl-incf count)
- (helm-add-face-text-properties
- (match-beginning 0) (match-end 0) 'helm-match))
+ (unless (string= pattern "")
+ (while (re-search-forward regex nil t)
+ (cl-incf count)
+ (helm-add-face-text-properties
+ (match-beginning 0) (match-end 0) 'helm-match)))
;; If no matches start matching against multiples or fuzzy matches.
(when (zerop count)
(cl-loop with multi-match = (string-match-p " " pattern)
diff --git a/helm-files.el b/helm-files.el
index e9fc9d0a58..7a697d91f8 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -3962,8 +3962,9 @@ If SKIP-BORING-CHECK is non nil don't filter boring
files."
(let* ((basename (helm-basename file))
(dot (helm-ff-dot-file-p file))
(urlp (string-match-p helm-ff-url-regexp file))
- ;; Filename with cntrl chars e.g. foo^J
- (disp (or (helm-ff--get-host-from-tramp-invalid-fname file)
+ (tramp-invalid-fname (helm-ff--get-host-from-tramp-invalid-fname
file))
+ (disp (or tramp-invalid-fname
+ ;; Filename with cntrl chars e.g. foo^J
(replace-regexp-in-string
"[[:cntrl:]]" "?"
(if (or reverse urlp) file basename))))
@@ -3991,47 +3992,49 @@ If SKIP-BORING-CHECK is non nil don't filter boring
files."
;; Handle tramp files with minimal highlighting.
(if (and (or (string-match-p helm-tramp-file-name-regexp helm-pattern)
(helm-file-on-mounted-network-p helm-pattern)))
- (let* ((hostp (helm-ff--get-host-from-tramp-invalid-fname file)))
- (helm-acond (;; Dot directories . and ..
- dot
- (cons (propertize file 'face
'helm-ff-dotted-directory) file))
- ;; Directories.
- ((get-text-property 1 'helm-ff-dir file)
- (cons (propertize disp 'face 'helm-ff-directory)
file))
- ;; Backup files.
- (backup
- (cons (propertize disp 'face 'helm-ff-backup-file)
file))
- ;; Executable files.
- ((get-text-property 1 'helm-ff-exe file)
- (add-face-text-property 0 len 'helm-ff-executable t
disp)
- (cons disp file))
- ;; Symlinks.
- ((get-text-property 1 'helm-ff-sym file)
- (add-face-text-property 0 len 'helm-ff-symlink t disp)
- (if (stringp it) ; adb method.
- (progn
- (add-face-text-property 0 (length it)
'helm-ff-truename nil it)
- (cons (propertize disp 'display (concat disp "
->" it)) file))
- (cons disp file)))
- ;; Regular files.
- ((get-text-property 1 'helm-ff-file file)
- (add-face-text-property 0 len 'helm-ff-file t disp)
- (cons disp file))
- ;; Tramp methods.
- ((string-match helm-ff-tramp-method-regexp file)
- (let ((method (match-string 1 file))
- (mh (helm-ff--tramp-multihops-p
helm-pattern)))
- (cons (propertize (concat (if mh "" "/") method)
'face 'helm-ff-file)
- (if mh
- (concat (match-string 1 helm-pattern) ":"
method)
- (concat "/:" method)))))
- ;; non existing files.
- (t
- (add-face-text-property 0 len 'helm-ff-file t disp)
- (cons (helm-ff-prefix-filename
- disp
- hostp (unless hostp 'new-file))
- file))))
+ (helm-acond (;; Dot directories . and ..
+ dot
+ (cons (propertize file 'face 'helm-ff-dotted-directory)
file))
+ ;; Directories.
+ ((get-text-property 1 'helm-ff-dir file)
+ (cons (propertize disp 'face 'helm-ff-directory) file))
+ ;; Backup files.
+ (backup
+ (cons (propertize disp 'face 'helm-ff-backup-file)
file))
+ ;; Executable files.
+ ((get-text-property 1 'helm-ff-exe file)
+ (add-face-text-property 0 len 'helm-ff-executable t
disp)
+ (cons disp file))
+ ;; Symlinks.
+ ((get-text-property 1 'helm-ff-sym file)
+ (add-face-text-property 0 len 'helm-ff-symlink t disp)
+ (if (stringp it) ; adb method.
+ (progn
+ (add-face-text-property 0 (length it)
'helm-ff-truename nil it)
+ (cons (propertize disp 'display (concat disp "
->" it)) file))
+ (cons disp file)))
+ ;; Regular files.
+ ((get-text-property 1 'helm-ff-file file)
+ (add-face-text-property 0 len 'helm-ff-file t disp)
+ (cons disp file))
+ ;; Tramp methods.
+ ((string-match helm-ff-tramp-method-regexp file)
+ (let ((method (match-string 1 file))
+ (mh (helm-ff--tramp-multihops-p
helm-pattern)))
+ (cons (propertize (concat (if mh "" "/") method)
'face 'helm-ff-file)
+ (if mh
+ (concat (match-string 1 helm-pattern) ":"
method)
+ (concat "/:" method)))))
+ ;; non existing files.
+ (t
+ (add-face-text-property 0 len 'helm-ff-file t disp)
+ (helm-aif tramp-invalid-fname
+ (add-text-properties 0 len `(host ,it) disp))
+ (cons (helm-ff-prefix-filename
+ disp
+ tramp-invalid-fname
+ (unless tramp-invalid-fname 'new-file))
+ file)))
;; Highlight local files showing everything, symlinks, exe,
;; dirs etc...