Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find out we are running under emacs? #3

Open
JanWielemaker opened this issue Oct 5, 2018 · 6 comments
Open

Find out we are running under emacs? #3

JanWielemaker opened this issue Oct 5, 2018 · 6 comments

Comments

@JanWielemaker
Copy link

Most emacs mode that create a process put something into the environment such that the process can act on this mode. Currently SW-Prolog checks for EMACS, INSIDE_EMACS and INFERIOR. It would be nice if ediprolog did that as well. Or do we have some other not-to-wild way to discover we are running under ediprolog? Testing the prompt is all I can think of right now ...

@triska
Copy link
Owner

triska commented Oct 6, 2018

Can this be handled analogously to SWI-Prolog/swipl-devel@044aabc ?

@JanWielemaker
Copy link
Author

Hmmm. As a hack, possibly (but then we also have checking the prompt). In general I'd guess a dumb terminal is still ok to do basic paging, while it is not good enough for commandline editing. I'll probably implement some quick fix for now, but it would be nice if there was a more robust way to find out that we are running under ediprolog.

@triska
Copy link
Owner

triska commented Oct 6, 2018

One important point for the immediate ad hoc solution: The default prompt that ediprolog uses is:

?ediprolog- .

Please see:

(defvar ediprolog-prompt "?ediprolog- "

This is user-configurable, though I do not expect many changes in this area, also not for the immediate future.

@JanWielemaker
Copy link
Author

However,

?- prompt(X,X).
%@ X = '|: '.

I think it makes the point clear that using the prompt is not a good way to find ediprolog (especially if it can be configured). For now, TERM does the job, but who know whether that should be reverted at some point because there are dumb terminals where you want (elementary) paging?

Most related emacs functionality such as M-x shell seem to do this using an environment variable. Unfortunately they all use their own ...

@triska
Copy link
Owner

triska commented Oct 7, 2018

ediprolog sets the prompt with '$set_prompt'/1:

'$set_prompt'('%s').\n" ediprolog-prompt)))

You can see the exact toplevel interaction in the buffer *ediprolog-history*. For example, in the case you posted:

?ediprolog-  prompt(X, X).
X = '|: '.

?ediprolog- 

@JanWielemaker
Copy link
Author

Thanks. That explains something. Now changed the test to

running_under_emacs :-
    current_prolog_flag(toplevel_prompt, P),
    sub_atom(P, _, _, _, 'ediprolog'),
    !.

Note that '$set_promp'/1 is deprecated and new code should use the Prolog flag. As this is not a hard constant it is still a shaky way to find emacs/ediprolog.

As a side note, wouldn't it be a good idea to do something similar as for PDT where we have library(pdt_console) and add a library(ediprolog_console) where we can do whatever is needed to facilitate ediprolog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants