@@ -185,7 +185,7 @@ For example, \[ is allowed in :db/id[:db.part/user]."
185185
186186(defcustom clojure-build-tool-files '(" project.clj" " build.boot" " build.gradle" )
187187 " A list of files, which identify a Clojure project's root.
188- Out-of-the box clojure-mode understands lein, boot and gradle."
188+ Out-of-the box ` clojure-mode' understands lein, boot and gradle."
189189 :type '(repeat string)
190190 :package-version '(clojure-mode . " 5.0.0" )
191191 :safe (lambda (value )
@@ -317,7 +317,7 @@ CIDER provides a more complex version which does classpath analysis.")
317317 (message " clojure-mode (version %s ) " clojure-mode-version))
318318
319319(defconst clojure-mode-report-bug-url " https://github.com/clojure-emacs/clojure-mode/issues/new"
320- " The URL to report a clojure-mode issue." )
320+ " The URL to report a ` clojure-mode' issue." )
321321
322322(defun clojure-mode-report-bug ()
323323 " Report a bug in your default browser."
@@ -458,7 +458,14 @@ ENDP and DELIMITER."
458458(declare-function paredit-convolute-sexp " ext:paredit" )
459459
460460(defun clojure--replace-let-bindings-and-indent (orig-fun &rest args )
461- " Advise `paredit-convolute-sexp' to replace s-expressions with their bound name if a let form was convoluted."
461+ " Advise ORIG-FUN to replace let bindings.
462+
463+ Sexps are replace by their bound name if a let form was
464+ convoluted.
465+
466+ ORIG-FUN should be `paredit-convolute-sexp' .
467+
468+ ARGS are passed to ORIG-FUN, as with all advice."
462469 (save-excursion
463470 (backward-sexp )
464471 (when (looking-back clojure--let-regexp)
@@ -520,13 +527,14 @@ replacement for `cljr-expand-let`."
520527 (add-hook 'paredit-mode-hook #'clojure-paredit-setup ))
521528
522529(defcustom clojure-verify-major-mode t
523- " If non-nil, warn when activating the wrong major-mode."
530+ " If non-nil, warn when activating the wrong ` major-mode' ."
524531 :type 'boolean
525532 :safe #'booleanp
526533 :package-version '(clojure-mode " 5.3.0" ))
527534
528535(defun clojure--check-wrong-major-mode ()
529- " Check if the current major-mode matches the file extension.
536+ " Check if the current `major-mode' matches the file extension.
537+
530538If it doesn't, issue a warning if `clojure-verify-major-mode' is
531539non-nil."
532540 (when (and clojure-verify-major-mode
@@ -1107,8 +1115,11 @@ Place point as in `clojure--position-for-alignment'."
11071115
11081116(defun clojure--search-whitespace-after-next-sexp (&optional bound _noerror )
11091117 " Move point after all whitespace after the next sexp.
1118+
11101119Set the match data group 1 to be this region of whitespace and
1111- return point."
1120+ return point.
1121+
1122+ BOUND is bounds the whitespace search."
11121123 (unwind-protect
11131124 (ignore-errors
11141125 (clojure-forward-logical-sexp 1 )
@@ -1835,6 +1846,9 @@ list of (fn args) to pass to `apply''"
18351846 (insert " \n " )))
18361847
18371848(defun clojure--unwind-last ()
1849+ " Unwind a thread last macro once.
1850+
1851+ Point must be between the opening paren and the ->> symbol."
18381852 (forward-sexp )
18391853 (save-excursion
18401854 (let ((beg (point ))
@@ -1857,13 +1871,15 @@ list of (fn args) to pass to `apply''"
18571871 (forward-char ))
18581872
18591873(defun clojure--ensure-parens-around-function-names ()
1874+ " Insert parens around function names if necessary."
18601875 (clojure--looking-at-non-logical-sexp)
18611876 (unless (looking-at " (" )
18621877 (insert-parentheses 1 )
18631878 (backward-up-list )))
18641879
18651880(defun clojure--unwind-first ()
18661881 " Unwind a thread first macro once.
1882+
18671883Point must be between the opening paren and the -> symbol."
18681884 (forward-sexp )
18691885 (save-excursion
@@ -1879,12 +1895,14 @@ Point must be between the opening paren and the -> symbol."
18791895 (forward-char ))
18801896
18811897(defun clojure--pop-out-of-threading ()
1898+ " Raise a sexp up a level to unwind a threading form."
18821899 (save-excursion
18831900 (down-list 2 )
18841901 (backward-up-list )
18851902 (raise-sexp )))
18861903
18871904(defun clojure--nothing-more-to-unwind ()
1905+ " Return non-nil if a threaded form cannot be unwound further."
18881906 (save-excursion
18891907 (let ((beg (point )))
18901908 (forward-sexp )
@@ -1895,6 +1913,10 @@ Point must be between the opening paren and the -> symbol."
18951913 (= beg (point )))))
18961914
18971915(defun clojure--fix-sexp-whitespace (&optional move-out )
1916+ " Fix whitespace after unwinding a threading form.
1917+
1918+ Optional argument MOVE-OUT, if non-nil, means moves up a list
1919+ before fixing whitespace."
18981920 (save-excursion
18991921 (when move-out (backward-up-list ))
19001922 (let ((sexp (bounds-of-thing-at-point 'sexp )))
@@ -1933,10 +1955,12 @@ Return nil if there are no more levels to unwind."
19331955 (while (clojure-unwind)))
19341956
19351957(defun clojure--remove-superfluous-parens ()
1958+ " Remove extra parens from a form."
19361959 (when (looking-at " ([^ )]+)" )
19371960 (delete-pair )))
19381961
19391962(defun clojure--thread-first ()
1963+ " Thread a nested sexp using ->."
19401964 (down-list )
19411965 (forward-symbol 1 )
19421966 (unless (looking-at " )" )
@@ -1954,6 +1978,7 @@ Return nil if there are no more levels to unwind."
19541978 t )))
19551979
19561980(defun clojure--thread-last ()
1981+ " Thread a nested sexp using ->>."
19571982 (forward-sexp 2 )
19581983 (down-list -1 )
19591984 (backward-sexp )
@@ -1972,6 +1997,7 @@ Return nil if there are no more levels to unwind."
19721997 t )))
19731998
19741999(defun clojure--threadable-p ()
2000+ " Return non-nil if a form can be threaded."
19752001 (save-excursion
19762002 (forward-symbol 1 )
19772003 (looking-at " [\n\r\t ]*(" )))
@@ -1993,6 +2019,12 @@ Return nil if there are no more levels to unwind."
19932019 (clojure--fix-sexp-whitespace 'move-out ))))
19942020
19952021(defun clojure--thread-all (first-or-last-thread but-last )
2022+ " Fully thread the form at point.
2023+
2024+ FIRST-OR-LAST-THREAD is \" ->\" or \" ->>\" .
2025+
2026+ When BUT-LAST is non-nil, the last expression is not threaded.
2027+ Default value is `clojure-thread-all-but-last' ."
19962028 (save-excursion
19972029 (insert-parentheses 1 )
19982030 (insert first-or-last-thread))
@@ -2003,14 +2035,18 @@ Return nil if there are no more levels to unwind."
20032035;;;### autoload
20042036(defun clojure-thread-first-all (but-last )
20052037 " Fully thread the form at point using ->.
2006- When BUT-LAST is passed the last expression is not threaded."
2038+
2039+ When BUT-LAST is non-nil, the last expression is not threaded.
2040+ Default value is `clojure-thread-all-but-last' ."
20072041 (interactive " P" )
20082042 (clojure--thread-all " -> " but-last))
20092043
20102044;;;### autoload
20112045(defun clojure-thread-last-all (but-last )
20122046 " Fully thread the form at point using ->>.
2013- When BUT-LAST is passed the last expression is not threaded."
2047+
2048+ When BUT-LAST is non-nil, the last expression is not threaded.
2049+ Default value is `clojure-thread-all-but-last' ."
20142050 (interactive " P" )
20152051 (clojure--thread-all " ->> " but-last))
20162052
@@ -2161,9 +2197,13 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-cycle-if"
21612197
21622198(defvar clojure--let-regexp
21632199 " \( \\ (when-let\\ |if-let\\ |let\\ )\\ (\\ s-*\\ |\\ [\\ )"
2164- " Regexp matching let like expressions, i.e. let, when-let, if-let.
2200+ " Regexp matching let like expressions, i.e. \" let\" , \" when-let\" , \" if-let\" .
2201+
2202+ The first match-group is the let expression.
21652203
2166- The first match-group is the let expression, the second match-group is the whitespace or the opening square bracket if no whitespace between the let expression and the bracket." )
2204+ The second match-group is the whitespace or the opening square
2205+ bracket if no whitespace between the let expression and the
2206+ bracket." )
21672207
21682208(defun clojure--goto-let ()
21692209 " Go to the beginning of the nearest let form."
@@ -2177,6 +2217,7 @@ The first match-group is the let expression, the second match-group is the white
21772217 (looking-at clojure--let-regexp))
21782218
21792219(defun clojure--inside-let-binding-p ()
2220+ " Return non-nil if point is inside a let binding."
21802221 (ignore-errors
21812222 (save-excursion
21822223 (let ((pos (point )))
@@ -2225,12 +2266,18 @@ Assume that point is in the binding form of a let."
22252266 (newline-and-indent ))))
22262267
22272268(defun clojure--sexp-regexp (sexp )
2269+ " Return a regexp for matching SEXP."
22282270 (concat " \\ ([^[:word:]^-]\\ )"
22292271 (mapconcat #'identity (mapcar 'regexp-quote (split-string sexp))
22302272 " [[:space:]\n\r ]+" )
22312273 " \\ ([^[:word:]^-]\\ )" ))
22322274
22332275(defun clojure--replace-sexp-with-binding (bound-name init-expr )
2276+ " Replace a binding with its bound name in the let form.
2277+
2278+ BOUND-NAME is the name (left-hand side) of a binding.
2279+
2280+ INIT-EXPR is the value (right-hand side) of a binding."
22342281 (save-excursion
22352282 (while (re-search-forward
22362283 (clojure--sexp-regexp init-expr)
@@ -2240,6 +2287,7 @@ Assume that point is in the binding form of a let."
22402287
22412288(defun clojure--replace-sexps-with-bindings (bindings )
22422289 " Replace bindings with their respective bound names in the let form.
2290+
22432291BINDINGS is the list of bound names and init expressions."
22442292 (let ((bound-name (pop bindings))
22452293 (init-expr (pop bindings)))
@@ -2248,6 +2296,7 @@ BINDINGS is the list of bound names and init expressions."
22482296 (clojure--replace-sexps-with-bindings bindings))))
22492297
22502298(defun clojure--replace-sexps-with-bindings-and-indent ()
2299+ " Replace sexps with bindings."
22512300 (clojure--replace-sexps-with-bindings
22522301 (clojure--read-let-bindings))
22532302 (clojure-indent-region
@@ -2277,6 +2326,10 @@ Return a list: odd elements are bound names, even elements init expressions."
22772326 (nreverse bindings)))
22782327
22792328(defun clojure--introduce-let-internal (name &optional n )
2329+ " Create a let form, binding the form at point with NAME.
2330+
2331+ Optional numeric argument N, if non-nil, introduces the let N
2332+ lists up."
22802333 (if (numberp n)
22812334 (let ((init-expr-sexp (clojure-delete-and-extract-sexp)))
22822335 (insert name)
@@ -2299,6 +2352,7 @@ Return a list: odd elements are bound names, even elements init expressions."
22992352 (insert name)))
23002353
23012354(defun clojure--move-to-let-internal (name )
2355+ " Bind the form at point to NAME in the nearest let."
23022356 (if (not (save-excursion (clojure--goto-let)))
23032357 (clojure--introduce-let-internal name)
23042358 (let ((contents (clojure-delete-and-extract-sexp)))
0 commit comments