David Bjergaard <dbjerga...@gmail.com> writes: > Hi, > > I'm not entirely sure what's going wrong. Could you clarify what the > difference between working and not working? Also, you may not want the quote:
I think it's defcommand's problem, But I can't find the reason too for I can't find the error information. > > Two pieces of code you might want to use as a reference: > https://github.com/dss-project/dswm-modules/tree/master/emacs > and > https://gitorious.org/dss-project/stumpmacs/source/1a2d69f20f0843fce5c5213a539824020786ad27:stumpmacs/daemon.lisp#L99 this package is too complex for me ... > > I hope to integrate the latter some day... > > Does: > #+begin_src lisp > (defcommand gnus () () > (run-shell-command "emacsclient -c -e '(gnus)'")) > #+end_src It's work, Now I use function like this: #+begin_src (defun escape-instance-name (str) (let (buf) (map nil #'(lambda (ch) (if (or (char= ch #\() (char= ch #\)) (char= ch #\") (char= ch #\ )) (push #\_ buf) (push ch buf))) str) (coerce (reverse buf) 'string))) (defun emacsclient-eval (&optional expression create-frame frame-name file) (let ((name (or frame-name (escape-instance-name expression)))) (run-or-raise (concat "emacsclient --server-file=default " (when create-frame (concat "-c -F '((name . \"" name "\"))' ")) (when expression (concat " --eval '" expression "'")) file) (list :instance name)))) (defcommand org-capture-contacts () () (emacsclient-eval "(progn (kill-new \"\") (eh-org-capture nil \"contacts\"))")) #+end_src I don't like write sexp string, for example "(progn (kill-new \"\") (eh-org-capture nil \"contacts\"))" to my stumpwmrc, which will used by emacsclient as --eval argument. I find (string-downcase (prin1-to-string '(progn (kill-new "") (eh-org-capture nil "contacts")))) get "(progn (kill-new \"\") (eh-org-capture nil \"contacts\"))" and the first one is much cleaner for me ... > work? > Cheers, > > Dave > > > Feng Shu <tuma...@gmail.com> writes: > >> Hi: >> >> I defun a emacsclient-eval function like this >> >> #+begin_src lisp >> (defun escape-instance-name (str) >> (let (buf) >> (map nil #'(lambda (ch) >> (if (or (char= ch #\() >> (char= ch #\)) >> (char= ch #\") >> (char= ch #\ )) >> (push #\_ buf) >> (push ch buf))) >> str) >> (coerce (reverse buf) 'string))) >> >> (defun emacsclient-eval (&optional expression create-frame frame-name file) >> (let* ((expr-string (string-downcase (prin1-to-string expression))) >> (name (or frame-name >> (escape-instance-name expression)))) >> (run-or-raise >> (concat "emacsclient --server-file=default " >> (when create-frame (concat "-c -F '((name . \"" name "\"))' ")) >> (when expr-string (concat " --eval '" expr-string "'")) >> file) >> (list :instance name)))) >> >> #+end_src >> >> this can work, >> #+begin_src >> (emacsclient-eval '(gnus)) >> #+end_src >> >> but the follow command defun can't work, someone can help me? thanks! >> >> #+begin_src >> (defcommand gnus () () >> (emacsclient-eval '(gnus))) >> #+end_src >> >> -- feng shu >> >> >> _______________________________________________ >> Stumpwm-devel mailing list >> Stumpwm-devel@nongnu.org >> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel -- _______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/stumpwm-devel