Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vindarel/detective see macros #1627

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extensions/lisp-mode/ext/detective.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
(defmethod capture-reference ((position lem:point) (class (eql :package-reference)))
(%default-capture 'lem/detective:package-reference position))

(defmethod capture-reference ((position lem:point) (class (eql :macro-reference)))
(%default-capture 'lem/detective:macro-reference position))

(defmethod capture-reference ((position lem:point) (class (eql :misc-reference)))
(ppcre:register-groups-bind (type name)
("^\\s*\\(\\s*(\\w+)\\s+(.*)\\s*" (line-string position))
Expand Down
4 changes: 4 additions & 0 deletions extensions/lisp-mode/lisp-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
(lem/detective:make-capture-regex
:regex "^(?:\\(defvar |\\(defparameter )"
:function #'lem-lisp-mode/detective:capture-reference)
:macro-regex
(lem/detective:make-capture-regex
:regex "^\\(defmacro "
:function #'lem-lisp-mode/detective:capture-reference)
:misc-regex
(lem/detective:make-capture-regex
:regex "^\\(deftest "
Expand Down
18 changes: 18 additions & 0 deletions src/ext/detective.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
:variable-reference
:variable-reference-value

:macro-reference
:macro-reference-value

:misc-reference
:misc-custom-type

Expand Down Expand Up @@ -100,6 +103,9 @@
((value :initarg :variable-reference-value
:reader variable-reference-value)))

(defclass macro-reference (reference)
((value :initarg :macro-reference-value
:reader macro-reference-value)))

(defclass misc-reference (reference)
((custom-type :initarg :misc-custom-type
Expand Down Expand Up @@ -131,6 +137,10 @@
:initarg :variable-regex
:writer set-variable-regex
:reader search-variable-regex )
(macro-regex :type (or capture-regex null)
:initform nil
:initarg :macro-regex
:reader search-macro-regex)
(misc-regex :type (or capture-regex null)
:initform nil
:initarg :misc-regex
Expand Down Expand Up @@ -174,6 +184,7 @@
(with-accessors ((function-regex search-function-regex)
(package-regex search-package-regex)
(class-regex search-class-regex)
(macro-regex search-macro-regex)
(variable-regex search-variable-regex)
(misc-regex search-misc-regex))
search
Expand All @@ -182,6 +193,7 @@
(cons (cons "classes" class-regex) :class-reference)
(cons (cons "packages" package-regex) :package-reference)
(cons (cons "variables" variable-regex) :variable-reference)
(cons (cons "macros" macro-regex) :macro-reference)
(cons (cons "misc" misc-regex) :misc-reference))))

(setf (buffer-references (current-buffer))
Expand Down Expand Up @@ -289,6 +301,12 @@
(let ((reference (navigate-reference "functions")))
(move-to-reference reference)))

(define-command detective-macro () ()
"Prompt for a macro defined in this buffer and move to it."
(check-change)
(let ((reference (navigate-reference "macros")))
(move-to-reference reference)))

(define-command detective-class () ()
"Prompt for a class defined in this buffer and move to it."
(check-change)
Expand Down
Loading