如何在Slime中使用cl-annot(在Lucerne中定义另一个视图)

时间:2017-04-20 22:57:53

标签: common-lisp 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编译它是行不通的。我为emacs安装了slime-annot.el,但我只能

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

我在开头写了(annot:enable-annot-syntax)

所以这是一个阻塞点:/我们如何使用cl-annot定义新东西?

由于

ps:related issue

编辑:有关文件结构的更多信息:我使用Lucerne的项目创建者创建了一个项目,这是我的主文件的开头:

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

1 个答案:

答案 0 :(得分:0)

我在Caveman项目中找到了不同的符号。它不会出现在cl-annot的doc上,但它有效:

(syntax:use-syntax :annot)

我现在可以C-c C-c新路线。