-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(defpackage :lem-lisp-mode/utopian | ||
(:use :cl :lem :lem-lisp-mode/internal)) | ||
(in-package :lem-lisp-mode/utopian) | ||
|
||
(defun find-utopian-route (point) | ||
(when (in-string-p point) | ||
(with-point ((start point) | ||
(end point)) | ||
(maybe-beginning-of-string start) | ||
(move-point end start) | ||
(character-offset start 1) | ||
(form-offset end 1) | ||
(character-offset end -1) | ||
(let* ((route (points-to-string start end)) | ||
(parts (uiop:split-string route :separator ":"))) | ||
(when (= 2 (length parts)) | ||
(destructuring-bind (path name) | ||
parts | ||
(let ((filename (expand-file-name | ||
(format nil "../controllers/~A.lisp" path) | ||
(buffer-directory (current-buffer))))) | ||
(unless (probe-file filename) | ||
(editor-error "~A does not exists" filename)) | ||
(lem/language-mode:make-xref-location | ||
:filespec (probe-file filename) | ||
:position (let ((buffer (find-file-buffer filename | ||
:temporary t | ||
:enable-undo-p nil))) | ||
(with-point ((point (buffer-point buffer))) | ||
(buffer-start point) | ||
(search-forward-regexp | ||
point | ||
`(:sequence | ||
"(def" | ||
(:greedy-repetition 1 nil (:CHAR-CLASS :WORD-CHAR-CLASS #\-)) | ||
(:greedy-repetition 1 nil :whitespace-char-class) | ||
(:greedy-repetition 0 1 #\() | ||
(:greedy-repetition 0 nil :whitespace-char-class) | ||
,name | ||
:whitespace-char-class)) | ||
(line-start point) | ||
(position-at-point point))))))))))) | ||
|
||
(pushnew 'find-utopian-route lem-lisp-mode/internal:*find-definitions*) |