all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to detect two emacs process in Elisp code?
@ 2020-07-17 14:54 stardiviner
  2020-09-03  2:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-03 13:13 ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: stardiviner @ 2020-07-17 14:54 UTC (permalink / raw)
  To: Emacs Help


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

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 which is in /usr/local/bin and
compiled from source code.

Does anyone have good solution for this? Thanks in advance.

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3



^ permalink raw reply	[flat|nested] 11+ messages in thread
* How to detect two emacs process in Elisp code?
@ 2020-07-18  5:55 numbchild
  2020-07-18 12:25 ` Noam Postavsky
  0 siblings, 1 reply; 11+ messages in thread
From: numbchild @ 2020-07-18  5:55 UTC (permalink / raw)
  To: emacs-help

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

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.

Does anyone has good solution for this? Thanks in advance.

[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/


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-09-04  4:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [SOLVED] " numbchild
2020-09-03  2:47     ` 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

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.