Function: projectile--rake-task-names
projectile--rake-task-names is a byte-compiled function defined in
projectile.el.
Signature
(projectile--rake-task-names FILE)
Documentation
Return the names of the rake tasks defined in FILE.
Only tasks whose name is written out literally are returned: a name
built from a variable (task type, [:id]) can't be known without
running rake, which this deliberately doesn't do. Names are qualified
with the namespace blocks they sit in, so a task is returned under the
name you'd actually invoke it by.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--rake-task-names (file)
"Return the names of the rake tasks defined in FILE.
Only tasks whose name is written out literally are returned: a name
built from a variable (`task type, [:id]') can't be known without
running rake, which this deliberately doesn't do. Names are qualified
with the `namespace' blocks they sit in, so a task is returned under the
name you'd actually invoke it by."
(let ((names nil)
;; Stack of (INDENT . NAME) for the `namespace' blocks we're in.
(namespaces nil))
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(let ((case-fold-search nil))
(while (not (eobp))
(let ((indent (current-indentation)))
(cond
;; Leaving a block: drop the namespace it opened, if any.
((looking-at "[ \t]*end\\_>")
(when (and namespaces (<= indent (caar namespaces)))
(pop namespaces)))
((looking-at "[ \t]*namespace[ \t]+[:'\"]?\\([a-zA-Z0-9_][a-zA-Z0-9_-]*\\)")
(push (cons indent (match-string 1)) namespaces))
;; `task' followed by whitespace - not `task.files = ...',
;; which is a method call on a block argument.
((looking-at
(concat "[ \t]*\\(?:multi\\)?task[ \t]+"
;; :symbol | 'string' | "string" | bare-word:
"\\(?::\\([a-zA-Z0-9_][a-zA-Z0-9_:-]*\\)"
"\\|[\"']\\([^\"'\n]+\\)[\"']"
"\\|\\([a-zA-Z0-9_][a-zA-Z0-9_-]*\\):\\)"))
(let* ((name (or (match-string 1) (match-string 2) (match-string 3)))
(qualified (string-join
(append (reverse (mapcar #'cdr namespaces))
(list name))
":")))
(unless (member qualified names)
(push qualified names))))))
(forward-line 1))))
(nreverse names)))