For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2007 > Re: How to make the SWI-Prolog 'edit' command invoke gvim instead









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to make the SWI-Prolog 'edit' command invoke gvim instead
student

2007-04-28, 7:03 pm

szgyg wrote:
> student wrote:
>
> SWI FAQ
> http://gollem.science.uva.nl/twiki/.../FAQ/BindEditor



13 ?- pwd.
j:/documents and settings/administrator/desktop

Yes
14 ?- set_prolog_flag(editor, gvim).

Yes
15 ?- edit(file(junk)).
% Waiting for editor ...
% Editor returned failure; skipped make/0 to reload files

Hmm, apparently there is more to it.

I promise to save all the pieces of this puzzle and post them at the
end of this thread, just so the next person who stumbles across this
frequently encountered question will be able to find the answer to it in
less than a minute with Google.


Cesar Rabak

2007-04-28, 7:03 pm

student escreveu:
> szgyg wrote:
>
>
> 13 ?- pwd.
> j:/documents and settings/administrator/desktop
>
> Yes
> 14 ?- set_prolog_flag(editor, gvim).
>
> Yes
> 15 ?- edit(file(junk)).
> % Waiting for editor ...
> % Editor returned failure; skipped make/0 to reload files
>
> Hmm, apparently there is more to it.


Well, perhaps in your installation, because in my Windows XP, it works
as directed in the FAQ.

Just to be sure: is 'gvim' in your path?
student

2007-04-28, 10:05 pm

Cesar Rabak wrote:
> student escreveu:
>
> Well, perhaps in your installation, because in my Windows XP, it works
> as directed in the FAQ.
>
> Just to be sure: is 'gvim' in your path?


If by path you mean the environmental veriable PATH, adding the path
to the Vim executables doesn't seem to fix the problem (Swi-prolog still
brings up Notepad). In fact, I can invoke both vim and gvim from an
MSDOS command-line *without* having the path to the Vim executables
present on PATH Maybe I have to change something in the Windows Registry.
Cesar Rabak

2007-04-28, 10:05 pm

student escreveu:
> Cesar Rabak wrote:
>
> If by path you mean the environmental veriable PATH,

Yes, this is what I mean.

> adding the path
> to the Vim executables doesn't seem to fix the problem (Swi-prolog still
> brings up Notepad).


Very odd. Just to ascertain my understanding of this report: you mean that:

1) You add the path to [g]vim executableh to your PATH environmental
variable.

2) in this 'MSDOS' session you start pl shell.

3) you follow the procedure for setting the prolog flag for the editor.

4) and *in addition* to the message you posted, the editor brought is
Notepad.

Is it correct?

> In fact, I can invoke both vim and gvim from an
> MSDOS command-line *without* having the path to the Vim executables
> present on PATH


This is even more strange! It has to be in the path in some way. . . You
showed above calling a unixy command 'pwd'. By any chance, have you also
the utility 'which'? Could you try to see what 'which gvim.exe' brings
in your machine?

> Maybe I have to change something in the Windows Registry.


I think is too early to fiddle with the Registry...
student

2007-04-29, 8:03 am

student wrote:

> Maybe I have to change something in the Windows Registry.


Maybe so, but this worked:

3 ?- set_prolog_flag(editor,'j:/progra~1/vim/vim70/gvim.exe').

Yes
4 ?- current_prolog_flag(editor,Q).

Q = 'j:/progra~1/vim/vim70/gvim.exe' ;

(Duh!)

Now I have to figure out how to save this setting...


student

2007-04-29, 10:03 pm

student wrote:

Ok, made a little more progress...

(1) Made sure the directory containing the SWI-Prolog executables was
on my WINNT PATH (via

My Computer->Properties->Advanced->Environmental Variables|->System
Variables->select variable name 'Path' -> click Edit... )

(2) Added the command

:- set_prolog_flag(editor,gvim).

by directly editing my 'pl.ini' file (apropos which more below).

(3) Ran SWI-Prolog and tried

?- current_prolog_flag(editor,Q).

Q = gvim

Great!

(4) Ran

?- edit('d:/misc/prolog/bell_numbers'). /* a known file */

and it came up in 'gvim'!

Fantastic!

(5)) Tried

?- edit(junk).
Warning: Cannot find anything to edit from "junk"
Warning: Use edit(file(junk)) to create a new file

Ok, expected that, so tried


?- edit(new(junk)).
Warning: Cannot find anything to edit from "new(junk)"

<expletive deleted>!

Any ideas, anyone?

Possible clue:

clicking Settings -> User init file causes plwin to hang.

--
Cesar Rabak

2007-04-30, 10:04 pm

student escreveu:
> student wrote:
>
> Ok, made a little more progress...
>
> (1) Made sure the directory containing the SWI-Prolog executables was
> on my WINNT PATH (via
>
> My Computer->Properties->Advanced->Environmental Variables|->System
> Variables->select variable name 'Path' -> click Edit... )
>
> (2) Added the command
>
> :- set_prolog_flag(editor,gvim).
>
> by directly editing my 'pl.ini' file (apropos which more below).
>
> (3) Ran SWI-Prolog and tried
>
> ?- current_prolog_flag(editor,Q).
>
> Q = gvim
>
> Great!
>
> (4) Ran
>
> ?- edit('d:/misc/prolog/bell_numbers'). /* a known file */
>
> and it came up in 'gvim'!
>
> Fantastic!
>
> (5)) Tried
>
> ?- edit(junk).
> Warning: Cannot find anything to edit from "junk"
> Warning: Use edit(file(junk)) to create a new file
>
> Ok, expected that, so tried
>
>
> ?- edit(new(junk)).
> Warning: Cannot find anything to edit from "new(junk)"
>
> <expletive deleted>!
>
> Any ideas, anyone?


How about you paying more attention to the warning messages:

<quote>
> Warning: Use edit(*file*(junk)) to create a new file

</quote>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com