all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Emacsclient --eval with command line arguments.
Date: Thu, 5 May 2022 09:23:58 +0800	[thread overview]
Message-ID: <CAGP6PO+=bEZpyvAUzs2AzyzMuRjA8YODdouzsEXDbZoZTboSxA@mail.gmail.com> (raw)

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	other threads:[~2022-05-05  1:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  1:23 Hongyi Zhao [this message]
2022-05-05 15:07 ` Emacsclient --eval with command line arguments Manuel Giraud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGP6PO+=bEZpyvAUzs2AzyzMuRjA8YODdouzsEXDbZoZTboSxA@mail.gmail.com' \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.