summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* linenoise: handle SIGWINCH resize signal.Kaz Kylheku2015-09-141-2/+64
| | | | | | | | | | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, need_resize. (lino_list_busy): New static variable. (handle_resize): New function. (complete_line, history_search, edit): Check for the tty read being interrupted, and in that case call handle_resize to put the resize into effect, and continue the loop to fetch another character. (sigwich_handler): New function. (linenoise): If we have SIGWINCH, install a handler for it temporarily. (link_into_list, unlink_from_list): Set global busy flag around list manipulations. The signal handler stays away if these are set. This means that if the user performs some action that requires a lino_t to be constructed (e.g. types Ctrl-R to search), while resizing the window at almost exactly the same time, we will lose the resize signal. Oh well!
* Implement ~/.txr_profile mechanism.Kaz Kylheku2015-09-134-1/+58
| | | | | | | | | | | | * parser.c (load_rcfile): New function. (repl): Compute profile file name and try to load it before entering loop. * sysif.c (statp): Linkage becomes external. * sysif.h (statp): Declaration updated. * txr.1: Documented.
* Don't supply trivial completion which matches prefix.Kaz Kylheku2015-09-131-0/+3
| | | | | | | * parser.c (find_matching_syms): Don't add an entry into the history if it is a full match for the completion prefix, because in the UI in then looks as if nothing happened when Tab as pressed.
* linenoise: recognize additional commands in search.Kaz Kylheku2015-09-132-3/+17
| | | | | | | | | * linenoise/linenoise.c (history_search): Editing keys should leave search mode and be processed in command mode. Also, let's have Ctrl-L and Ctrl-Z work, but stay in search mode. * txr.1: Documented.
* linenoise: suppress duplicates in Ctrl-R search.Kaz Kylheku2015-09-131-2/+8
| | | | | | * linenoise/linenoise.c (history_search): Don't step through identical lines, which looks as if Ctrl-R is being ignored.
* linenoise: support completion in the middle of line.Kaz Kylheku2015-09-122-17/+23
| | | | | | | | | * linenoise/linenoise.c (compare_completions): Restructure with help of new lino_copy function to collect completions just for the prefix of the line up to the cursor position, and recombine those with the suffix. * txr.1: Doc updated.
* linenoise: incorrect ESC treatment in completion.Kaz Kylheku2015-09-122-15/+2
| | | | | | | | | | * linenoise/linenoise.c (complete_line): ESC must not be treated specially when leaving completion mode; it must accept the completed line. The original code did this wrong in my opinion and I propagated the error. * txr.1: Remove all mention of special ESC treatment in completion mode.
* linenoise: Suppress unknown control characters.Kaz Kylheku2015-09-122-5/+9
| | | | | | | * linenoise/linenoise.c (edit): Don't let characters less than 32 be inserted. * txr.1: Documented that control characters are rejected.
* linenoise: Ctrl-R searchKaz Kylheku2015-09-122-3/+180
| | | | | | | | | | | * linenoise/linenoise.c (next_hist_match, history_search): New static function. (edit): New Ctrl-R case added to early switch that also handles Tab completion, and calls history_search. (lino_free): Adding null check, so we can safely call lino_free(0). history_search relies on this. * txr.1: Documented search.
* Treat comment lines in repl, and plug memory leak.Kaz Kylheku2015-09-112-4/+24
| | | | | | | | | | * parser.c (repl): If we continue the loop due to detecting a blank line, we must free that line, since we are outside of the unwind block (and continue would violate that block if we were). If a line contains nothing but a comment, then enter that line into the history. * txr.1: Documented treatment of commented lines.
* New :read command in repl for direct stdin parse.Kaz Kylheku2015-09-112-1/+48
| | | | | | | | * parser.c (read_eval_ret_last): New function. (repl): Use read_eval_ret_last for :read command. * txr.1: Document :read in new section on direct read from the terminal.
* Better EOF check in read-eval stream function.Kaz Kylheku2015-09-112-1/+11
| | | | | | | | | | | | | | | | | | | | | This makes a difference if we read from a TTY. Without this fix, two Ctrl-D's have to be issued before the code registers EOF and returns. The trick is that we know, after calling the parser, whether it hit EOF, because we have the recent token. If its value is zero, that's the EOF token. We can bail out of the loop instead of calling the parser again which will require another EOF (because prime_parser will not push an EOF token!) * parser.h (parser_eof): Declared. * parser.c (read_eval_stream): After lisp_parse and eval, check for EOF with the parser_eof function, and bail if so. (parser_eof): New function.
* Quit if input form is :quit not its value.Kaz Kylheku2015-09-112-3/+3
| | | | | | | | * parser.c (repl): Subtle difference. Test form's syntax for equality to :quit, not its value. The REPL should not terminate if a form happens to calculate :quit as a value. * txr.1: Updated.
* Document some special keys supported by linenoise.Kaz Kylheku2015-09-111-2/+5
| | | | * txr.1: document Home, End and Delete support.
* linenoise: Ctrl-C cleanly cancels completion.Kaz Kylheku2015-09-112-3/+18
| | | | | | | | | | * linenoise/linenoise.c (complete_line): If Ctrl-C is pressed in completion mode, we cancel completion and return 0 so the command loop reads a new character. * txr.1: Documented Ctrl-C in completion mode, and removed the falsehood that ESC is a cancel command, adding instead an explanation about the ESC handling is really for.
* linenoise: replace 9 with TAB; anticipate extension.Kaz Kylheku2015-09-111-8/+14
| | | | | | | * linenoise/linenoise.c (edit): Code block which handles tab completion before main command dispatch uses the TAB symbol instead of 9, and is refactored into a switch statement which will also handle a history search command.
* linenoise: lino_copy function.Kaz Kylheku2015-09-112-7/+35
| | | | | | | | | | | | * linenoise/linenoise.c (link_into_list, unlink_from_list): New static functions. (lino_make): Use link_into_list instead of open-coded list manipulation. (lino_copy): New function. (lino_free): Use unlink_from list instead of open-coded list manipulation. * linenoise/linenoise.h (lino_copy): Declared.
* Version 115.txr-115Kaz Kylheku2015-09-106-366/+504
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Fix misspelled :toinger filter.Kaz Kylheku2015-09-103-5/+5
| | | | | | | | | | | | | | | | | | | The manual documents a filter called :tointeger, but it has never existed. The keyword was misspelled in the source code from the beginning as :toinger. I'm fixing the typo and renaming the filter to :toint at the same time. * filter.c (tointeger_k, toint_k): Former renamed to latter. (filter_init): Initialize toint_k with correctly spelled symbol. Register filter under toint_k. * filter.h (tointeger_k, toint_k): Former renamed to latter. * txr.1: Changed mention of :tointeger to :toint.
* Remove duplicate variable initialization.Kaz Kylheku2015-09-101-1/+0
| | | | | * eval.c (eval_init): Remove duplicate initialization of with_saved_vars_s.
* Bugfix: *args* not bound for command line expressions.Kaz Kylheku2015-09-102-10/+21
| | | | | | | | | | | | | | | | The documentation says that *args* is bound to nil, but actually it is not bound at all. Let us fix this by actualy binding *args* to the remaining arguments, and by also allowing modification of *args* to dynamically take effect. * txr.c: Set up value of *args* prior to processing any option which evaluates TXR Lisp. Afterwards, reload the argument list from that variable. * txr.1: Documented semantics of *args* during command line processing.
* Don't scan C source code for Lisp symbols.Kaz Kylheku2015-09-103-33/+58
| | | | | | | | | | | | | | * eval.c (eval_init): Register package-alist, package-name and package-symbols intrinsics. * genvim.txr: Rather than scanning C sources for TXR Lisp symbols, iterate over the packages and their symbols, collecting anything which has a binding or is self-evaluating. To get the stdlib symbols, we trigger the autoloads by doing boundp queries on a few symbols. * txr.1: Document package-alist, package-name and package-symbols.
* Bugfix: make self-path visible to Lisp.Kaz Kylheku2015-09-102-2/+26
| | | | | | | | | | | | | | | The self-path variable is not bound in TXR Lisp scripts or the command line. * txr.c (txr_main): Set self-path to "cmdline-expr" before command line Lisp evaluations. (For TXR pattern language syntax invoked in a -c, it continues to be "cmdline"). Set self-path to the file name when reading a Lisp file. Also, the legacy, undocumented *self-path* is only set for TXR scripts, and is reverted to being a special variable, not a global lexical. * txr.1: Documented self-path in more detail.
* Don't pass char to <ctype.h> function.Kaz Kylheku2015-09-101-2/+4
| | | | | | | * parser.c (provide_completions): Cast char argument to unsigned char in call to isalnum. The data comes from user input, which could be any byte. The char type may be signed (and usually is) and so may take on negative values.
* Completion doesn't iterate over all packages.Kaz Kylheku2015-09-101-10/+3
| | | | | | | | | | | When the completed symbol is unqualified, let's not complete across all packages, but just the user package. * parser.c (provide_completions): Substitute user_package if package is null, and call find_matching_syms once rather than iterating on all packages. Also, in this case, do not request symbol qualification.
* No completion on symbol in nonexistent package.Kaz Kylheku2015-09-101-0/+2
| | | | | * parser.c (provide_completions): If find_package returns nil, then just bail with no completions.
* linenoise: sort completions by length.Kaz Kylheku2015-09-101-0/+19
| | | | | | | | | | Give the shorter completions first, and lexicographically within each length equivalence class. This effectively gives the user a breadth-first search through the trie of possible suffixes. * linenoise/linenoise.c (compare_completions): New static function. (complete_line): Apply qsort to the collected vector of strings. Easy does it.
* C++: don't use int constant as enum initializer.Kaz Kylheku2015-09-091-1/+1
| | | | | * match.c (complex_open): Initialize member close of fpip_t using fpip_close enum constant.
* C++: need conversions in return value from alloca.Kaz Kylheku2015-09-091-2/+2
| | | | | * parser.c (provide_completions): Use convert macro to cast void * return value of alloca to char *.
* C++: avoid the compl identifier.Kaz Kylheku2015-09-091-5/+5
| | | | | | | * parser.c (find_matching_syms): Rename the compl variable to comple, because compl is a standard C++ macro which provides an alternate name for the ~ operator.
* C++: fix goto repl which skips initializations.Kaz Kylheku2015-09-091-3/+3
| | | | | | | * txr.c (txr_main): Move the labeled code to the end of the function, so it's not sitting in the scope of of names whose initialization is skipped. This is a better organization: thank you, C++.
* linenoise: fix g++ signed/unsigned warning.Kaz Kylheku2015-09-091-1/+2
| | | | | | * linenoise/linenoise.c (sync_data_to_buf): Cast l->dpos to the signed type ptrdiff_t when comparing to difference between two pointers.
* Small optimization in finalization.Kaz Kylheku2015-09-091-1/+6
| | | | | | | | | | | | | * gc.c (prepare_finals): In the second pass, only mark objects that were identified in the first pass as unreachable. Reachable ones don't require a redundant call to mark_obj. Also, objects identified as unreachable can be moved to gen 0. This is something like what the mark_makefresh hack was trying to do. It only does anything in a full GC pass, because in an incremental pass, anything identified as unreachable is necessarily gen 0. It can help prevent some objects that are revived by finalization from sliding back to gen 1 and hanging around.
* Remove useless mark_makefresh hack.Kaz Kylheku2015-09-091-12/+1
| | | | | | | | | This contraption doesn't actually do anything. * gc.c (mark_makefresh): Static variable removed. (mark_obj): Remove logic conditional no mark_makefresh. (prepare_finals): Remove setting of mark_makefresh. (call_finals): Remove clearing of mark_makefresh.
* Finalization fix: incorrect for generational gc.Kaz Kylheku2015-09-091-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Another bug found in the finalization hooks. The reachability test being applied is not correct for generational GC, relying only on the REACHABLE flag. This bug means that we call finalization hooks on mature objects, while they remain reachable. It must use the gc_is_reachable logic, just like weak hash table processing does, because under an incremental garbage collection pass, all gen 1 objects are considered reachable (though they don't have the REACHABLE flag set). * gc.c (struct fin_reg): Remving obj_type member, replacing with reachable flag. (is_reachable): New static function based on gc_is_reachable, minus the is_ptr test. (GC code which knows it is dealing with a pointer doesn't need the test). (prepare_finals): In the first pass, instead of memorizing the prior object type, simply calculate the reachable flag, correctly taking into account generational GC. (call_finals): Rely on the new reachable flag rather than the REACHABLE flag in the saved obj_type. (gc_is_reachable): Becomes a public wrapper for is_reachable which adds the pointer test. (gc_finalize): Initialize the reachable member of fin_reg. Remove initialization for obj_type.
* Bugfix: multiple evaluation problem in slot place.Kaz Kylheku2015-09-091-4/+5
| | | | | | * share/txr/stdlib/place.tl (defplace slot): The slot argument must be evaluated only once, a gensym is established for it, just like for the object form.
* Formatting under new macro.Kaz Kylheku2015-09-091-0/+1
| | | | * txr.1: Missing .desc added.
* Fix fun, symbol-function and symbol-value places.Kaz Kylheku2015-09-091-5/+5
| | | | | | | * share/txr/stdlib/place.tl (defplace fun, defplace symbol-function, defplace symbol-value): Fix incorrect splicing substitution of body into the output.
* More informative printed rep for functions.Kaz Kylheku2015-09-092-2/+19
| | | | | | | | | * lib.c (obj_print_impl): Print whether a function is interpreted or intrinsic, and include argument information. * tests/012/struct.tl: Test case relying on function printed rep updated.
* Reveal struct winsize on Solaris.Kaz Kylheku2015-09-093-4/+39
| | | | | | | | | | | | | | | | | | | | | | | | | On Solaris 10, we need __EXTENSIONS__ defined to make struct winsize appear out of <termios.h>. This commit adds detection for what preprocessor symbol needs to be defined for struct winsize to appear, if it appears at all. Then this symbol is defined on the compiler command line when compiling linenoise. * Makefile (CFLAGS): Add -D$(termios_define) for linenoise.o target. * configure (have_winsize, termios_define): New variables. Detect whether struct winsize is available, and what preprocessor symbol, if any, is required to reveal the feature. * linenoise/linenoise.c: Need to include TXR's "config.h" for HAVE_WINSIZE. (get_columns): Reorganized so that use of struct winsize is guarded by HAVE_WINSIZE and fallback code is used if either obtaining the size fails or the feature is completely unavailable.
* alloca needs to be declared.Kaz Kylheku2015-09-091-0/+1
| | | | * parser.c: #include ALLOCA_H.
* Wrap call to repl with #if HAVE_TERMIOS.Kaz Kylheku2015-09-091-0/+2
| | | | | * txr.c (txr_main): The repl funtion is not declared unless HAVE_TERMIOS is present and nonzero.
* linenoise: remove input-viewing debug function.Kaz Kylheku2015-09-093-32/+0
| | | | | | | | | | | | This is unused code which just addds to the executable size. Also it passes a char to isprint, which is undefined behavior if that char happens to be negative. * linenoise/example.c (main): Remove --keycodes option and reference to lino_print_keycodes function. * linenoise/linenoise.c, linenoise/linenoise.h (lino_print_keycodes): Function removed.
* Missing termination and else clause in configure.Kaz Kylheku2015-09-091-0/+4
| | | | | | * configure: If we don't have alloca, we must not only print "no", but bail, because we depend on it now. If termios is not found, print no.
* linenoise: don't touch OPOST termios output flag.Kaz Kylheku2015-09-081-2/+1
| | | | | | * linenoise/linenoise.c (enable_raw_mode): Do not clear the OPOST output flag. It is implementation-defined, and if it is set, it is probably set for a good reason.
* linenoise: stray printf on stdout.Kaz Kylheku2015-09-081-2/+5
| | | | | * linenoise/linenoise.c (linenoise): Replace printf("\n") with one-character write on ls->ofd.
* linenoise: don't flush tty input when changing mode.Kaz Kylheku2015-09-081-2/+2
| | | | | | | * linenoise/linenoise.c (enable_raw_mode, disable_raw_mode): Use TCSANOW instead of TCSAFLUSH to change tty settings without flushing input. TCSAFLUSH could discard type-ahead-buffered keystrokes.
* Refinement in linenoise eof/intr handling.Kaz Kylheku2015-09-081-3/+10
| | | | | | | | * parser.c (repl): Rather than breaking out of the loop when linenoise indicates lino_eof, break out of the loop for any error not equal to lino_intr. If the termination was due to other than lino_eof, print an error message.
* linenoise: stdin fd closed bug in !isatty case.Kaz Kylheku2015-09-081-1/+4
| | | | | | * linenoise/linenoise.c (linenoise): Of course, we must up ls->ifd and fdopen the dup, because fdopen closes the descriptor.
* Documented interactive listener.Kaz Kylheku2015-09-081-0/+343
|