Function: cider-ns-edit--alias-before-slash
cider-ns-edit--alias-before-slash is a byte-compiled function defined
in cider-ns.el.
Signature
(cider-ns-edit--alias-before-slash)
Documentation
Return the alias in front of the slash before point, or nil.
Nothing in a string, a comment or a discarded form counts, and neither does what comes before the slash of a qualified keyword (:foo/), a number (1/2), a tagged literal (#foo/), a quoted symbol, a class name, an array class (long/1), or a name in a :keys vector. The alias of an auto-resolved keyword (::foo/) does. So does a namespace name, which reads the same as an alias with dots (utils.strings/), but no namespace turns up for it.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-ns.el
(defun cider-ns-edit--alias-before-slash ()
"Return the alias in front of the slash before point, or nil.
Nothing in a string, a comment or a discarded form counts, and neither
does what comes before the slash of a qualified keyword (:foo/), a
number (1/2), a tagged literal (#foo/), a quoted symbol, a class name,
an array class (long/1), or a name in a :keys vector. The alias of an
auto-resolved keyword (::foo/) does. So does a namespace name, which
reads the same as an alias with dots (utils.strings/), but no namespace
turns up for it."
(let ((slash (1- (point)))
(case-fold-search nil))
(when (and (eq (char-after slash) ?/)
(not (nth 8 (syntax-ppss))))
(let* ((start (save-excursion
(goto-char slash)
(skip-chars-backward "^][(){}\"'` \t\n,;~@^")
(point)))
(token (buffer-substring-no-properties start slash))
(auto-resolved (string-prefix-p "::" token))
(alias (if auto-resolved (substring token 2) token)))
(when (and (string-match-p (if auto-resolved
;; nothing but an alias can go there
"\\`[[:alpha:]][^/]*\\'"
;; a capitalized segment makes it a
;; class
"\\`[[:lower:]][^/.]*\\(?:\\.[[:lower:]][^/.]*\\)*\\'")
alias)
(not (member alias cider-ns-edit--primitive-types))
(not (and (equal alias "js")
(not (equal (cider-ns-edit--platform) "clj"))))
;; 'a/b needs no alias, unlike #'a/b
(not (and (eq (char-before start) ?\')
(not (eq (char-before (1- start)) ?#))))
(not (cider-ns-edit--in-discarded-p slash))
(or auto-resolved
(not (cider-ns-edit--destructuring-p slash))))
alias)))))