help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Emacsclient --eval with command line arguments.


From: Hongyi Zhao
Subject: Emacsclient --eval with command line arguments.
Date: Thu, 5 May 2022 09:23:58 +0800

I want to call Emacsclient to format the gap script with the following steps:

1. Put the following code snippet in scratch buffer, and `C-x C-e` it:

```emacs-lisp
(server-start)
(defun my-gap-format-file (file)
  "Open file, format as GAP, and save."
  (with-current-buffer (find-file "test.gap")
    (gap-format-buffer)
    (save-buffer)))
```
2. According to the comment here [1], I tried the following method but failed:

```shell
$ time emacsclient -s read --eval '(my-gap-format-file (file-truename
"'"$1"'"))' gap-test.g
emacsclient: Should XDG_RUNTIME_DIR='/run/user/1000' be in the environment?
emacsclient: (Be careful: XDG_RUNTIME_DIR is security-related.)
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: error accessing socket "read"

real    0m0.012s
user    0m0.009s
sys    0m0.005s
```

How can I run `emacsclient --eval` with command line arguments in this
situation?

[1] 
https://www.reddit.com/r/emacs/comments/hhbcg7/emacsclient_eval_with_command_line_arguments/

Regards
-- 
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



reply via email to

[Prev in Thread] Current Thread [Next in Thread]