2017-04-20 61 views
0

如何編譯使用cl-annot註釋的函數?如何在Slime中使用cl-annot(在盧塞恩定義另一個視圖)

使用案例:

Lucerne使用它來定義路線:

@route app "/profile/:username" 
(defview profile (username) 
    (let* ((user (utweet.models:find-user username)) 
     ;; The user's timeline 
     (user-tweets (utweet.models:user-tweets user)) 
     ;; Is the user viewing his own profile? 
     (is-self (string= (lucerne-auth:get-userid) 
          username))) 
    (render-template (+profile+) 
        :user user 
        :tweets (display-tweets user-tweets) 
        :is-self is-self))) 

我做了一個視圖中工作。但編寫第二個並用C-c-c編譯它將不起作用。我安裝slime-annot.el爲Emacs,但我只得到

The variable @ROUTE is unbound. [Condition of type UNBOUND-VARIABLE]

我一開始寫(annot:enable-annot-syntax)

所以這是一個阻礙點:/我們如何使用cl-annot定義新的東西?

感謝

PS:related issue

編輯:更多有關的文件結構:我創建了盧塞恩的工程創建一個項目,這是我的主文件的開頭:

(in-package :cl-user) 
(defpackage lucerne-books 
    (:use :cl 
     :lucerne 
     :cl-arrows 
     :str) 
    (:export :app) 
    (:documentation "Main lucerne-books code.")) 
(in-package :lucerne-books) 
(annot:enable-annot-syntax) 

;;; App 

(defapp app 
    :middlewares ((clack.middleware.static:<clack-middleware-static> 
       :root (asdf:system-relative-pathname :lucerne-books #p"assets/") 
       :path "/static/"))) 

;;; Templates 

(djula:add-template-directory 
(asdf:system-relative-pathname :lucerne-books #p"templates/")) 

(defparameter +index+ (djula:compile-template* "index.html")) 

;;; Views 

@route app "/" ;; first created: it works 
(defview index() 
    (render-template (+index+) 
        :foo "you")) 

@route app "/rst" ;; this view won't work, not accessible 
(defview index() 
    (render-template (+index+) 
        :foo "rst")) 

@route app "/following/:username" ;; this one neither 
(defview user-following (username) 
    (let ((user username)) 
    (render-template (+index+) 
        :foo user))) 
+0

我不知道Lucrene,但我最近使用了cl-annot沒有問題。如文檔中所述,您是否在文件的開頭插入了「(annot:enable-annot-syntax)」?你能否提供關於你的文件結構的更多信息? –

+0

是的,我啓用了annot語法。我用我的代碼和文件結構的更多信息編輯了我的問題。 – Ehvince

+0

它與我在穴居人項目中找到的'(syntax:use-syntax:annot)'一起工作。不要因爲我爲什麼! – Ehvince

回答

0

我在穴居人項目上發現了不同的符號。它不會出現在CL-ANNOT的文件,但它的工作原理:

(syntax:use-syntax :annot) 

我現在可以C-c C-c新航線。

相關問題