From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: hg-histedit, how to pass shell involvement, to the lisp code? Date: Thu, 10 Oct 2024 09:22:02 +0300 Message-ID: <86ed4o32b9.fsf@gnu.org> References: <87o73t5arw.fsf@mat.ucm.es> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15982"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Uwe Brauer Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 10 08:23:16 2024 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 1symZw-0003zH-4t for ged-emacs-devel@m.gmane-mx.org; Thu, 10 Oct 2024 08:23:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1symZ4-0002o1-Kf; Thu, 10 Oct 2024 02:22:23 -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 1symZ0-0002nB-Kq for emacs-devel@gnu.org; Thu, 10 Oct 2024 02:22:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1symZ0-0000qS-7M; Thu, 10 Oct 2024 02:22:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=MbBLt25sKx3UR3YU6SCSrHIHJd4Oy8hRBLMLux6yx+4=; b=JLqviGrhjVq3 rwoxMASxyCYDqQoqOhF8vYrPQU/baIAd4HiPcIzXFv+WaQJafCPGUzSuZh6ULHRA6qsjnxAdAQI3S C+AqKloZ9B4c1aEnO/3rbf8WL3W3taV8Je7RKGxjdpiJiiTYGgFINOxMNtOfrr8kFxS32aiA3AMfr MoxuRH3H6hBlwNd43sxClNVFXtnnhihNzSzfyp+TZY6Kct0s3go9oIF1SU69sP5hM5hVhZnejGtP0 7kKqLDjYpINRnZ8KGsxp2PDeHa+0LgwsG7HgDMg7wjaaxDU5TuAe/vf9KtfWurE6D0sZSXEGbb/Ew 1PsE9DWzQ9MFtpVPno3hbg==; In-Reply-To: <87o73t5arw.fsf@mat.ucm.es> (emacs-devel@gnu.org) 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:324475 Archived-At: > Date: Wed, 09 Oct 2024 21:36:19 +0200 > From: Uwe Brauer via "Emacs development discussions." > > In mercurial the command histedit, allows, well to rewrite history, (log > messages etc). > > The emacs pkg hg-histedit (pkg seems abandoned) now allows one to use > this command entirely within emacs, the relevant code lines are > > (defcustom hg-histedit-executable "hg" > > > And the crucial lines in the main function > > > (let ((output-buffer (generate-new-buffer " *hg-histedit*")) > (commands (if changeset > `(,hg-histedit-executable "histedit" "--rev" ,changeset) > `(,hg-histedit-executable "histedit")))) > > However when run it this way, the editing takes place in /tmp (which is the > default for mercurial) and not in the directory of the repository in > question. > > >From the command line this can be changed by > > 1. Bash TMP=$(hg root) hg histedit (or TMP="$(hg root)" hg histedit > > 2. Tcsh set TMP=`hg root`; hg histedit $argv > > Then histedit runs in the directory of said repository. > > Now my question is: how can I modify the lisp code to have this behavior > I just described? You are asking how to inject an environment variable into the environment of a program that Emacs will run? The way to do it is to bind process-environment around the call to call-process or similar, and add TMP=whatever to the value of process-environment inside the let form. Example from comint.el: (let ((process-environment (nconc (comint-term-environment) (list (format "INSIDE_EMACS=%s,comint" emacs-version)) (when comint-pager (if (stringp comint-pager) (list (format "PAGER=%s" comint-pager)) (error "comint-pager should be a string: %s" comint-pager))) process-environment))