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

Fix parsing for (def |foo bar| #1114

Merged
merged 2 commits into from
Sep 28, 2023
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
7 changes: 3 additions & 4 deletions extensions/lisp-mode/detective.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
(%default-capture 'lem/detective:package-reference position))

(defmethod capture-reference ((position lem:point) (class (eql :misc-reference)))
(let* ((line (str:split #\Space (line-string position)))
(type (str:replace-all "(" "" (first line)))
(name (remove #\) (second line))))
(ppcre:register-groups-bind (type name)
("^\\s*\\(\\s*(\\w+)\\s+(.*)\\s*" (line-string position))
(make-instance 'lem/detective:misc-reference
:misc-custom-type type
:reference-name name
:reference-name (string-right-trim '(#\space #\tab) name)
:reference-point position)))
28 changes: 14 additions & 14 deletions src/ext/detective.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
:navigate-reference

:move-to-reference)

#+sbcl
(:lock t))

(in-package :lem/detective)

(defclass reference ()
((name :type string
((name :type string
:initarg :reference-name
:reader reference-name)

Expand Down Expand Up @@ -168,7 +168,7 @@
(with-point ((p (buffer-start-point (point-buffer (current-point)))))
(loop :for point = (search-forward-regexp p (capture-regex-regex regex))
:while point
:collect (funcall (capture-regex-function regex)
:collect (funcall (capture-regex-function regex)
(copy-point point :temporary)
class)))))
(with-accessors ((function-regex search-function-regex)
Expand All @@ -183,7 +183,7 @@
(cons (cons "packages" package-regex) :package-reference)
(cons (cons "variables" variable-regex) :variable-reference)
(cons (cons "misc" misc-regex) :misc-reference))))

(setf (buffer-references (current-buffer))
(make-hash-table :test 'equal))

Expand Down Expand Up @@ -244,16 +244,16 @@
(let ((closest (%closest-reference))
(current-expression
(lem:with-point ((p point))
(funcall
(variable-value 'lem/language-mode:beginning-of-defun-function :buffer)
p 1) p)))

(if (= (line-number-at-point (car closest))
(line-number-at-point current-expression))
(find (car closest)
(cdr closest)
:key #'reference-point :test #'point=)
(message "Not inside a reference."))))
(funcall (variable-value 'lem/language-mode:beginning-of-defun-function :buffer)
p 1)
p)))

(if (= (line-number-at-point (car closest))
(line-number-at-point current-expression))
(find (car closest)
(cdr closest)
:key #'reference-point :test #'point=)
(message "Not inside a reference."))))

(defun %closest-reference (&key (direction :up))
(let* ((references (buffer-references (current-buffer)))
Expand Down