Skip to content

Commit

Permalink
ivy.el: Fix some string predicates
Browse files Browse the repository at this point in the history
(ivy--dirname-p, ivy--magic-file-slash): Simplify now that Ivy
requires Emacs 24.5 or later by using string-suffix-p instead of
slower regexp matching.
(ivy--occur-insert-lines): Escape leading dot in regexp by using
existing helper ivy--starts-with-dotslash.

Re: abo-abo#1817, abo-abo#1845, abo-abo#1846
  • Loading branch information
basil-conto authored and astoff committed Jan 1, 2021
1 parent a7e9600 commit 2dc2740
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ivy.el
Expand Up @@ -2078,7 +2078,7 @@ An :init is a function with no arguments.
#'directory-name-p
(lambda (name)
"Return non-nil if NAME ends with a directory separator."
(string-match-p "/\\'" name))))
(string-suffix-p "/" name))))

(defun ivy--sorted-files (dir)
"Return the list of files in DIR.
Expand Down Expand Up @@ -3251,7 +3251,7 @@ Possible choices are 'ivy-magic-slash-non-match-cd-selected,
(cond ((member ivy-text ivy--all-candidates)
(ivy--cd canonical))
((and (eq system-type 'windows-nt) (string= ivy-text "//")))
((string-match-p "//\\'" ivy-text)
((string-suffix-p "//" ivy-text)
(ivy--cd
(ivy--magic-file-doubleslash-directory)))
((string-match-p "\\`/ssh:" ivy-text)
Expand Down Expand Up @@ -5038,7 +5038,7 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
highlight
help-echo "mouse-1: call ivy-action")
cand)
(insert (if (string-match-p "\\`.[/\\]" cand) "" " ")
(insert (if (ivy--starts-with-dotslash cand) "" " ")
cand ?\n)))

(defun ivy--occur-default (cands)
Expand Down

0 comments on commit 2dc2740

Please sign in to comment.