Simplify and fix ‘vc-p4-is-in-client’
Quoting the string with Windows paths in it would double-quote the directory separators. It also seems easier to use ‘string-prefix-p’ than an anchored regular expression. ‘alist-get’ is a function that was introduced in Emacs 25 that is easier to use than ‘assoc’ + ‘cdr’.
This commit is contained in:
parent
d181ea1e1f
commit
d32dd5f376
1 changed files with 3 additions and 11 deletions
14
vc-p4.el
14
vc-p4.el
|
@ -892,17 +892,9 @@ If DIRNAME is not specified, uses `default-directory'."
|
|||
"Return true if FILE is inside the p4 client hierarchy."
|
||||
(let* ((default-directory (file-name-directory file))
|
||||
(info (p4-lowlevel-info))
|
||||
(root-pair (assoc "Client root" info))
|
||||
(root (and root-pair (cdr root-pair)))
|
||||
(quoted-root (and root (concat "^" (regexp-quote root))))
|
||||
(cwd-pair (assoc "Current directory" info))
|
||||
(cwd (and cwd-pair (cdr cwd-pair))))
|
||||
(if (or (not quoted-root) (not (string-match quoted-root cwd)))
|
||||
nil
|
||||
(setq cwd (replace-match "" nil nil cwd))
|
||||
(if (or (string= cwd "") (string-match "^/" cwd))
|
||||
t
|
||||
nil))))
|
||||
(root (alist-get "Client root" info))
|
||||
(cwd (alist-get "Current directory" info)))
|
||||
(string-prefix-p root cwd)))
|
||||
|
||||
(defun vc-p4-has-unresolved-conflicts-p (file)
|
||||
"Search through FILE's buffer for unresolved P4 conflicts.
|
||||
|
|
Loading…
Reference in a new issue