Skip to content

Commit

Permalink
extract package
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 28, 2023
1 parent a885028 commit eb5d8b1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
1 change: 1 addition & 0 deletions extensions/lisp-mode/lem-lisp-mode.asd
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
(:file "class-browser")
(:file "macroexpand")
(:file "test-runner")
(:file "utopian")
(:file "package")))

(defsystem "lem-lisp-mode/v2"
Expand Down
42 changes: 0 additions & 42 deletions extensions/lisp-mode/misc-commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,6 @@
(:use :cl :lem :lem-lisp-mode/internal))
(in-package :lem-lisp-mode/misc-commands)

(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*)


(define-command lisp-defstruct-to-defclass () ()
(lem-lisp-syntax:defstruct-to-defclass (current-point)))

Expand Down
44 changes: 44 additions & 0 deletions extensions/lisp-mode/utopian.lisp
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*)

0 comments on commit eb5d8b1

Please sign in to comment.