unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Uwe Brauer <oub@mat.ucm.es>
Cc: emacs-devel@gnu.org
Subject: Re: hg-histedit, how to pass shell involvement, to the lisp code?
Date: Thu, 10 Oct 2024 09:22:02 +0300	[thread overview]
Message-ID: <86ed4o32b9.fsf@gnu.org> (raw)
In-Reply-To: <87o73t5arw.fsf@mat.ucm.es> (emacs-devel@gnu.org)

> 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))




  reply	other threads:[~2024-10-10  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 19:36 hg-histedit, how to pass shell involvement, to the lisp code? Uwe Brauer via Emacs development discussions.
2024-10-10  6:22 ` Eli Zaretskii [this message]
2024-10-10  8:02   ` Uwe Brauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ed4o32b9.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=oub@mat.ucm.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).