forked from Singular/Singular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.doc
4424 lines (3844 loc) · 150 KB
/
general.doc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@comment -*-texinfo-*-
@comment this file contains the general information about Singular
@c The following directives are necessary for proper compilation
@c with emacs (C-c C-e C-r). Please keep it as it is. Since it
@c is wrapped in `@ignore' and `@end ignore' it does not harm `tex' or
@c `makeinfo' but is a great help in editing this file (emacs
@c ignores the `@ignore').
@ignore
%**start
\input texinfo.tex
@setfilename general.info
@node Top, General concepts
@menu
* General concepts::
@end menu
@node General concepts, Data types, Introduction, Top
@chapter General concepts
%**end
@end ignore
@menu
* Interactive use::
* Emacs user interface::
* Rings and orderings::
* Implemented algorithms::
* The SINGULAR language::
* Input and output::
* Procedures::
* Libraries::
* Debugging tools::
* Dynamic loading::
@end menu
@c ---------------------------------------------------------------------------
@node Interactive use, Emacs user interface, General concepts, General concepts
@section Interactive use
@cindex Interactive use
In this section, aspects of interactive use are discussed. This
includes how to enter and exit @sc{Singular}, how to interpret its
prompt, how to get online help, and so on.
There are a few important notes which one should not forget:
@itemize @bullet
@item
every command has to be terminated by a @code{;} (semicolon) followed
by a @key{RETURN}
@item
the online help is accessible by means of the @code{help} function
@end itemize
@menu
* How to enter and exit::
* The SINGULAR prompt::
* The online help system::
* Interrupting SINGULAR::
* Editing input::
* Command line options::
* Startup sequence::
@end menu
@c --------------------------------------------------------------------------
@node How to enter and exit, The SINGULAR prompt, Interactive use, Interactive use
@subsection How to enter and exit
@cindex How to enter and exit
@sc{Singular} can either be run in an ASCII-terminal or within Emacs.
To start @sc{Singular} in its ASCII-terminal user interface, enter
@code{Singular} at the system prompt. The @sc{Singular} banner appears which,
among other data, reports the version and the compilation date.
To start @sc{Singular} in its Emacs user interface, either enter
@code{ESingular} at the system prompt, or type @code{M-x singular}
within a running Emacs (provided you have loaded the file
@code{singular.el} in your running Emacs, see @ref{Running SINGULAR
under Emacs} for details).
Generally, we recommend to use @sc{Singular} in its Emacs interface,
since this offers many more features and is more convenient to
use than the ASCII-terminal interface (@pxref{Emacs user interface}).
To exit @sc{Singular} type @code{quit;}, @code{exit;} or @code{$} (or,
when running within Emacs preferably type @code{C-c $}).
@sc{Singular} and @code{ESingular} may also be started with command line
options and with
filenames as arguments. More generally, the startup syntax is
@smallexample
Singular [options] [file1 [file2 @dots{}]]
ESingular [options] [file1 [file2 @dots{}]]
@end smallexample
@xref{Command line options}, @ref{Startup sequence}, @ref{Running SINGULAR
under Emacs}.
@c --------------------------------------------------------------------------
@node The SINGULAR prompt,The online help system,How to enter and exit, Interactive use
@subsection The SINGULAR prompt
@cindex prompt
@cindex error recovery
The @sc{Singular} prompt @code{>} (larger than) asks the user for input
of commands. The ``continuation'' prompt @code{.} (period) asks the
user for input of missing parts of a command (e.g. the semicolon at
the end of every command).
@sc{Singular} does not interpret the semicolon as the end of a command
if it occurs inside a string. Also, @sc{Singular} waits for blocks
(sequences of commands enclosed in curly brackets) to be closed before
prompting with @code{>} for more commands. Thus, if @sc{Singular} does
not respond with its regular prompt after typing a semicolon it may wait
for a @code{"} or a @code{@}} first.
Additional semicolons will not harm @sc{Singular} since they are
interpreted as empty statements.
@c --------------------------------------------------------------------------
@node The online help system,Interrupting SINGULAR, The SINGULAR prompt,Interactive use
@subsection The online help system
@cindex The online help system
@cindex online help
@cindex help, online help system
The online help system is invoked by the @code{help} command.
@code{?} may be used as a synonym for @code{help}. Simply typing
@code{help;} displays the ``top'' of the help system (i.e., the title
page of the @sc{Singular} manual) which offers a
short table of contents. Typing @code{help} topic@code{;} shows the
available documentation on the respective topic. Here, topic may be either a function
name or, more generally, any index entry of the @sc{Singular}
manual. Furthermore, topic may contain wildcard characters.
@xref{help}, for more information.
@cindex browsers
@cindex help browsers
Online help information can be displayed in various help browsers. The
following table lists a summary of the browsers which are always present.
Usually, external browsers are much more convenient:
A complete, customizable list can be found in the file @code{LIB/help.cnf}.
@multitable @columnfractions .2 .2 .6
@item @strong{Browser} @tab @strong{Platform}
@tab @strong{Description}
@item html
@cindex help browsers, html
@cindex html, default help
@tab Windows
@tab displays a html version of the manual in your default html browser
@item builtin
@cindex help browsers, dummy
@tab all
@tab simply outputs the help information in plain ASCII format
@item emacs
@cindex help browsers, emacs
@tab Unix, Windows
@tab when running @sc{Singular} within (X)emacs, displays help inside the
(X)emacs info buffer.
@item dummy
@tab all
@cindex help browsers, dummy
@tab displays an error message due to the non-availability of a help browser
@end multitable
External browsers depend on your system and the contents of @code{LIB/help.cnf},
the default includes:
@code{htmlview} (displays HTML help pages via @code{htlmview}),@*
@code{mac} (displays HTML help pages via @code{open}),@*
@code{mac-net} (displays HTML help pages via @code{open}),@*
@code{mozilla} (displays HTML help pages via @code{mozilla}),@*
@code{firefox} (displays HTML help pages via @code{firefox}),@*
@code{konqueror} (displays HTML help pages via @code{konqueror}),@*
@code{galeon} (displays HTML help pages via @code{galeon}),@*
@code{netscape} (displays HTML help pages via @code{netscape}),@*
@code{safari} (displays HTML help pages on MacOsX via @code{safari}),@*
@code{tkinfo} (displays INFO help pages via @code{tkinfo}),@*
@code{xinfo} (displays INFO help pages via @code{info}),@*
@code{info} (displays INFO help pages via @code{info}),@*
@code{lynx} (displays HTML help pages via @code{lynx}).
The browser which is used to display the help information, can be either
set at startup time with the command line option (@pxref{Command line
options})
@smallexample
--browser=<browser>
@end smallexample
or with the @sc{Singular} command (@pxref{system})
@smallexample
system("--browser", "<browser>");
@end smallexample
The @sc{Singular} command
@smallexample
system("browsers");
@end smallexample
lists all available browsers and the command
@smallexample
system("--browser");
@end smallexample
returns the currently used browser.
If no browser is explicitely set by the user, then the first available browser
(w.r.t. the order of the browsers in the file @code{LIB/help.cnf}) is chosen.
The @code{.singularrc} (@pxref{Startup sequence}) file is a good place
to set your default browser. Recall that if a file
@code{$HOME/.singularrc} exists on your system, then the content of this
file is executed before the first user input. Hence, putting
@smallexample
if (! system("--emacs"))
@{
// only set help browser if not running within emacs
system("--browser", "info");
@}
// if help browser is later on set to a web browser,
// allow it to fetch HTML pages from the net
system("--allow-net", 1);
@end smallexample
in your file @code{$HOME/.singularrc} sets your default browser to
@code{info}, unless @sc{Singular} is run within emacs (in which case the
default browser is automatically set to @code{emacs}).
Obviously, certain external files and programs are required for the
@sc{Singular} help system to work correctly. If something is not available
or goes wrong, here are some tips for troubleshooting the help system:
@itemize @bullet
@item
@cindex DISPLAY environment variable
@cindex environment variable, DISPLAY
Under Unix, the environment variable @code{DISPLAY} has to be set for all X11
browsers to work.
@item
@cindex help browsers, setting command to use
The help browsers are only available if the respective programs are installed
on your system (for @code{xinfo}, the programs @code{xterm} and
@code{info} are necessary). You can explicitely specify which program to
use, by changing the entry in @code{LIB/help.cnf}
@item
If the help browser cannot find the local html
pages of the @sc{Singular} manual (which it will look for at
@code{$RootDir/html} -- see @ref{Loading a library} for more info on
@code{$RootDir}) @emph{and} the (command-line) option @code{--allow-net}
has @emph{explicitely} been set (see @ref{Command line options} and
@ref{system} for more info on
setting values of command-line options), then it dispatches the html
pages from
@url{http://www.singular.uni-kl.de/Manual}. (Note that
the non-local net-access of HTML pages is disabled, by default.)
@*An
alternative location of a local directory where the html pages reside
can be specified by setting the environment variable
@code{SINGULAR_HTML_DIR}.
@c TBC (@xref{Setting environment variables}).
@item
The @code{info} based help browsers @code{tkinfo}, @code{xinfo}, @code{info}, and
@code{builtin} need the (info) file @code{singular.hlp} which will be looked
for at @code{$RootDir/info/singular.hlp} (see @ref{Loading a library}
for more info on @code{$RootDir}). An alternative
location of the info file of the manual can be specified by setting the
environment variable @code{SINGULAR_INFO_FILE}.
@c TBC (@xref{Setting environment variables}).
@end itemize
@c ref
@ref{Command line options}
@ref{Loading a library}
@ref{system}
@ref{Startup sequence}
@c ref
@subsubheading Info help browsers
@cindex info
The help browsers @code{tkinfo}, @code{xinfo} and @code{info} (so-called
info help browsers) are based on the
@code{info} program from the GNU @code{texinfo} package. @xref{Top, An
Introduction to Info, Getting started, info, The Info Manual}, for more
information.
For info help browsers, the online manual is decomposed into ``nodes''
of information, closely
related to the division of the printed manual into sections and
subsections. A node contains text describing a specific topic at a
specific level of detail. The top line of a node is its ``header''.
The node's header tells the name of the current node (@code{Node:}), the
name of the next node (@code{Next:}), the name of the previous node
(@code{Prev:}), and the name of the upper node (@code{Up:}).
To move within info, type commands consisting of single characters. Do
not type @code{RETURN}. Do not use cursor keys, either. Using some of
the cursor keys by accident might pop to some totally different node.
Type @code{l} to return to the original node. Some of the @code{info}
commands read input from the command line at the bottom. The
@code{TAB} key may be used to complete partially entered input.
The most important commands are:
@table @asis
@item @code{q}
leaves the online help system
@item @code{n}
goes to the next node
@item @code{p}
goes to the previous node
@item @code{u}
goes to the upper node
@item @code{m}
picks a menu item specified by name
@item @code{f}
follows a cross reference
@item @code{l}
goes to the previously visited node
@item @code{b}
goes to the beginning of the current node
@item @code{e}
goes to the end of the current node
@item @code{SPACE}
scrolls forward a page
@item @code{DEL}
scrolls backward a page
@item @code{h}
invokes info tutorial (use @code{l} to return to the manual or
@code{CTRL-X 0} to remove extra window)
@item @code{CTRL-H}
shows a short overview over the online help system (use @code{l} to return
to the manual or @code{CTRL-X 0} to remove extra window)
@item @code{s}
searches through the manual for a specific string, and selects the node in
which the next occurrence is found
@item @code{1}, @dots{}, @code{9}
picks i-th subtopic from a menu
@end table
@c --------------------------------------------------------------------------
@node Interrupting SINGULAR,Editing input,The online help system,Interactive use
@subsection Interrupting SINGULAR
@cindex Interrupting SINGULAR
On Unix-like operating systems and on Windows NT, typing @code{CTRL-C}
(or, alternatively @code{C-c C-c}, when running within Emacs),
interrupts @sc{Singular}. @sc{Singular} prints the current command and
the current line and prompts for further action. The following choices
are available:
@table @code
@item a
returns to the top level after finishing the current (kernel) command. Notice
that commands of the @sc{Singular} kernel (like @code{std}) cannot be
aborted, i.e. (@code{a})bort only happens whenever the interpreter is active.
@item c
continues
@item q
quits @sc{Singular}
@end table
@c --------------------------------------------------------------------------
@node Editing input,Command line options,Interrupting SINGULAR,Interactive use
@subsection Editing input
@cindex Editing input
@cindex SINGULARHIST
@c This section describes only a subset of the key bindings of
@c @sc{Singular} binaries built with the GNU Readline library.
@c @xref{Command Line Editing, GNU Readline Library, Command Line Editing,
@c readline, The GNU Readline Library Manual}, for more information.
The following keys can be used for editing the input and retrieving
previous input lines:
@table @code
@item TAB
provides command line completion for function names and file names
@item CTRL-B
moves cursor to the left
@item CTRL-F
moves cursor to the right
@item CTRL-A
moves cursor to the beginning of the line
@item CTRL-E
moves cursor to the end of the line
@item CTRL-D
deletes the character under the cursor
@* Warning: on an empty line, @code{CTRL-D} is interpreted as the
@code{EOF} character which immediately terminates @sc{Singular}.
@item BACKSPACE
@itemx DELETE
@itemx CTRL-H
deletes the character before the cursor
@item CTRL-K
kills from cursor to the end of the line
@item CTRL-U
kills from cursor to the beginning of the line
@item CTRL-N
saves the current line to history and gives the next line
@item CTRL-P
saves the current line to history and gives the previous line
@item RETURN
saves the current line to the history and
sends it to the @sc{Singular} parser for interpretation
@end table
When run under a Unix-like operating system and in its ASCII-terminal
user interface, @sc{Singular} tries to dynamically link at runtime
with the GNU Readline library. @xref{Command Line Editing, GNU Readline
Library, Command Line Editing, readline, The GNU Readline Library
Manual}, for more information. If a shared version of this library can
be found on your machine, then additional command-line editing
features like history completion are available.
In particuliar, if @sc{Singular} is able to load that library and
if the environment
variable @code{SINGULARHIST} is set and has a name of a valid file as value,
then the input history is stored across sessions using this
file. Otherwise, i.e., if the environment variable @code{SINGULARHIST}
is not set, then the history of the last inputs is only available for
previous commands of the current session.
@c --------------------------------------------------------------------------
@node Command line options, Startup sequence, Editing input, Interactive use
@subsection Command line options
@cindex Command line options
The startup syntax is
@smallexample
Singular [options] [file1 [file2 @dots{}]]
ESingular [options] [file1 [file2 @dots{}]]
@end smallexample
Options can be given in both their long and short format. The following
options control the general behaviour of @sc{Singular}:
@table @asis
@item @code{-d}, @code{--sdb}
@cindex -d
@cindex --sdb
@cindex Source code debugger, invocation
Enable the use of the source code debugger.
@xref{Source code debugger}.
@item @code{-e}, @code{--echo[=VAL]}
@cindex -e
@cindex --echo
Set value of variable @code{echo} to @code{VAL} (integer in the range
0, @dots{}, 9). Without an argument, @code{echo} is set to 1, which echoes
all input coming from a file. By default, the value of @code{echo} is
0. @xref{echo}.
@item @code{-h}, @code{--help}
@cindex -h
@cindex --help
@cindex command-line options, short help
Print a one-line description of each command line option and exit.
@item @code{--allow-net}
@cindex --allow-net
@cindex net access
@cindex allowing net access
@cindex help, accessing over the net
Allow the help browsers based on a web browser to fetch HTML manual pages over
the net from the WWW home-site of @sc{Singular}. @xref{The online help
system}, for more info.
@item @code{--browser="VAL"}
@cindex --browser
@cindex browser, command line option
Use @code{VAL} as browser for the @sc{Singular} online manual.
@*@code{VAL} may be one of the browsers mentioned in @code{LIB/help.cnf},
for example @code{html} (Windows only), @code{mozilla}, @code{firefox},
@code{konqueror}, @code{galeon}, @code{netscape}, @code{safari} (OsX only),
@code{xinfo}, @code{tkinfo}, @code{info}, @code{builtin}, or @code{emacs}.
Depending on your platform and local
installation, only some browsers might be available. The default browser
is @code{html} for Windows and one based on a web browser for Unix
platforms. @xref{The online help system}, for more info.
@item @code{--no-rc}
@cindex --no-rc
@cindex .singularrc file, no loading
Do not execute the @code{.singularrc} file on start-up. By default,
this file is executed on start-up. @xref{Startup sequence}.
@item @code{--no-stdlib}
@cindex --no-stdlib
Do not load the library @code{standard.lib} on start-up. By default,
this library is loaded on start-up. @xref{Startup sequence}.
@item @code{--no-warn}
@cindex --no-warn
Do not display warning messages.
@item @code{--no-out}
@cindex --no-out
Suppress display of all output.
@item @code{--no-shell}
@cindex --no-shell
Runs Singular in restricted mode to disallow shell escape commands.
Objects of type link will also be unable to use.
@item @code{-t}, @code{--no-tty}
@cindex --no-tty
Do not redefine the characteristics of the terminal. This option should be
used for batch processes.
@item @code{-q}, @code{--quiet}
@cindex -q
@cindex --quiet
Do not print the start-up banner and messages when loading
libraries. Furthermore, redirect @code{stderr}
(all error messages) to @code{stdout} (normal output channel). This
option should be used if @sc{Singular}'s output is redirected to a file.
@item @code{-v}
@cindex -v
Print extended information about the version and configuration of
@sc{Singular} (used optional parts, compilation date, start of random
generator etc.). This information should be included if a user reports
an error to the authors.
@end table
The following command line options allow manipulations of the timer and
the pseudo random generator and enable the passing of commands and strings
to @sc{Singular}:
@table @asis
@item @code{-c}, @code{--execute=STRING}
@cindex -c
@cindex --execute
Execute @code{STRING} as (a sequence of) @sc{Singular} commands on
start-up after the @code{.singularrc} file is executed, but prior to
executing the files given on the command line. E.g., @code{Singular -c
"help all.lib; quit;"} shows the help for the library @code{all.lib} and
exits.
@item @code{-u}, @code{--user-option=STRING}
@cindex -u
@cindex --user-option
Returns @code{STRING} on @code{system("--user-option")}. This is useful
for passing arbitrary arguments from the command line to the
@sc{Singular} interpreter. E.g.,
@*@code{Singular -u "xxx.dump" -c 'getdump(system("--user-option"))'}
reads the file @code{xxx.dump} at
start-up and allows the user to start working with all the objects
defined in a previous session.
@item @code{-r}, @code{--random=SEED}
@cindex -r
@cindex --random
Seed (i.e., set the initial value of) the pseudo random generator with
integer @code{SEED}. If this option is not given, then the random
generator is seeded with a time-based @code{SEED} (the number of
seconds since January, 1, 1970, on Unix-like operating systems, to be
precise).
@item @code{--min-time=SECS}
@cindex --min-time
If the @code{timer} (@pxref{timer}), resp.@: @code{rtimer}
(@pxref{rtimer}) , variable is
set, report only
times larger than @code{SECS} seconds (@code{SECS} needs to be a
floating point number greater than 0). By default, this value is set to
0.5 (i.e., half a second). E.g., the option @code{--min-time=0.01}
forces @sc{Singular} to report all times larger than 1/100 of a
second.
@item @code{--ticks-per-sec=TICKS}
@cindex --ticks-per-sec
Set unit of timer to @code{TICKS} ticks per second (i.e., the value
reported by the @code{timer} and @code{rtimer} variable divided by
@code{TICKS} gives the time in seconds). By default, this value is 1.
@item @code{--cpus=CPUs}
set the maximal number of CPUs to use.
@item @code{--cntrlc=C}
set the default answer for interupt signals to C which should be
a for abort, c for continue or q for quit.
@end table
The next three options are of interest for the use with ssi links:
@table @asis
@item @code{-b}, @code{--batch}
@cindex -b
@cindex --batch
Run in batch mode. Opens a TCP/IP connection with host specified by
@code{--MPhost} at the port specified by @code{--MPport}. Input is read
from and output is written to this connection in the format given by @code{--link}.
@xref{Ssi links}.
@item @code{--MPport=PORT}
@cindex --MPport
Use @code{PORT} as default port number for connections (whenever not
further specified). This option is mandatory when the @code{--batch}
option is given. @xref{Ssi links}.
@item @code{--MPhost=HOST}
@cindex --MPhost
Use @code{HOST} as default host for connections (whenever not
further specified). This option is mandatory when the @code{--batch}
option is given. @xref{Ssi links}.
@end table
Finally, the following options are only available when running
@code{ESingular} (see @ref{Running SINGULAR under Emacs} for details).
@table @code
@item --emacs=EMACS
@cindex --emacs
Use @code{EMACS} as Emacs program to run the @sc{Singular} Emacs
interface, where @code{EMACS} may e.g. be emacs or xemacs.
@item --emacs-dir=DIR
@cindex --emacs-dir
Set the singular-emacs-home-directory, which is the directory where
singular.el can be found, to @code{DIR}.
@item --emacs-load=FILE
@cindex --emacs-load
Load @code{FILE} on Emacs start-up, instead of the default load file.
@item --singular=PROG
@cindex --singular
Start @code{PROG} as @sc{Singular} program within Emacs
@end table
The value of options given to @sc{Singular} (resp.@: their default values,
if an option was not given), can be checked with the command
@code{system("--}long_option_name@code{")}. @xref{system}.
@smallexample
@c example
system("--quiet"); // if ``quiet'' 1, otherwise 0
system("--min-time"); // minimal reported time
system("--random"); // seed of the random generator
@c example
@end smallexample
Furthermore, the value of options (e.g., @code{--browser}) can be
re-defined while @sc{Singular} is running using the command
@code{system("--}long_option_name_string @code{",}expression@code{)}. @xref{system}.
@smallexample
system("--browser", "builtin"); // sets browser to 'builtin'
system("--ticks-per-sec", 100); // sets timer resolution to 100
@end smallexample
@c --------------------------------------------------------------------------
@node Startup sequence, , Command line options, Interactive use
@subsection Startup sequence
@cindex Startup sequence
On start-up, @sc{Singular}
@enumerate
@item
loads the library @code{standard.lib} (provided the @code{--no-stdlib}
option was not given),
@item
@cindex file, .singularrc
@cindex .singularrc file
@cindex singularrc
searches the current directory and then the
home directory of the user, and then all directories contained in the
library @code{SearchPath} (see @ref{Loading a library} for more info
on @code{SearchPath}) for a file named @code{.singularrc} and
executes it, if found (provided the @code{--no-rc} option was not
given),
@item
executes the string specified with the @code{--execute} command line
option,
@item
executes the files @code{file1}, @code{file2} @dots{} (given on the command
line) in that order.
@end enumerate
@strong{Note:} @code{.singularrc} file(s) are an approriate place for
setting some default values of (command-line) options.
For example, a system administrator might remove the locally installed
HTML version of the manual and put a @code{.singularrc} file
with the following content
@smallexample
if (system("version") >= 1306) // assure backwards-compatibility
@{
system("--allow-net", 1);
@}; // the last semicolon is important: otherwise no ">", but "." prompt
@end smallexample
in the directory containing the @sc{Singular} libraries, thereby
allowing to fetch the HTML on-line help from the WWW home-site of
@sc{Singular}.
On the other hand, a single user might put a @code{.singularrc} with the
following content
@smallexample
if (system("version") >= 1306) // assure backwards-compatibility
@{
if (! system("--emacs"))
@{
// set default browser to info, unless we run within emacs
system("--browser", "info");
@}
@}; // the last semicolon is important: otherwise no ">", but "." prompt
@end smallexample
in his home directory, which sets the default help browser to
@code{info} (unless @sc{Singular} is run within emacs) and thereby
prevents the execution of the"global"
@code{.singularrc} file installed by the system administrator (since the
@code{.singularrc} file of the user is found before the "global"
@code{.singularrc} file installed by the system administrator).
@c ---------------------------------------------------------------------------
@node Emacs user interface, Rings and orderings, Interactive use, General concepts
@section Emacs user interface
@cindex Emacs, user interface
@cindex Emacs
@cindex interface, Emacs
@cindex user interface, Emacs
Besides running @sc{Singular} in an ASCII-terminal, @sc{Singular} might
also be run within Emacs. Emacs (or, XEmacs which is very similar) is a
powerful and freely available text editor, which, among others,
provides a framework for the implementation of interactive user
interfaces. Starting from version 1.3.6, @sc{Singular} provides such an
implementation, the so-called @sc{Singular} Emacs mode, or Emacs user
interface.
Generally, we recommend to use the Emacs interface,
instead of the ASCII-terminal interface: The Emacs interface does not
only provide everything the ASCII-terminal interface provides, but
offers much more. Among others, it offers
@itemize @bullet
@item
color highlighting
@item
truncation of long lines
@item
folding of input and output
@item
TAB-completion for help topics
@item
highlighting of matching parentheses
@item
key-bindings and interactive menus for most user interface commands and
for basic @sc{Singular} commands (such as loading of libraries and files)
@item
a mode for running interactive @sc{Singular} demonstrations
@item
convenient ways to edit @sc{Singular} input files
@item
interactive customization of nearly all aspects of the user-interface.
@end itemize
In order to use the @sc{Singular}-Emacs interface you need to have Emacs version
20 or higher, or XEmacs
version 20.3 or higher installed on your system. These
editors can be downloaded for most hard- and software platforms,
sources from either
@uref{http://www.gnu.org/software/emacs/emacs.html} (Emacs), or from
@uref{http://www.xemacs.org} (XEmacs).
(Download of binaries depend on your OS). The
differences between Emacs and XEmacs w.r.t. the @sc{Singular}-Emacs
interface are marginal -- which editor to use is mainly a matter of personal
preferences.
The simplest way to start-up @sc{Singular} in its Emacs interface is by
running the program @code{ESingular} which is contained in the Singular
distribution. Alternatively, @sc{Singular} can be started within an
already running Emacs -- see @ref{Running SINGULAR under Emacs} for
details.
The next section gives a tutorial-like introduction to Emacs. This
introductory section is
followed by sections which explain the functionality of various aspects
of the Emacs user interface in more detail: how to start/restart/kill
@sc{Singular} within Emacs, how to run an interactive demonstration, how
to customize the Emacs user interface, etc. Finally, the 20 most
important commands of the Emacs interface together with their key
bindings are listed.
@menu
* A quick guide to Emacs::
* Running SINGULAR under Emacs::
* Demo mode::
* Customization of the Emacs interface::
* Editing SINGULAR input files with Emacs::
* Top 20 Emacs commands::
@end menu
@c --------------------------------------------------------------------------
@node A quick guide to Emacs, Running SINGULAR under Emacs, Emacs user interface, Emacs user interface
@subsection A quick guide to Emacs
@cindex Emacs, overview
@cindex Emacs, a quick guide
This section gives a tutorial-like introduction to Emacs. Especially to
users who are not familiar with Emacs, we recommend that they go through
this section and try out the described features.
Emacs commands generally involve the @code{CONTROL} key (sometimes
labeled @code{CTRL} or @code{CTL}) or the @code{META} key. On some
keyboards, the @code{META} key is labeled @code{ALT} or @code{EDIT} or
something else (for example, on Sun keyboards, the diamond key to the
left of the space-bar is @code{META}). If there is no @code{META} key,
the @code{ESC} key can be used, instead. Rather than writing out
@code{META} or
@code{CONTROL} each time we want to prefix a character, we will use the
following abbreviations:
@multitable @columnfractions .2 .8
@item @code{C-<chr>}
@tab means hold the @key{CONTROL} key while typing the character
@code{<chr>}. Thus, @code{C-f} would be: hold the @key{CONTROL} key and
type @code{f}.
@item @code{M-<chr>}
@tab means hold the @key{META} key down while typing @code{<chr>}. If there
is no @key{META} key, type @key{ESC}, release it, then type the
character @code{<chr>}.
@end multitable
For users new to Emacs, we highly recommend that they go through the
interactive Emacs tutorial: type @code{C-h t} to start it.
For others, it is important to understand the following Emacs concepts:
@table @asis
@item window
In Emacs terminology, a window refers to separate panes within the same
window of the window system, and not to overlapping, separate
windows. When using @sc{Singular} within Emacs, extra windows may appear
which display help or output from certain commands. The most important
window commands are:
@multitable @columnfractions .1 .2 .6
@item @code{C-x 1}
@tab @code{File->Un-Split}
@tab Un-Split window (i.e., kill other windows)
@item @code{C-x o}
@tab
@tab Goto other window, i.e. move cursor into other window.
@end multitable
@item cursor and point
The location of the cursor in the text is also called "point". To
paraphrase, the cursor shows on the screen where point is located in
the text. Here is a summary of simple cursor-moving operations:
@multitable @columnfractions .2 .8
@item @code{C-f} @tab Move forward a character
@item @code{C-b} @tab Move backward a character
@item @code{M-f} @tab Move forward a word
@item @code{M-b} @tab Move backward a word
@item @code{C-a} @tab Move to the beginning of line
@item @code{C-e} @tab Move to the end of line
@end multitable
@item buffer
Any text you see in an Emacs window is always part of some buffer. For
example, each file you are editing with Emacs is stored inside a buffer,
but also @sc{Singular} is running inside an Emacs buffer. Each buffer
has a name: for example, the buffer of a file you edit usually has the
same name as the file, @sc{Singular} is running in a buffer which has
the name @code{*singular*} (or, @code{*singular<2>*},
@code{*singular<3>*}, etc., if you have multiple @sc{Singular}
sessions within the same Emacs).
When you are asked for input to an Emacs command, the cursor
moves to the bottom line of Emacs, i.e., to a special buffer, called the
"minibuffer". Typing @key{RETURN} within the minibuffer, ends the
input, typing @key{SPACE} within the minibuffer, lists all possible
input values to the interactive Emacs command.
The most important buffer commands are
@multitable @columnfractions .2 .8
@item @code{C-x b} @tab Switch buffer
@item @code{C-x k} @tab Kill current buffer
@end multitable
Alternatively, you can switch to or kill buffers using the @code{Buffer}
menu.
@item Executing commands
Emacs commands are executed by typing @code{M-x <command-name>}
(remember that @key{SPACE} completes partial
command names). Important and frequently used commands have short-cuts
for their execution: Key bindings or even menu entries. For example, a
file can be loaded with @code{M-x load-file}, or @code{C-x C-f}, or with
the @code{File->Open} menu.
@item How to exit
To end the Emacs (and, @sc{Singular}) session,
type @code{C-x C-c} (two characters), or use the @code{File -> Exit}
menu.
@item When Emacs hangs
If Emacs stops responding to your commands, you can stop it safely by
typing @code{C-g}, or, if this fails, by typing @code{C-]}.
@item More help
Nearly all aspects of Emacs are very well documented: type
@code{C-h} and then a character saying what kind of help you want.
For example, typing @code{C-h i} enters the @code{Info} documentation
browser.
@item Using the mouse
Emacs is fully integrated with the mouse. In particular, clicking the
right mouse button brings up a pop-up menu which usually contains a few
commonly used commands.
@end table
@c --------------------------------------------------------------------------
@node Running SINGULAR under Emacs, Demo mode, A quick guide to Emacs, Emacs user interface
@subsection Running SINGULAR under Emacs
@cindex Emacs, running Singular under
@cindex Singular, running within Emacs
@cindex Running SINGULAR under Emacs
There are two ways to start the @sc{Singular} Emacs interface: Typing
@code{ESingular} instead of @code{Singular} on the command shell
launches a new Emacs process, initializes the interface and runs
@sc{Singular} within Emacs. The other way is to start the interface in
an already running Emacs, by typing @code{M-x singular} inside
Emacs. This initializes the interface and runs @sc{Singular} within
Emacs. Both ways are described in more detail below.
Note: To properly run the Emacs interface, several files are needed
which usually reside in the @code{emacs} subdirectory of your
@sc{Singular} distribution. This directory is called
singular-emacs-home-directory in the following.
@subheading Starting the interface using ESingular
As mentioned above, @code{ESingular} is an "out-of-the-box" solution:
You don't have to add special things to your @code{.emacs} startup file
to initialize the interface; everything is done for you in a special
file called @code{.emacs-singular} (which comes along with the
@sc{Singular} distribution and resides in the
singular-emacs-home-directory) which is automatically loaded on Emacs
startup (and the loading of the @code{.emacs} file is automatically
suppressed).
The customizable variables of the @sc{Singular} Emacs interface are set
to defaults which give the novice user a very shell like
feeling of the interface. Nevertheless, these default settings can be
changed, see @ref{Customization of the Emacs interface}. Besides other
Emacs initializations, such as fontification or blinking parentheses, a
new menu item called @code{Singular} is added to the main menu,
providing menu items for starting @sc{Singular}. On XEmacs, a button
starting @sc{Singular} is added to the main toolbar.
The @sc{Singular} interface is started automatically; once you see a
buffer called @code{*singular*} and the @sc{Singular} prompt, you are
ready to start your @sc{Singular} session.
@code{ESingular} inherits all @code{Singular} options. For a description
of all these options, see @ref{Command line options}. Additionally
there are the following options which are special to @code{ESingular}:
@multitable @columnfractions .3 .7
@item command-line option /
@*environment variable
@tab functionality
@item @code{--emacs=EMACS}
@*@code{ESINGULAR_EMACS}
@tab Use @code{EMACS} as Emacs program to run the @sc{Singular} Emacs
interface, where @code{EMACS} may e.g. be emacs or xemacs.
@item @code{--emacs-dir=DIR}
@*@code{ESINGULAR_EMACS_DIR}
@tab Set the singular-emacs-home-directory, which is the directory where
singular.el can be found, to @code{DIR}.
@item @code{--emacs-load=FILE}
@*@code{ESINGULAR_EMACS_LOAD}
@tab Load @code{FILE} on Emacs start-up, instead of the default load file.
@item @code{--singular=PROG}
@*@code{ESINGULAR_SINGULAR}
@tab Start @code{PROG} as @sc{Singular} program within Emacs
@end multitable
Notice that values of these options can also be given by setting the
above mentioned environment variables (where values given as
command-line arguments take priority over values given by environment
variables).
@subheading Starting the interface within a running Emacs
If you are a more experienced Emacs user and you already have your own
local @code{.emacs} startup file, you might want to start the interface
out of your running Emacs without using @code{ESingular}. For this, you
should add the following lisp code to your @code{.emacs} file:
@smallexample
(setq load-path (cons "<singular-emacs-home-directory>" load-path))