@ -67,20 +67,27 @@ twister.conf file"
:type 'integer
:type 'integer
:group 'twister )
:group 'twister )
;; Preliminary convention
;; tw-* methods -> sorta private for now, don't use directly
;; twister-* methods -> public API
( defun twister-rpc ( method &rest params )
" Wrapper for the json-rpc method for twister use.
The connection is closed afer each use. This is not necessarily
the most effective. METHOD is the RPC method we are calling
while PARAMS contain the rest of the parameters. "
;; Get a connection to the twister daemon
( let* ( ( twisterd ( json-rpc-connect
( setf twisterd ( json-rpc-connect
twister-host twister-port
twister-host twister-port
twister-rpcuser twister-rpcpassword ) )
twister-rpcuser twister-rpcpassword ) )
;; Preliminary convention
( result ( apply 'json-rpc twisterd method params ) ) )
;; tw-* methods -> sorta private for now, don't use directly
( json-rpc-close twisterd )
;; twister-* methods -> public API
result ) )
( defun tw-get-last-post ( user )
( defun tw-get-last-post ( user )
" Get the last post of a user "
" Get the last post of a user "
( let ( obj ( json-new-object ) )
( let ( obj ( json-new-object ) )
( json-rpc twisterd " getposts " 1
( twister-rpc " getposts " 1
( vector ( json-add-to-object obj " username " user ) ) ) ) )
( vector ( json-add-to-object obj " username " user ) ) ) ) )
( defun tw-get-next-k ( user )
( defun tw-get-next-k ( user )
@ -95,12 +102,10 @@ twister.conf file"
" Post msg to the configured twister daemon "
" Post msg to the configured twister daemon "
( interactive )
( interactive )
( json-rpc
( twister-rpc " newpostmsg "
twisterd " newpostmsg "
twister-user
twister-user
( tw-get-next-k twister-user ) msg ) )
( tw-get-next-k twister-user ) msg ) )
( defun twister-post-region ( begin end )
( defun twister-post-region ( begin end )
" Post the current region to twister "
" Post the current region to twister "
( interactive " r " )
( interactive " r " )