Skip to content

Commit 3f5d152

Browse files
committed
cleanup, add docstrings
1 parent dde0c0e commit 3f5d152

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

cider-util.el

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,29 +516,39 @@ Any other value is just returned."
516516
x))
517517

518518

519-
;;; Files
519+
;;; Files & Directories
520520
(defun cider--ensure-executable (file)
521+
"Try to make FILE executable if it isn't already.
522+
Returns FILE on success, nil on failure."
521523
(with-demoted-errors "Error while trying to make file executable:\n %s"
522524
(when (or (file-executable-p file)
523525
(and (set-file-modes file "u+x")
524526
(file-executable-p file)))
525527
file)))
526528

527-
(defconst cider--temp-name-prefix ".cider__")
529+
(defconst cider--temp-name-prefix ".cider__"
530+
"Prefix for marking temporary files created by cider.")
528531

529532
(defun cider--make-temp-name (file)
533+
"Generate a randomized name from FILEs basename.
534+
Tag it with `cider--temp-name-prefix'"
530535
(make-temp-name
531536
(concat cider--temp-name-prefix (file-name-nondirectory file) "__")))
532537

533538
(defun cider--make-nearby-temp-copy (file)
539+
"Create a copy of FILE in the default local or remote tempdir.
540+
Falls back to `clojure-project-dir' or `default-directory'.
541+
The copy is marked with `cider--temp-name-prefix'."
534542
(let* ((default-directory (or (clojure-project-dir) default-directory))
535-
;; Note: (temporary-file-directory) uses `default-directory' as fallback.
536543
(new-file (file-name-concat (temporary-file-directory)
537544
(cider--make-temp-name file))))
538545
(copy-file file new-file :exists-ok nil nil :keep-permissions)
539546
new-file))
540547

541-
(defun cider--inject-self-delete (bash-script)
548+
(defun cider--inject-self-delete (bash-file)
549+
"Make BASH-FILE delete itself on exit.
550+
Injects the self-delete script after the first line, assuming it is a
551+
shebang."
542552
(let (;; Don't create any temporary files.
543553
(remote-file-name-inhibit-locks t)
544554
(remote-file-name-inhibit-auto-save-visited t)
@@ -547,7 +557,7 @@ Any other value is just returned."
547557
;; Disable version-control check
548558
(vc-handled-backends nil))
549559
(with-temp-buffer
550-
(insert-file-contents bash-script)
560+
(insert-file-contents bash-file)
551561
;; inject after the first line, assuming it is the shebang
552562
(goto-char (point-min))
553563
(skip-chars-forward "^\n")
@@ -558,9 +568,9 @@ Any other value is just returned."
558568
echo \"cider: Cleaned up temporary script after use.\"
559569
exit $ARG
560570
' EXIT"
561-
(file-local-name bash-script)))
562-
(write-file bash-script))
563-
bash-script))
571+
(file-local-name bash-file)))
572+
(write-file bash-file))
573+
bash-file))
564574

565575

566576
;;; Help mode

cider.el

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ Returns the local path to the script or nil."
434434
"Get or create an executable enrich-classpath script for PROJECT-TYPE.
435435
If `default-directory' is remote, create a copy at
436436
'<remote-tempdir>/.cider__<script-name>__<random>' that deletes itself after
437-
use. The search for <remote-tempdir> is handled by tramp and falls back to
438-
`default-directory'. Returns nil if anything goes wrong."
437+
use. The search for '<remote-tempdir>' is handled by tramp and falls back to
438+
`clojure-project-dir' or `default-directory'. Returns nil if anything goes wrong."
439439
(when-let* ((cider-dir (file-name-directory (locate-library "cider.el" t)))
440440
(name (map-elt cider--enrich-classpath-script-names project-type))
441441
(location (concat cider-dir name))
@@ -2143,8 +2143,9 @@ M-2 \\[cider-jack-in-universal]."
21432143

21442144

21452145
(defun cider--resolve-command (command)
2146-
"Find COMMAND in exec-path and shell-quote it.
2147-
Return nil if not found."
2146+
"Test if COMMAND exists, is executable and shell-quote it.
2147+
Return nil otherwise. When `default-directory' is remote, the check is
2148+
performed by tramp."
21482149
(when-let* ((command (or (executable-find command :remote)
21492150
(executable-find (concat command ".bat")))))
21502151
(shell-quote-argument command)))

0 commit comments

Comments
 (0)