all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Reset Emacs state
@ 2010-03-02 10:41 Johan Andersson
  2010-03-02 10:50 ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Andersson @ 2010-03-02 10:41 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hey,

I'm looking for a way to reset Emacs. By reset I mean like something you
would want to do in a testing framework. So if you set a variable in one
test, it will not be set in the next.

The only way I find this possible is to run each test as a Emacs Batch
script:
(dolist (test tests)
  (shell-command "./run-test"))

I guess that would work. However, there is a problem with this. *run-test does
not have the test* object. I could solve that by for each test output the
object to a file and then read it in run-test.

This solution seems rather clumpy though and I'm wondering if you can think
of any good way to do it.


Thanks!

[-- Attachment #2: Type: text/html, Size: 897 bytes --]

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

* Re: Reset Emacs state
  2010-03-02 10:41 Reset Emacs state Johan Andersson
@ 2010-03-02 10:50 ` Lennart Borgman
  2010-03-02 11:03   ` Johan Andersson
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2010-03-02 10:50 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

On Tue, Mar 2, 2010 at 11:41 AM, Johan Andersson <johan.rejeep@gmail.com> wrote:
> Hey,
> I'm looking for a way to reset Emacs. By reset I mean like something you
> would want to do in a testing framework. So if you set a variable in one
> test, it will not be set in the next.
> The only way I find this possible is to run each test as a Emacs Batch
> script:
> (dolist (test tests)
>   (shell-command "./run-test"))
> I guess that would work. However, there is a problem with this. run-test
> does not have the test object. I could solve that by for each test output
> the object to a file and then read it in run-test.
> This solution seems rather clumpy though and I'm wondering if you can think
> of any good way to do it.


Dynamic scoping?




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

* Re: Reset Emacs state
  2010-03-02 10:50 ` Lennart Borgman
@ 2010-03-02 11:03   ` Johan Andersson
  2010-03-02 11:18     ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Andersson @ 2010-03-02 11:03 UTC (permalink / raw)
  Cc: help-gnu-emacs

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

You mean like this?
  (setq var "some value...")
  (let ((var "some other value..."))
    ;; Use var with some other value
    )
  ;; Use var with original value

That would only work if I knew the variable names that I would set in the
test, right? And that wont work...

On Tue, Mar 2, 2010 at 10:50 AM, Lennart Borgman
<lennart.borgman@gmail.com>wrote:

> On Tue, Mar 2, 2010 at 11:41 AM, Johan Andersson <johan.rejeep@gmail.com>
> wrote:
> > Hey,
> > I'm looking for a way to reset Emacs. By reset I mean like something you
> > would want to do in a testing framework. So if you set a variable in one
> > test, it will not be set in the next.
> > The only way I find this possible is to run each test as a Emacs Batch
> > script:
> > (dolist (test tests)
> >   (shell-command "./run-test"))
> > I guess that would work. However, there is a problem with this. run-test
> > does not have the test object. I could solve that by for each test output
> > the object to a file and then read it in run-test.
> > This solution seems rather clumpy though and I'm wondering if you can
> think
> > of any good way to do it.
>
>
> Dynamic scoping?
>

[-- Attachment #2: Type: text/html, Size: 1808 bytes --]

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

* Re: Reset Emacs state
  2010-03-02 11:03   ` Johan Andersson
@ 2010-03-02 11:18     ` Lennart Borgman
  2010-03-02 11:48       ` Johan Andersson
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2010-03-02 11:18 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

On Tue, Mar 2, 2010 at 12:03 PM, Johan Andersson <johan.rejeep@gmail.com> wrote:
> You mean like this?
>   (setq var "some value...")
>   (let ((var "some other value..."))
>     ;; Use var with some other value
>     )
>   ;; Use var with original value
> That would only work if I knew the variable names that I would set in the
> test, right? And that wont work...

Yes, you are right. However that is not a serious problem (as long as
you are not testing display things). You can always collect the result
to your current Emacs.

For an example of how to implement this see for example
web-vcs-byte-compile-file in nXhtml. (Which essentially just locates
the current Emacs executable and calls call-process.)


> On Tue, Mar 2, 2010 at 10:50 AM, Lennart Borgman <lennart.borgman@gmail.com>
> wrote:
>>
>> On Tue, Mar 2, 2010 at 11:41 AM, Johan Andersson <johan.rejeep@gmail.com>
>> wrote:
>> > Hey,
>> > I'm looking for a way to reset Emacs. By reset I mean like something you
>> > would want to do in a testing framework. So if you set a variable in one
>> > test, it will not be set in the next.
>> > The only way I find this possible is to run each test as a Emacs Batch
>> > script:
>> > (dolist (test tests)
>> >   (shell-command "./run-test"))
>> > I guess that would work. However, there is a problem with this. run-test
>> > does not have the test object. I could solve that by for each test
>> > output
>> > the object to a file and then read it in run-test.
>> > This solution seems rather clumpy though and I'm wondering if you can
>> > think
>> > of any good way to do it.
>>
>>
>> Dynamic scoping?
>
>




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

* Re: Reset Emacs state
  2010-03-02 11:18     ` Lennart Borgman
@ 2010-03-02 11:48       ` Johan Andersson
  2010-03-02 11:50         ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Andersson @ 2010-03-02 11:48 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: help-gnu-emacs

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

I'm not sure how that would help me? Do you mean something like this?
  (let ((var "some variable"))
    (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
"~/test.el"))

Using *call-process* would reset the state, but how do I reach *var* in *
test.el*? I thought that was what you meant with dynamic scoping?


On Tue, Mar 2, 2010 at 11:18 AM, Lennart Borgman
<lennart.borgman@gmail.com>wrote:

> On Tue, Mar 2, 2010 at 12:03 PM, Johan Andersson <johan.rejeep@gmail.com>
> wrote:
> > You mean like this?
> >   (setq var "some value...")
> >   (let ((var "some other value..."))
> >     ;; Use var with some other value
> >     )
> >   ;; Use var with original value
> > That would only work if I knew the variable names that I would set in the
> > test, right? And that wont work...
>
> Yes, you are right. However that is not a serious problem (as long as
> you are not testing display things). You can always collect the result
> to your current Emacs.
>
> For an example of how to implement this see for example
> web-vcs-byte-compile-file in nXhtml. (Which essentially just locates
> the current Emacs executable and calls call-process.)
>
>
> > On Tue, Mar 2, 2010 at 10:50 AM, Lennart Borgman <
> lennart.borgman@gmail.com>
> > wrote:
> >>
> >> On Tue, Mar 2, 2010 at 11:41 AM, Johan Andersson <
> johan.rejeep@gmail.com>
> >> wrote:
> >> > Hey,
> >> > I'm looking for a way to reset Emacs. By reset I mean like something
> you
> >> > would want to do in a testing framework. So if you set a variable in
> one
> >> > test, it will not be set in the next.
> >> > The only way I find this possible is to run each test as a Emacs Batch
> >> > script:
> >> > (dolist (test tests)
> >> >   (shell-command "./run-test"))
> >> > I guess that would work. However, there is a problem with
> this. run-test
> >> > does not have the test object. I could solve that by for each test
> >> > output
> >> > the object to a file and then read it in run-test.
> >> > This solution seems rather clumpy though and I'm wondering if you can
> >> > think
> >> > of any good way to do it.
> >>
> >>
> >> Dynamic scoping?
> >
> >
>

[-- Attachment #2: Type: text/html, Size: 3117 bytes --]

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

* Re: Reset Emacs state
  2010-03-02 11:48       ` Johan Andersson
@ 2010-03-02 11:50         ` Lennart Borgman
  2010-03-02 12:06           ` Johan Andersson
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2010-03-02 11:50 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

On Tue, Mar 2, 2010 at 12:48 PM, Johan Andersson <johan.rejeep@gmail.com> wrote:
> I'm not sure how that would help me? Do you mean something like this?
>   (let ((var "some variable"))
>     (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
> "~/test.el"))
> Using call-process would reset the state, but how do I reach var in test.el?
> I thought that was what you meant with dynamic scoping?


Using dynamic scoping and call-process are too different ways. When
using call-process you have to write some output in the inferior emacs
process and investigate that in the original emacs process.




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

* Re: Reset Emacs state
  2010-03-02 11:50         ` Lennart Borgman
@ 2010-03-02 12:06           ` Johan Andersson
  2010-03-02 12:21             ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Andersson @ 2010-03-02 12:06 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: help-gnu-emacs

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

I don't see why I would want to do that. I want the inferior emacs process
to read from the original emacs process. Or pass the variables from
the original emacs process to the inferior emacs process. But why the other
way around?

On Tue, Mar 2, 2010 at 11:50 AM, Lennart Borgman
<lennart.borgman@gmail.com>wrote:

> On Tue, Mar 2, 2010 at 12:48 PM, Johan Andersson <johan.rejeep@gmail.com>
> wrote:
> > I'm not sure how that would help me? Do you mean something like this?
> >   (let ((var "some variable"))
> >     (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
> > "~/test.el"))
> > Using call-process would reset the state, but how do I reach
> var in test.el?
> > I thought that was what you meant with dynamic scoping?
>
>
> Using dynamic scoping and call-process are too different ways. When
> using call-process you have to write some output in the inferior emacs
> process and investigate that in the original emacs process.
>

[-- Attachment #2: Type: text/html, Size: 1392 bytes --]

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

* Re: Reset Emacs state
  2010-03-02 12:06           ` Johan Andersson
@ 2010-03-02 12:21             ` Lennart Borgman
  2010-03-02 12:48               ` Johan Andersson
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2010-03-02 12:21 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

I don't understand. Of course you want to pass the variables and
values needed for testing to the inferior process. And I guess you
want to read the result... ;-)

I think we somehow misunderstand each other and I am quite sure you
will get this right.


On Tue, Mar 2, 2010 at 1:06 PM, Johan Andersson <johan.rejeep@gmail.com> wrote:
> I don't see why I would want to do that. I want the inferior emacs process
> to read from the original emacs process. Or pass the variables from
> the original emacs process to the inferior emacs process. But why the other
> way around?
>
> On Tue, Mar 2, 2010 at 11:50 AM, Lennart Borgman <lennart.borgman@gmail.com>
> wrote:
>>
>> On Tue, Mar 2, 2010 at 12:48 PM, Johan Andersson <johan.rejeep@gmail.com>
>> wrote:
>> > I'm not sure how that would help me? Do you mean something like this?
>> >   (let ((var "some variable"))
>> >     (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
>> > "~/test.el"))
>> > Using call-process would reset the state, but how do I reach
>> > var in test.el?
>> > I thought that was what you meant with dynamic scoping?
>>
>>
>> Using dynamic scoping and call-process are too different ways. When
>> using call-process you have to write some output in the inferior emacs
>> process and investigate that in the original emacs process.
>
>




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

* Re: Reset Emacs state
  2010-03-02 12:21             ` Lennart Borgman
@ 2010-03-02 12:48               ` Johan Andersson
  2010-03-02 20:16                 ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Andersson @ 2010-03-02 12:48 UTC (permalink / raw)
  Cc: help-gnu-emacs

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

The result from the sub process is actually not as important as passing
arguments. For now I can live with the exit value. But I still have no idea
of how to pass values to the sub process. I could use some more hints
here...

On Tue, Mar 2, 2010 at 12:21 PM, Lennart Borgman
<lennart.borgman@gmail.com>wrote:

> I don't understand. Of course you want to pass the variables and
> values needed for testing to the inferior process. And I guess you
> want to read the result... ;-)
>
> I think we somehow misunderstand each other and I am quite sure you
> will get this right.
>
>
> On Tue, Mar 2, 2010 at 1:06 PM, Johan Andersson <johan.rejeep@gmail.com>
> wrote:
> > I don't see why I would want to do that. I want the inferior emacs
> process
> > to read from the original emacs process. Or pass the variables from
> > the original emacs process to the inferior emacs process. But why the
> other
> > way around?
> >
> > On Tue, Mar 2, 2010 at 11:50 AM, Lennart Borgman <
> lennart.borgman@gmail.com>
> > wrote:
> >>
> >> On Tue, Mar 2, 2010 at 12:48 PM, Johan Andersson <
> johan.rejeep@gmail.com>
> >> wrote:
> >> > I'm not sure how that would help me? Do you mean something like this?
> >> >   (let ((var "some variable"))
> >> >     (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
> >> > "~/test.el"))
> >> > Using call-process would reset the state, but how do I reach
> >> > var in test.el?
> >> > I thought that was what you meant with dynamic scoping?
> >>
> >>
> >> Using dynamic scoping and call-process are too different ways. When
> >> using call-process you have to write some output in the inferior emacs
> >> process and investigate that in the original emacs process.
> >
> >
>

[-- Attachment #2: Type: text/html, Size: 2577 bytes --]

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

* Re: Reset Emacs state
  2010-03-02 12:48               ` Johan Andersson
@ 2010-03-02 20:16                 ` Lennart Borgman
  0 siblings, 0 replies; 10+ messages in thread
From: Lennart Borgman @ 2010-03-02 20:16 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

The easiest and most portable is to write a temporary file and load
that file with the -l pararater. The function nxhtmltest-run-Q does
something similar.


On Tue, Mar 2, 2010 at 1:48 PM, Johan Andersson <johan.rejeep@gmail.com> wrote:
> The result from the sub process is actually not as important as passing
> arguments. For now I can live with the exit value. But I still have no idea
> of how to pass values to the sub process. I could use some more hints
> here...
>
> On Tue, Mar 2, 2010 at 12:21 PM, Lennart Borgman <lennart.borgman@gmail.com>
> wrote:
>>
>> I don't understand. Of course you want to pass the variables and
>> values needed for testing to the inferior process. And I guess you
>> want to read the result... ;-)
>>
>> I think we somehow misunderstand each other and I am quite sure you
>> will get this right.
>>
>>
>> On Tue, Mar 2, 2010 at 1:06 PM, Johan Andersson <johan.rejeep@gmail.com>
>> wrote:
>> > I don't see why I would want to do that. I want the inferior emacs
>> > process
>> > to read from the original emacs process. Or pass the variables from
>> > the original emacs process to the inferior emacs process. But why the
>> > other
>> > way around?
>> >
>> > On Tue, Mar 2, 2010 at 11:50 AM, Lennart Borgman
>> > <lennart.borgman@gmail.com>
>> > wrote:
>> >>
>> >> On Tue, Mar 2, 2010 at 12:48 PM, Johan Andersson
>> >> <johan.rejeep@gmail.com>
>> >> wrote:
>> >> > I'm not sure how that would help me? Do you mean something like this?
>> >> >   (let ((var "some variable"))
>> >> >     (call-process "emacs" nil "*scratch*" t "-Q" "--batch" "-l"
>> >> > "~/test.el"))
>> >> > Using call-process would reset the state, but how do I reach
>> >> > var in test.el?
>> >> > I thought that was what you meant with dynamic scoping?
>> >>
>> >>
>> >> Using dynamic scoping and call-process are too different ways. When
>> >> using call-process you have to write some output in the inferior emacs
>> >> process and investigate that in the original emacs process.
>> >
>> >
>
>




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

end of thread, other threads:[~2010-03-02 20:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 10:41 Reset Emacs state Johan Andersson
2010-03-02 10:50 ` Lennart Borgman
2010-03-02 11:03   ` Johan Andersson
2010-03-02 11:18     ` Lennart Borgman
2010-03-02 11:48       ` Johan Andersson
2010-03-02 11:50         ` Lennart Borgman
2010-03-02 12:06           ` Johan Andersson
2010-03-02 12:21             ` Lennart Borgman
2010-03-02 12:48               ` Johan Andersson
2010-03-02 20:16                 ` Lennart Borgman

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.