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

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

[SOLVED] Re: How to detect two emacs process in Elisp code?


From: address@hidden
Subject: [SOLVED] Re: How to detect two emacs process in Elisp code?
Date: Sat, 18 Jul 2020 22:01:21 +0800

Really thanks, Noam. You're awesome! This solved my problem.

[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 Sat, Jul 18, 2020 at 8:25 PM Noam Postavsky <npostavs@gmail.com> wrote:

> On Sat, 18 Jul 2020 at 01:56, numbchild@gmail.com <numbchild@gmail.com>
> wrote:
>
> >                   (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
> >
> > The upper code has a problem, the command "ps -C emacs -o pid=" can't
> detect
> > emacs program name like "emacs-28.2.3" which is in /usr/local/bin and
> > compiled from source code.
>
> If your init does (server-start), then you can just check for
> (server-running-p). Otherwise, something like
>
> (seq-count
>  (lambda (proc) (and (equal (alist-get 'user proc) user-login-name)
>                 (string-match "\\<emacs\\>" (alist-get 'comm proc))))
>  (mapcar #'process-attributes (list-system-processes)))
>


reply via email to

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