From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Evgeny Roubinchtein Newsgroups: gmane.emacs.devel Subject: Proposed patch to nt\runemacs.c: a way to augment environment variables prior to starting Emacs Date: Wed, 14 Oct 2015 15:08:45 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11c329fa629641052217cebb X-Trace: ger.gmane.org 1444876618 27414 80.91.229.3 (15 Oct 2015 02:36:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Oct 2015 02:36:58 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 15 04:36:57 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZmYPQ-0004e7-66 for ged-emacs-devel@m.gmane.org; Thu, 15 Oct 2015 04:36:48 +0200 Original-Received: from localhost ([::1]:45461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmYPP-0002zf-Cw for ged-emacs-devel@m.gmane.org; Wed, 14 Oct 2015 22:36:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmUE4-00048e-1q for emacs-devel@gnu.org; Wed, 14 Oct 2015 18:08:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmUE3-0007KJ-4I for emacs-devel@gnu.org; Wed, 14 Oct 2015 18:08:47 -0400 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:38496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmUE2-0007K2-Q7 for emacs-devel@gnu.org; Wed, 14 Oct 2015 18:08:47 -0400 Original-Received: by wieq12 with SMTP id q12so104277595wie.1 for ; Wed, 14 Oct 2015 15:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=LKyxvIkOFG0JKLBHsnmgPdenaEXAcLLQtxtYTIPqU0s=; b=VhM9Gs6GWgZIugvuBys44bkHQpqJQXIeoO1JSf8klKjMHr3jkDjh+ClveTjzIIIL4o hKl2vhs0lPXokflKTU4ZN9y7Nb1a8Hx9Csex9iDlICL/Qv/Gpf+3wcEwMtsjoJgg8rB7 0MLVzqI/m3UrCLW6M0WpURpkLVpcXNt//V+cFZ8ukvG2C31Uv/Bf8Yh5NdulBrd+u5jr UHy1E2Agpq4wE8CL2jCFJURq9YPddLVn4m7z2uXLr5JcBMGJLC2wERm6GZ2dYK6oQ/8I JIo7WNqPusAv8jgbLLVcBUeZoGoTi8+ee3PLSOMLGI9XYC0oFwnDqiE1XCViJhhwP5QO MzVw== X-Received: by 10.180.189.69 with SMTP id gg5mr6680834wic.45.1444860525677; Wed, 14 Oct 2015 15:08:45 -0700 (PDT) Original-Received: by 10.28.213.76 with HTTP; Wed, 14 Oct 2015 15:08:45 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 X-Mailman-Approved-At: Wed, 14 Oct 2015 22:35:14 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:191607 Archived-At: --001a11c329fa629641052217cebb Content-Type: text/plain; charset=UTF-8 Dear Emacs developers, Would you consider applying the attached patch to nt\runemacs.c? My "use case" is that I compiled 64-bit Emacs under Windows following instructions at http://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/, but I want to avoid copying libraries from ${msys2_root}/mingw64/bin to the Emacs installation directory, and I also don't want to add ${msys2_root}/mingw64/bin to the PATH for my user account (let alone system-wide). The attached patch gives me a way to augment system environment variables before runemacs starts the actual emacs executable. With this patch applied, I can set the environment variable EMACS_ENV to ">PATH>${msys2_root}/mingw64/bin", and have that directory appended to the PATH but only in the environment of the runemacs process. That environment is inherited by the emacs process, so I can allow Emacs to find the libraries it needs in order to run without copying them to the Emacs installation directory and without altering the PATH for my user account. Please let me know if it would be possible to get this patch applied to the Emacs sources. Thank you in advance! -- Evgeny --001a11c329fa629641052217cebb Content-Type: application/octet-stream; name="0001-Expand-the-EMACS_ENV-environment-variable.patch" Content-Disposition: attachment; filename="0001-Expand-the-EMACS_ENV-environment-variable.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ifrcihl70 RnJvbSBhNDcwZDM2ODVkOTZmOWMzZDZlM2NjODJlZjc1ZGYzOWE0OWE1NGE4IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBFdmdlbnkgUm91YmluY2h0ZWluIDx6aGVueWExMDA3QGdtYWls LmNvbT4KRGF0ZTogV2VkLCAxNCBPY3QgMjAxNSAyMTo0NTozMiArMDEwMApTdWJqZWN0OiBbUEFU Q0hdIEV4cGFuZCB0aGUgRU1BQ1NfRU5WIGVudmlyb25tZW50IHZhcmlhYmxlLgoKLS0tCiBudC9y dW5lbWFjcy5jIHwgMTAzICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysrKysrKysrKy0KIDEgZmlsZSBjaGFuZ2VkLCAxMDIgaW5zZXJ0aW9ucygrKSwgMSBk ZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL250L3J1bmVtYWNzLmMgYi9udC9ydW5lbWFjcy5jCmlu ZGV4IDg2NjQ0YjQuLjcwY2I1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CisgICAg Z290byBmcmVlX2J1ZjsKKworICBiID0gZSA9IGJ1ZjsKKyAgd2hpbGUgKE5VTEwgIT0gKGIgPSBz dHJwYnJrIChiLCAiPio8IikpKQorICAgIHsKKyAgICAgIGNoYXIgKmVlOworICAgICAgY2hhciAq dmFsID0gTlVMTDsKKyAgICAgIGNoYXIgKm52YWwgPSBOVUxMOworCisgICAgICBzZXBbMF0gPSAq YjsKKyAgICAgICsrYjsKKyAgICAgIGUgPSBzdHJwYnJrKGIsIHNlcCk7CisgICAgICBpZiAoTlVM TCA9PSBlKQorCWdvdG8gZnJlZV9idWY7CisgICAgICBlbHNlCisJKmUgPSAnXDAnOworICAgICAg ZWUgPSBzdHJwYnJrKGUrMSwgc2VwKTsKKyAgICAgIGlmIChOVUxMICE9IGVlKQorCSplZSA9ICdc MCc7CisgICAgICBzd2l0Y2ggKHNlcFswXSkKKwl7CisJY2FzZSAnPic6IC8qYXBwZW5kKi8KKwkg IGlmICghZ2V0X2Vudl92YXIgKGIsICZ2YWwpKQorCSAgICBnb3RvIGNsZWFudXA7CisJICBudmFs ID0gbWFsbG9jIChzdHJsZW4odmFsKSArIHN0cmxlbihlKzEpICsgMSk7CisJICBzdHJjcHkobnZh bCwgdmFsKTsKKwkgIHN0cmNhdChudmFsLCBlKzEpOworCSAgaWYgKCFTZXRFbnZpcm9ubWVudFZh cmlhYmxlIChiLCBudmFsKSkKKwkgICAgZ290byBjbGVhbnVwOworCSAgYnJlYWs7CisJY2FzZSAn PCc6IC8qcHJlcGVuZCovCisJICBpZiAoIWdldF9lbnZfdmFyIChiLCAmdmFsKSkKKwkgICAgZ290 byBjbGVhbnVwOworCSAgbnZhbCA9IG1hbGxvYyAoc3RybGVuKHZhbCkgKyBzdHJsZW4oZSsxKSAr IDEpOworCSAgc3RyY3B5KG52YWwsIGUrMSk7CisJICBzdHJjYXQobnZhbCwgdmFsKTsKKwkgIGlm ICghU2V0RW52aXJvbm1lbnRWYXJpYWJsZSAoYiwgbnZhbCkpCisJICAgIGdvdG8gY2xlYW51cDsK KwkgIGJyZWFrOworCWNhc2UgJyonOiAvKm92ZXJ3cml0ZSovCisJICBpZiAoIVNldEVudmlyb25t ZW50VmFyaWFibGUgKGIsIGUrMSkpCisJICAgIGdvdG8gY2xlYW51cDsKKwkgIGJyZWFrOworCWRl ZmF1bHQ6CisJICByZXR1cm47CisJfQorICAgIGNsZWFudXA6CisgICAgICBpZiAoTlVMTCAhPSB2 YWwpCisJZnJlZSAodmFsKTsKKyAgICAgIGlmIChOVUxMICE9IG52YWwpCisJZnJlZSAobnZhbCk7 CisgICAgICAqZSA9IHNlcFswXTsKKyAgICAgIGlmIChOVUxMICE9IGVlKQorCXsKKwkgIGIgPSBl ZSArIDE7CisJICAqZWUgPSBzZXBbMF07CisJfQorICAgICAgZWxzZQorCWIgPSBlICsgMTsKKyAg ICB9CisgZnJlZV9idWY6CisgIGlmIChOVUxMICE9IGJ1ZikKKyAgICBmcmVlIChidWYpOworfQot LSAKMi42LjEud2luZG93cy4xCgo= --001a11c329fa629641052217cebb--