Skip to content

Commit

Permalink
[Fix #589] Don't prefer local paths over tramp by default.
Browse files Browse the repository at this point in the history
Rename `cider-use-local-resources` to `cider-prefer-local-resources` and
set default value to nil.

Remove `cider-home-prefix-adjustment`. It was unnecessary, and a bug in
`cider-emacs-or-clojure-side-adjustment` prevented it working
as (apparently) designed anyway.

Rename `cider-emacs-or-clojure-side-adjustment` to `cider-file-path` for
clarity (and brevity!).
  • Loading branch information
jeffvalk committed Jun 1, 2014
1 parent 7a63d2b commit 71e015a
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@
(defconst cider-doc-buffer "*cider-doc*")
(defconst cider-result-buffer "*cider-result*")

(defcustom cider-use-local-resources t
"Use local resources under HOME if possible."
(define-obsolete-variable-alias 'cider-use-local-resources
'cider-prefer-local-resources "0.7.0")

(defcustom cider-prefer-local-resources nil
"Prefer local resources to remote (tramp) ones when both are available."
:type 'boolean
:group 'cider)

Expand Down Expand Up @@ -491,30 +494,16 @@ otherwise, nil."
localname)
name))

(defun cider-home-prefix-adjustment (resource)
"System-dependent HOME location will be adjusted in RESOURCE.
Removes any leading slash if on Windows."
(save-match-data
(cond ((string-match "^\\/\\(Users\\|home\\)\\/\\w+\\(\\/.+\\)" resource)
(concat (getenv "HOME") (match-string 2 resource)))
((and (eq system-type 'windows-nt)
(string-match "^/" resource)
(not (tramp-tramp-file-p resource)))
(substring resource 1))
(t
resource))))

(defun cider-emacs-or-clojure-side-adjustment (resource)
"Fix the RESOURCE path depending on `cider-use-local-resources`."
(let ((resource (cider-home-prefix-adjustment resource))
(clojure-side-res (concat (cider-tramp-prefix) resource))
(emacs-side-res resource))
(cond ((equal resource "") resource)
((and cider-use-local-resources
(file-exists-p emacs-side-res))
emacs-side-res)
((file-exists-p clojure-side-res)
clojure-side-res)
(defun cider-file-path (resource)
"Return RESOURCE's local or remote path using `cider-prefer-local-resources'."
(let ((local-path resource)
(remote-path (concat (cider-tramp-prefix) resource)))
(cond ((equal resource "") "")
((and cider-prefer-local-resources
(file-exists-p local-path))
local-path)
((file-exists-p remote-path)
remote-path)
(t
resource))))

Expand All @@ -523,7 +512,7 @@ Removes any leading slash if on Windows."
Adjusts for HOME location using `cider-home-prefix-adjustment'.
Uses `find-file'."
(let ((large-file-warning-threshold nil))
(find-file (cider-emacs-or-clojure-side-adjustment filename))))
(find-file (cider-file-path filename))))

(defun cider-find-resource (resource)
"Find and display RESOURCE."
Expand All @@ -532,7 +521,7 @@ Uses `find-file'."
((string-match "^\\(jar\\|zip\\):file:\\(.+\\)!/\\(.+\\)" resource)
(let* ((jar (match-string 2 resource))
(path (match-string 3 resource))
(file (cider-emacs-or-clojure-side-adjustment jar))
(file (cider-file-path jar))
(name (format "%s:%s" jar path)))
(switch-to-buffer
(or (get-file-buffer name)
Expand Down

0 comments on commit 71e015a

Please sign in to comment.