[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hg-histedit, how to pass shell involvement, to the lisp code?
From: |
Eli Zaretskii |
Subject: |
Re: hg-histedit, how to pass shell involvement, to the lisp code? |
Date: |
Thu, 10 Oct 2024 09:22:02 +0300 |
> Date: Wed, 09 Oct 2024 21:36:19 +0200
> From: Uwe Brauer via "Emacs development discussions." <emacs-devel@gnu.org>
>
> 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))