From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: msys2 build path problems + copy-paste english results in chinese characters Date: Thu, 02 Dec 2021 16:40:43 +0100 Message-ID: <87tufrgglg.fsf@telefonica.net> References: <83a6hks26v.fsf@gnu.org> <83pmqgqi6e.fsf@gnu.org> <87czmghqui.fsf@telefonica.net> <834k7rqxru.fsf@gnu.org> <8735nbibqe.fsf@telefonica.net> <83lf13pbib.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:K9I5uV2JMDiQK1BNh6YMkOHpRX4= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 02 16:46:54 2021 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 1msoIQ-000AFI-Mw for ged-emacs-devel@m.gmane-mx.org; Thu, 02 Dec 2021 16:46:54 +0100 Original-Received: from localhost ([::1]:52002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msoIO-00005c-Lw for ged-emacs-devel@m.gmane-mx.org; Thu, 02 Dec 2021 10:46:52 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msoCg-0006ix-K1 for emacs-devel@gnu.org; Thu, 02 Dec 2021 10:40:59 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:47268) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msoCc-0002nI-8T for emacs-devel@gnu.org; Thu, 02 Dec 2021 10:40:56 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1msoCZ-00022b-1d for emacs-devel@gnu.org; Thu, 02 Dec 2021 16:40:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.devel:280759 Archived-At: Eli Zaretskii writes: >> From: Óscar Fuentes >> Date: Thu, 02 Dec 2021 10:42:49 +0100 >> >> >> (let ((dir (file-name-directory (car command-line-args)))) >> >> (setenv "PATH" (concat (getenv "PATH") path-separator dir)) >> >> (setq exec-path (append exec-path (list dir)))) >> > >> > Changing PATH from within Emacs is not recommended, it will bite you >> > down the road when you least expect it. >> >> I'm using that since many years ago without problems. > > Sheer luck. > >> If you know a better approach > > Yes, change PATH outside of Emacs. Then live happily ever after. That's precisely what I prefer to avoid. >> and/or wish to describe a failure mode for the above code... > > One failure is that you put directories with forward slashes into the > environment of the programs you invoke, and not all of them like that > (although most do cope with that). Maybe if an application parses PATH on a broken way. So far I found none. > Another problem is that after this, PATH used by Emacs and PATH used > by sub-processes is different. I don't know how this could be a problem, even less when emacs.exe lives in the directory added to PATH. > Yet another problem, specific to invoking MSYS2 commands, is that the > directory might be incorrectly encoded (if it includes non-ASCII > characters), since MSYS2 programs expect UTF-8 encoding AFAIK, whereas > Emacs encodes it using the system codepage. Well, adding directories containing MSYS2/Cygwin applications to PATH is risky, something to avoid. Fortunately, on a MSYS2 setup MSYS2 and mingw-w64 binaries are strictly separated. > There might be other problems, I'm not sure I remember all of them. I > just learned long ago not to do that. My experience says otherwise, and having to set up PATH so Emacs can execute the applications installed on its same directory is not trivial for inexperienced users and an annoyance for the rest. IMO runemacs.exe/emacsclient.exe should add their directory to PATH before invoking emacs.exe.