From: "numbchild@gmail.com" <numbchild@gmail.com>
To: Emanuel Berg <moasenwood@zoho.eu>, emacs-help <help-gnu-emacs@gnu.org>
Subject: [SOLVED] Re: How to detect two emacs process in Elisp code?
Date: Thu, 3 Sep 2020 10:45:09 +0800 [thread overview]
Message-ID: <CAL1eYu+8rytD3To6Xv6qq1MqhWc0PtuVkaRisSzcQVxkUB+oAA@mail.gmail.com> (raw)
In-Reply-To: <87363z8tvl.fsf@ebih.ebihd>
Thanks for quick reply. Confirmed it solved my problem. Thanks very much!
[stardiviner] <Hack this world!> GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter: @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/
On Thu, Sep 3, 2020 at 10:41 AM Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> stardiviner wrote:
>
> > I load desktop-save-mode session in init.el.
> > But when using "bug-hunter-init-file", I need to
> > exclude this session init file.
> >
> > Here is my try:
> >
> > #+begin_src emacs-lisp
> > ;;; detect external system has Emacs process running?
> > ;;; If yes, like `bug-hunter' is running. Then don't load session.
> > ;;; FIXME
> > (let ((emacs-processes
> > (length (mapcar
> > 'string-to-number
> > (seq-filter
> > (lambda (str)
> > (not (string-empty-p str)))
> > (split-string
> > ;; (shell-command-to-string "ps -C emacs -o pid=")
> > (shell-command-to-string "ps -C emacs -o pid=")
> > "\n"))))))
> > (when (<= emacs-processes 1)
> > (message "init-emacs-session loading")
> > (require 'init-emacs-session)))
> > #+end_src
>
> Try this:
>
> (require 'seq)
> (defun how-many-emacs ()
> (let ((emacs-processes
> (length (mapcar
> #'string-to-number
> (seq-filter
> (lambda (str)
> (not (string-empty-p str)) )
> (split-string
> (shell-command-to-string "ps -C emacs -o pid=")
> "\n") )))))
> (message (format "Emacs process: %d" emacs-processes)) ))
> ;; (how-many-emacs) ; 1
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
next prev parent reply other threads:[~2020-09-03 2:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 14:54 How to detect two emacs process in Elisp code? stardiviner
2020-09-03 2:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-03 2:45 ` numbchild [this message]
2020-09-03 2:47 ` [SOLVED] " Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-03 2:50 ` numbchild
2020-09-03 13:13 ` Eli Zaretskii
2020-09-03 17:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-04 3:57 ` stardiviner
2020-09-04 4:28 ` Emanuel Berg via Users list for the GNU Emacs text editor
-- strict thread matches above, loose matches on Subject: below --
2020-07-18 5:55 numbchild
2020-07-18 12:25 ` Noam Postavsky
2020-07-18 14:01 ` [SOLVED] " numbchild
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAL1eYu+8rytD3To6Xv6qq1MqhWc0PtuVkaRisSzcQVxkUB+oAA@mail.gmail.com \
--to=numbchild@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).