Oh, my fault, this is really works. Thank you!

There is also an incomplete API available to view at 
> http://lighttable.github.io/LightTable/api/
>

Yes, that's what I asked for, thanks!

Can I ask another question?) I want to execute shell command via user 
script. I tried to create this command:

(defn get-folder [path]
  (reduce #(str %1 "/" %2) (butlast (.split path "\\"))))

(require '(clojure.java shell))      ;'

(defn exec-shell [file & commands]
  (println (:out (clojure.java.shell/sh "cmd" "/c" (str "cd " (get-folder 
file)) (reduce #(str %1 " & " %2) "" commands)))))

(cmd/command {:command :user.lein-deps
              :desc "User: Lein Deps"
              :exec (fn []
                      (let [ed (lt.objs.editor.pool/last-active)]
                        (exec-shell (-> @ed :info :path) "lein deps")))})

But as I found I can't use clojure or java libs from the user script. So, 
is there a way to execute a shell command from here?

вторник, 21 февраля 2017 г., 6:49:16 UTC+5 пользователь Scott Bauer написал:
>
> The command snippet appears to work fine if you do not deref `ed`... in 
> other words:
>
> (cmd/command {:command :user.say-hello
>               :desc "User: Say Hello"
>               :exec (fn []
>                       (let [ed (lt.objs.editor.pool/last-active)]
>                         (lt.objs.editor/center-cursor ed)))})
>
> should suffice. I was able to successfully use the command to bring the 
> viewport back to the cursor and have the cursor be on the center line. 
> Perhaps there was an issue with the command not being refreshed after 
> compiling changes? If so, you should be able to reopen Light Table and have 
> the modified command available.
>
> As for full documentation, that is still a work in progress. The gitbook 
> link you provided should eventually contain sufficient plugin development 
> docs. There is also an incomplete API available to view at 
> http://lighttable.github.io/LightTable/api/ . We plan to expand both this 
> year.
>
> Hope that helps,
>
> Scott
>
>
> On Monday, February 20, 2017 at 11:44:04 AM UTC-5, Max Muranov wrote:
>>
>> I think it's a usual sutiation: I haven't found one useful function in 
>> the light table and want to write it myself. It's a simple function and I 
>> want to just put it to user script. 
>>
>> Found this quick start guide for plugin development: 
>> https://lighttable.gitbooks.io/light-table-developers-guide/content/user-plugin.html
>> Okay but... What about full documentation? I want to use functions that 
>> are not in this guide. 
>>
>> I didn't found something similar to functions docs and assumed that I can 
>> find them in the sources. 
>>
>>
>> https://github.com/LightTable/LightTable/blob/master/src/lt/objs/editor.cljs
>> I found a function in this file and tried to do something simpliest:
>>
>> (cmd/command {:command :user.say-hello
>>               :desc "User: Say Hello"
>>               :exec (fn []
>>                       (let [ed (lt.objs.editor.pool/last-active)]
>>                         (lt.objs.editor/center-cursor @ed)))})
>>                       ;;;;;;;;;;;;(tabs/add-or-focus! hello))})
>>
>> And this causes an exception "TypeError: 
>> lt.objs.editor.__GT_cm_ed.call(...).getCursor is not a function". 
>>
>> What am I doing wrong? And where can I find something similar to plugin 
>> development docs? Help, I can't understand anything =D
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Light Table Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to light-table-discussion+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to