<commit_before>/*  $Id$

    Part of SWI-Prolog

    Author:        <NAME>
    E-mail:        <EMAIL>
    WWW:           http://www.swi-prolog.org
    Copyright (C): 1985-2011, University of Amsterdam
			      VU University Amsterdam

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    As a special exception, if you link this library with other files,
    compiled with a Free Software compiler, to produce an executable, this
    library does not by itself cause the resulting executable to be covered
    by the GNU General Public License. This exception does not however
    invalidate any other reasons why the executable file might be covered by
    the GNU General Public License.
*/

:- module(backward_compatibility,
	  [ '$arch'/2,
	    '$version'/1,
	    '$home'/1,
	    '$argv'/1,
	    '$set_prompt'/1,
	    '$strip_module'/3,
	    '$declare_module'/3,
	    at_initialization/1,	% :Goal
	    displayq/1,
	    displayq/2,
	    sformat/2,			% -String, +Fmt
	    sformat/3,			% -String, +Fmt, +Args
	    concat/3,
	    concat_atom/2,		% +List, -Atom
	    concat_atom/3,		% +List, +Sep, -Atom
	    read_variables/2,
	    read_variables/3,
	    feature/2,
	    set_feature/2,
	    substring/4,
	    flush/0,
	    write_ln/1,
	    proper_list/1,
	    free_variables/2,		% +Term, -Variables
	    subsumes_chk/2,		% @Generic, @Specific
	    subsumes/2,			% @Generic, @Specific
	    hash_term/2,		% +Term, -Hash
	    checklist/2,		% :Goal, +List
	    sublist/3,			% :Goal, +List, -Sublist
	    convert_time/2,		% +Stamp, -String
	    convert_time/8,		% +String, -YMDmhs.ms
	    'C'/3,			% +List, -Head, -Tail
	    current_thread/2,		% ?Thread, ?Status
	    current_mutex/3,		% ?Mutex, ?Owner, ?Count
	    message_queue_size/2,	% +Queue, -TermsWaiting
	    lock_predicate/2,		% +Name, +Arity
	    unlock_predicate/2,		% +Name, +Arity
	    current_module/2,		% ?Module, ?File
	    export_list/2,		% +Module, -Exports
	    setup_and_call_cleanup/3,	% :Setup, :Goal, :Cleanup
	    setup_and_call_cleanup/4,	% :Setup, :Goal, ?Catcher, :Cleanup
	    merge/3,			% +List1, +List2, -Union
	    merge_set/3,		% +Set1, +Set2, -Union
	    index/1,			% :Head
	    hash/1,			% :PI
	    set_base_module/1		% :Base
	  ]).
:- use_module(apply, [maplist/2]).
:- use_module(system, [lock_predicate/1, unlock_predicate/1]).

:- meta_predicate
	at_initialization(0),
	setup_and_call_cleanup(0,0,0),
	setup_and_call_cleanup(0,0,?,0),
	checklist(1, +),
	sublist(1, +, ?),
	index(:),
	hash(:),
	set_base_module(:).

/** <module> Backward compatibility

This library defines predicates that used to exist in older version of
SWI-Prolog, but are considered obsolete as there functionality is neatly
covered by new features. Most often, these constructs are superceeded by
ISO-standard compliant predicates.

Please also note the existence of   quintus.pl and edinburgh.pl for more
compatibility predicates.

@see	gxref/0 can be used to find files that import from
	library(backcomp) and thus reply on deprecated features.
*/

%%	'$arch'(-Architecture, -Version) is det.
%
%	@deprecated use current_prolog_flag(arch, Architecture)

'$arch'(Arch, unknown) :-
	current_prolog_flag(arch, Arch).

%%	'$version'(Version:integer) is det.
%
%	@deprecated use current_prolog_flag(version, Version)

'$version'(Version) :-
	current_prolog_flag(version, Version).

%%	'$home'(-SWIPrologDir) is det.
%
%	@deprecated use current_prolog_flag(home, SWIPrologDir)
%	@see file_search_path/2, absolute_file_name/3,  The Prolog home
%	     directory is available through the alias =swi=.

'$home'(Home) :-
	current_prolog_flag(home, Home).

%%	'$argv'(-Argv:list) is det.
%
%	@deprecated use current_prolog_flag(argv, Argv)

'$argv'(Argv) :-
	current_prolog_flag(argv, Argv).

%%	'$set_prompt'(+Prompt) is det.
%
%	Set the prompt for the toplevel
%
%	@deprecated use set_prolog_flag(toplevel_prompt, Prompt).

'$set_prompt'(Prompt) :-
	maplist(percent_to_tilde, Prompt, Prompt1),
	atom_codes(Atom, Prompt1),
	set_prolog_flag(toplevel_prompt, Atom).

percent_to_tilde(0'%, 0'~) :- !.
percent_to_tilde(X, X).

