From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yoichi Nakayama Newsgroups: gmane.emacs.devel Subject: Re: Can emacsclient send environment variables even if it doesn't create a frame? Date: Sat, 1 Apr 2023 22:37:30 +0900 Message-ID: References: <83bkkb7e6s.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8935"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 01 15:45:47 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pibY9-00024M-LF for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Apr 2023 15:45:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pibXi-0002il-MC; Sat, 01 Apr 2023 09:45:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pibQQ-0000Ww-O3 for emacs-devel@gnu.org; Sat, 01 Apr 2023 09:37:46 -0400 Original-Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pibQP-0003pO-2i; Sat, 01 Apr 2023 09:37:46 -0400 Original-Received: by mail-pf1-x432.google.com with SMTP id fb38so16493074pfb.7; Sat, 01 Apr 2023 06:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680356262; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eGJFnX9h9Lpuk0ghrjVcvLCeC10LX1zFQGis2bgxbDI=; b=SoFLRpgfwLMtp17mKVNubvG4rNy61xM08jNk3tajpGo2Bvz71j4Vvre6rArSA8VmLB nCFHmQ1VwE8iKh9KiOoVkADteGIlk/VGl5DbrWIH/f9lXpaKfpAPgxjrmfpf5ayxJoKC fmDTIsn+s6PaAIF1sv3YWfXj9444EQ9950Sp0SDe56DEoB7bk/yFgytXF/U+UKe9WMqM v3P/OCCXrIXwJRvyQe9siP5HHR0fhmYq0HoKsA99HzQIeUpC2YR9f1Dtmae4K0P7Prph NVKHXmY+jT7JFZ2DlmYFlBPy6+f3sYiYMTw4kM8tyCUddKvHGerHut72jvQKkEE4KRUQ PFrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680356262; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eGJFnX9h9Lpuk0ghrjVcvLCeC10LX1zFQGis2bgxbDI=; b=Hmjb85+P45tZ0QxOcpgzXBLetFuiI0qsfRVhaX2zPoLfezSUPEQGONXp0wGy/gjzR4 e9K3dXbPLXzppZ9bAvJxOdWEO782uKgXAufdMtejHiE6OUs766GQUH0KdPi5PIvFvosG UbuLh0/TPqa2C2S1nsPOkdNyDdLoK/SasG6u97ELHQNG8nvYe0w0UIcnCW3gFtTQBHS1 gYGTKrvBYYCBtiZ4874h/bhzElZrFGDyi2jb0ro3IfIlBh0npqg8NlWI4nIZLHfd3jDB /aD+ErSQZaPcB4/JWhAMMqNQ0uyH6rBQif7hvx5mdYkPFdJy8rxyri5Xvb8dTCNzQejJ 1mpw== X-Gm-Message-State: AAQBX9cYV4qo28OiRB/e/ohPy6Cj8pwrYGSB0oJCHN+BAYOckj8fBb0D XWNi4e2LBKJx9xceZTRDBpBndfloodLaAELj1o+VJ3Br0Rg= X-Google-Smtp-Source: AKy350Ztk3IfRp+Ri3s+Q13obcJAJZH8QMf+uASJIiatGyODIsr4/D14XVJgIQ+GSTdZVcH6aMG++q/4rAf7O0MBeFk= X-Received: by 2002:a05:6a00:a1a:b0:62d:9b70:1afd with SMTP id p26-20020a056a000a1a00b0062d9b701afdmr5735273pfh.1.1680356262173; Sat, 01 Apr 2023 06:37:42 -0700 (PDT) In-Reply-To: <83bkkb7e6s.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=yoichi.nakayama@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 01 Apr 2023 09:45:17 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305009 Archived-At: On Thu, Mar 30, 2023 at 12:46=E2=80=AFAM Eli Zaretskii wrote= : > > > From: Yoichi Nakayama > > Date: Wed, 29 Mar 2023 22:45:09 +0900 > > > > Currently, emacsclient sends environment variables to the server proces= s only > > if it is going to create a frame. So it is impossible to refer to envir= onment > > variables when calling EDITOR=3Demacsclient from other programs. > > In contrast, if EDITOR=3D"emacsclient -t" or EDITOR=3D"emacsclient -c" = (that is, > > emacsclient creates new frames), you can refer emacsclient's environmen= t > > variables via server-buffer-clients. > > > > Is it possible to eliminate the following conditional branching by crea= te_frame > > in lib-src/emacsclient.c? > > That would mean a single frame could "inherit" environment variables > from different shells, which will be at least confusing, if not > contradictory. For example, what about environment variables like > PATH? No, it will not update the frame-parameter of the existing frame. I=E2=80=99ve confirmed (frame-parameter nil 'environment) =3D> nil on the window/buffer created by the modified emacsclient, while (process-get (car server-buffer-clients) 'env) returns environment variables on it. Also, in the following usage, git will perform exclusive control and prevent committing to the same repository at the same time, so multiple clients will not edit the same COMMIT_EDITMSG file. So the single buffer does not "inherit" environment variables from different shells. > > Use case: > > Refer GIT_INDEX_FILE to show correct diff even when emacsclient is invo= ked > > by `git commit -a` or `git commit filename` (where GIT_INDEX_FILE point= s to > > a temporary index file), along with the commit message edit buffer. > > Why cannot you call emacsclient in that case with -t or -c option? > AFAIR, Git can use a Git-special variable GIT_EDITOR, so you could > define that to create a new frame without affecting the more general > EDITOR setting. I can use emacsclient with -t or -c option, and I can also use emacsclient without those option too. If we don't have magit installed, we can edit the commit message in either case, without any restrictions. If we have magit installed, in addition to the window for editing the commi= t message, it also opens a window for the change diff. I'm trying to fix an issue with magit that sometimes presents incorrect change diffs. I found a fix that uses GIT_INDEX_FILE in the client's environment variable= s https://github.com/magit/magit/pull/4888 but it doesn't work if emacsclient doesn't open a new frame. Because if emacsclient doesn't create a frame, emacsclient's environment variables aren't passed to the server side and there is no way to use them. --=20 Yoichi NAKAYAMA