all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* hg-histedit, how to pass shell involvement, to the lisp code?
@ 2024-10-09 19:36 Uwe Brauer via Emacs development discussions.
  2024-10-10  6:22 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Brauer via Emacs development discussions. @ 2024-10-09 19:36 UTC (permalink / raw)
  To: emacs-devel


Hi

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?

The only kludge I found was to write a trivial shell script say
myhghistedit.sh
and change 
(defcustom hg-histedit-executable "myhghistedit.sh"    

But how can I do this in lisp?

Regards

Uwe Brauer 

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: hg-histedit, how to pass shell involvement, to the lisp code?
  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
  2024-10-10  8:02   ` Uwe Brauer
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-10-10  6:22 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: hg-histedit, how to pass shell involvement, to the lisp code?
  2024-10-10  6:22 ` Eli Zaretskii
@ 2024-10-10  8:02   ` Uwe Brauer
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Brauer @ 2024-10-10  8:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Uwe Brauer, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]



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

Thanks I will try this out later!

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5684 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-10  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-10-10  8:02   ` Uwe Brauer

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.