<commit_msg>FIXED: Better backward compatibility of '$set_prompt'/1.  Needed for the Emacs package ("ediprolog"). <NAME>.<commit_after>/*  $Id$

    Part of SWI-Prolog

    Author:        <NAME>
    E-mail:        <EMAIL>
    WWW:           http://www.swi-prolog.org
    Copyright (C): 1985-2011, University of Amsterdam
			      VU University Amsterdam

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    As a special exception, if you link this library with other files,
    compiled with a Free Software compiler, to produce an executable, this
    library does not by itself cause the resulting executable to be covered
    by the GNU General Public License. This exception does not however
    invalidate any other reasons why the executable file might be covered by
    the GNU General Public License.
*/

:- module(backward_compatibility,
	  [ '$arch'/2,
	    '$version'/1,
	    '$home'/1,
	    '$argv'/1,
	    '$set_prompt'/1,
	    '$strip_module'/3,
	    '$declare_module'/3,
	    at_initialization/1,	% :Goal
	    displayq/1,
	    displayq/2,
	    sformat/2,			% -String, +Fmt
	    sformat/3,			% -String, +Fmt, +Args
	    concat/3,
	    concat_atom/2,		% +List, -Atom
	    concat_atom/3,		% +List, +Sep, -Atom
	    read_variables/2,
	    read_variables/3,
	    feature/2,
	    set_feature/2,
	    substring/4,
	    flush/0,
	    write_ln/1,
	    proper_list/1,
	    free_variables/2,		% +Term, -Variables
	    subsumes_chk/2,		% @Generic, @Specific
	    subsumes/2,			% @Generic, @Specific
	    hash_term/2,		% +Term, -Hash
	    checklist/2,		% :Goal, +List
	    sublist/3,			% :Goal, +List, -Sublist
	    convert_time/2,		% +Stamp, -String
	    convert_time/8,		% +String, -YMDmhs.ms
	    'C'/3,			% +List, -Head, -Tail
	    current_thread/2,		% ?Thread, ?Status
	    current_mutex/3,		% ?Mutex, ?Owner, ?Count
	    message_queue_size/2,	% +Queue, -TermsWaiting
	    lock_predicate/2,		% +Name, +Arity
	    unlock_predicate/2,		% +Name, +Arity
	    current_module/2,		% ?Module, ?File
	    export_list/2,		% +Module, -Exports
	    setup_and_call_cleanup/3,	% :Setup, :Goal, :Cleanup
	    setup_and_call_cleanup/4,	% :Setup, :Goal, ?Catcher, :Cleanup
	    merge/3,			% +List1, +List2, -Union
	    merge_set/3,		% +Set1, +Set2, -Union
	    index/1,			% :Head
	    hash/1,			% :PI
	    set_base_module/1		% :Base
	  ]).
:- use_module(apply, [maplist/2]).
:- use_module(system, [lock_predicate/1, unlock_predicate/1]).

:- meta_predicate
	at_initialization(0),
	setup_and_call_cleanup(0,0,0),
	setup_and_call_cleanup(0,0,?,0),
	checklist(1, +),
	sublist(1, +, ?),
	index(:),
	hash(:),
	set_base_module(:).

/** <module> Backward compatibility

This library defines predicates that used to exist in older version of
SWI-Prolog, but are considered obsolete as there functionality is neatly
covered by new features. Most often, these constructs are superceeded by
ISO-standard compliant predicates.

Please also note the existence of   quintus.pl and edinburgh.pl for more
compatibility predicates.

@see	gxref/0 can be used to find files that import from
	library(backcomp) and thus reply on deprecated features.
*/

%%	'$arch'(-Architecture, -Version) is det.
%
%	@deprecated use current_prolog_flag(arch, Architecture)

'$arch'(Arch, unknown) :-
	current_prolog_flag(arch, Arch).

%%	'$version'(Version:integer) is det.
%
%	@deprecated use current_prolog_flag(version, Version)

'$version'(Version) :-
	current_prolog_flag(version, Version).

%%	'$home'(-SWIPrologDir) is det.
%
%	@deprecated use current_prolog_flag(home, SWIPrologDir)
%	@see file_search_path/2, absolute_file_name/3,  The Prolog home
%	     directory is available through the alias =swi=.

'$home'(Home) :-
	current_prolog_flag(home, Home).

%%	'$argv'(-Argv:list) is det.
%
%	@deprecated use current_prolog_flag(argv, Argv)

'$argv'(Argv) :-
	current_prolog_flag(argv, Argv).

%%	'$set_prompt'(+Prompt) is det.
%
%	Set the prompt for the toplevel
%
%	@deprecated use set_prolog_flag(toplevel_prompt, Prompt).

'$set_prompt'(Prompt) :-
	(   is_list(Prompt)
	->  Prompt0 = Prompt
	;   atom_codes(Prompt, Prompt0)
	),
	maplist(percent_to_tilde, Prompt0, Prompt1),
	atom_codes(Atom, Prompt1),
	set_prolog_flag(toplevel_prompt, Atom).

percent_to_tilde(0'%, 0'~) :- !.
percent_to_tilde(X, X).


{'fraction_non_alphanumeric': 0.11705306543019062, 'fraction_numerical': 0.01875321998969603, 'mean_word_length': 3.3369079535299373, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6468839', 'n_tokens_mistral': 3582, 'n_tokens_neox': 3354, 'n_words': 957}