Commit graph

31 commits

Author SHA1 Message Date
Charlie Gordon
6fb16e1cc2 Simplify and improve qe_check_buffer_file
* pass `QEmacsState` to key grab functions
* clear `grab_key_opaque` when freeing windows, buffers, mode_data
* add checks on window and buffer pointers in key grab functions
* this should fix a crash bug when deleting unsynched buffers from bufed
* fix `reload_buffer` to update buffer `file_size` and `mtime` fields
* check buffer file before invoking commands that modify the buffer
* check buffer file after command that changes the current window
  or the current window's buffer
2026-06-24 00:44:18 +02:00
Charlie Gordon
227c3dc5e8 Help: improve describe-xxx functions and help popups
* rename and pass flags to byte quoting functions:
  `byte_quote` -> `strquote_byte`
* add `eb_print_style` to output data to a buffer in a given style
* add `eb_print_field` to output a field name and value using styles
* use styles in describe commands
* improve byte stats and page layout output in `describe-buffer`
* add `wall-chart` command (sorted list of bindings)
* add `describe-help` command
2026-06-18 23:30:17 +02:00
Charlie Gordon
0cb68d2d74 Shell: improve current directory traking
* parse process output for shell prompts with current directory
* parse `make -w -C` output for temporary subdirectory excursions
* handle property type and flags separately
* add `QE_PROP_MARK` to prevent offset update at range boundary
* use `QE_PROP_DUP` to optimize buffer properties with single allocation
* use mask in `eb_delete_properties` to delete tags selectively
* fix `eb_find_property` range glitch
* fix offset tracking for CWD properties
* simplify default directory selection for shell commands
* fix compiler warnings on variable shadow definitions
* optimize `next_error()`: no lookback needed anymore
* display buffer properties in `describe-buffer`
* update TODO.md
2026-06-13 18:12:57 +02:00
Charlie Gordon
eff66d1e8c Buffer/File: check for file changes
* keep track of original file size and time in buffer data
* check for file changes upon window change, buffer modification and save
* prompt for reloading buffer contents and other options
2026-06-04 15:08:24 +02:00
Charlie Gordon
c702bd012f Bufed: fix sorting order for system buffers 2026-05-27 01:43:40 +02:00
Charlie Gordon
897b7555d2 bufed: improve sorting method
* keep track of buffer creation, modification and access times
* add buffer sorting methods (buffer times, pathname, basename)
* always sort systems buffers last in alpha order
* small touch up in modeline
2026-05-23 22:34:28 +02:00
Charlie Gordon
21b00da0cb bufed/dired: toggle hex display for non-ASCII codepoints
* `dired-toggle-encoding` and `bufed-toggle-encoding` (key \)
  also toggle display of Unicode letters as hex escapes
2026-05-18 15:18:00 +02:00
Charlie Gordon
e89e07e318 bufed/dired: fix layout for non printing characters
* add `eb_put_filename()` to encode buffer or file names with
  non-ASCII characters according to PF_xxx flags
* add `CF_SAVE_LIST` flag for completions to store the list
  of matches in `MinibufState`
* fix bufed and dired layout issues
* fix buffer and filename completion popup layout
* add commands to control display of Unicode and non printing
  charcaters in buffer or file names:
  - U toggles unicode display
  - \ cycles through 4 possible encodings: ? ^J \x10 \010
* use `(*fp)()` syntax for indirect function calls
2026-05-18 12:31:06 +02:00
Charlie Gordon
5a37c1cbc3 occur: reuse the same buffer but clear contents
* use `BC_REUSE | BC_CLEAR` to avoid killing the `*occur*` buffer
* this ensures the `*occur*` buffer stays current in windows that show it
* modify the `BC_CLEAR` semantics to imply `BC_REUSE`
* simplify calls: remove redundant `BC_REUSE` flag
2026-05-11 19:16:05 +02:00
Charlie Gordon
e3c5bfd457
Remove references to global qe_state (#45)
* Remove references to global `qe_state`

Add `QEmacsState *qs` field in context and object structures:
- `QEditScreen`, `EditState` (renamed from `qe_state`), `QuitState`
- `WinWindow` (win32.c), `X11State` (x11.c), `QEArgs` (cmd line arguments)
- `CmdLineOptionDef::func_arg()`, `QEModeData`
- move `QEKeyContext` to `QEmacsState`

Pass `QEmacsState *qs` to configuration and state functions:
- all `module_xxx_init` and static `xxx_init` functions
- `QEDisplay::dpy_init()`, `qe_register_display()`, `screen_init()̀`
- `load_input_methods()`, `unload_input_methods()`
- `register_input_method()`, `find_input_method()`
- `find_resource_file()`, `open_resource_file()`
- `qe_find_current_binding()`, `qe_list_bindings()`
- `qe_register_mode()`, `qe_find_mode()`, `qe_find_mode_filename()`
- `qe_register_cmd_line_options()`, `set_user_option()`, `set_tty_charset()`
- `qe_register_commands()`, `qe_register_bindings()`, `qe_find_cmd()`
- `qe_register_completion()`, `qe_register_variables()`
- `eb_register_data_type()`, `parse_command_line()`
- `eb_trace_bytes()`, `qe_toggle_control_h()` (split from `do_toggle_control_h()`)
- `unget_key()`, `qe_grab_keys()`, `qe_ungrab_keys()`, `qe_key_process()`
- `eb_new()`, `eb_find()`, `eb_find_new()`, `eb_scratch()`, `eb_find_file()`
- `new_shell_buffer()` `macro_add_key()`, `clear_macro(), `stop_macro()`
- `check_window()`, `check_buffer()`, `qe_kill_buffer()`, `qe_get_history()`
- `qe_register_charset()`, `find_charset()`

Add error message handlers:
- add `QEDisplay::dpy_error()` method
- add `qe_cfg_error()`, use for all expression parsing errors
- pass opaque pointer to `css_error()`
- add `qe_put_error()` and `qe_dpy_error()`

Add context argument:
- always pass a non-null window pointer to `do_refresh()`, `new_help_buffer()`

Rename functions:
- `find_resource_file` -> `qe_find_resource_file`
- `open_resource_file` -> `qe_open_resource_file`
- `input_methods_init` -> `qe_input_methods_init`
- `load_input_methods` -> `qe_load_input_methods`
- `unload_input_methods` -> `qe_unload_input_methods`
- `find_input_methods` -> `qe_find_input_methods`
- `register_input_method` -> `qe_register_input_method`
- `parse_command_line` -> `qe_parse_command_line`
- `eb_trace_bytes` -> `qe_trace_bytes`
- `eb_init` -> `qe_data_init`
- `eb_count_buffers` -> `qe_count_buffers`
- `eb_get_buffer_from_index` -> `qe_get_buffer_from_index`
- `init_all_modules` -> `qe_init_all_modules`
- `exit_all_modules` -> `qe_exit_all_modules`
- `load_all_modules` -> `qe_load_all_modules`
- `maybe_set_mark` -> `do_maybe_set_mark`
- `unget_key` -> `qe_unget_key`
- `minibuffer_init` -> `qe_minibuffer_init`
- `edit_display` -> `qe_display`
- `new_yank_buffer` -> `qe_new_yank_buffer`
- `new_shell_buffer` -> `qe_new_shell_buffer`
- `shell_find_mode` -> `qe_shell_find_mode`
- `save_selection` -> `qe_save_selection`
- `register_emulation_bindings` -> `qe_register_emulation_bindings`
- `macro_add_key` -> `qe_macro_add_key`
- `clear_macro` -> `qe_clear_macro`
- `stop_macro` -> `qe_stop_macro`
- `eb_format_message` -> `qe_format_message`
- `screen_init` -> `qe_screen_init`
- `charset_jis_init` -> `qe_charset_jis_init`
- `charset_more_init` -> `qe_charset_more_init`
- `check_window` -> `qe_check_window`
- `check_buffer` -> `qe_check_buffer`
- `eb_find_file` -> `qe_find_buffer_file`
- `eb_find` -> `qe_find_buffer_name`
- `eb_new` -> `qe_new_buffer`
- `eb_find_new` -> `qe_new_buffer` with `BC_REUSE`
- `eb_scratch` -> `qe_new_buffer` with `BC_REUSE | BC_CLEAR`
- `find_charset` -> `qe_find_charset`

Add asan, msan and ubsan targets
Fix `qe_encode64` buffer length computation.
Add `qe_new_shell_buffer` flags `SF_REUSE_BUFFER` and `SF_ERASE_BUFFER`
Bumped version to 6.3.3
fix redundant typedef
fix compilation errors
2024-12-01 23:34:00 +01:00
Charlie Gordon
4bccb6f2d9 drop capitalized bufed bindings 2024-11-10 00:44:20 +01:00
Charlie Gordon
26c3d3a9b1 Improve buffer list
* sort normal, system, log and style buffers separately
* add `bufed-summary` command to display list of bufed commands
* cycle 3 filter levels with `.`: normal, system, log/style
* `bufed` requires extra `C-u` prefix to display log/style buffers
2024-10-11 09:14:16 +02:00
Charlie Gordon
7b803ace0e Improve syntax coloring APIs
* pass const `char32_t` array and `QETermStyle` array to `ColorizeFunc`
* add `cp_colorize_line()` wrapper to call colorizer function on null
  terminated buffer.
* remove unused `EditBuffer` colorize fields
* remove `EditState` field `colorize_func`: rely on `colorize_mode` only
* no longer combine style into codepoint buffer.
* remove `STYLE_BITS`, `STYLE_SHIFT`, `CHAR_MASK`
* rename `set_colorize_func` as `set_colorize_mode`
* rename `SET_COLOR` and `SET_COLOR1` as `SET_STYLE` and `SET_STYLE1`
* add documentation for buffer API functions
2024-07-28 00:00:03 +02:00
Charlie Gordon
e0d9a641d3
Add repeat-mode (#34)
- add `repeat` command on `C-x z`
- add `repeat-mode`, always enabled
- cycle all matching tags in current file on `goto-tag` and `find-tag`
- set up `repeat-mode` for these commands:
  - `undo` on `C-x u` (`u` repeats `undo`, `r` performs `redo`)
  - `undo` on `C-x r` (`r` repeats `redo`, `u` performs `undo`)
  - `find-window-left`, `find-window-right`, `find-window-up`, `find-window-dow`
    repeat navigation on `up`, `down`, `left`, `right`
  - `next-error`, `previous-error`: `M-n` and `M-p` repeat in corresponding direction
  - `next-buffer`, `previous-buffer: repeat buffers nagivation with `left` and `right`
  - `enlarge-window` / `shrink-window`: repeat resizing on `^`, `v`, `{`, `}`
     and cursor movement keys
  - `goto-tag` on `C-x ,` goto next tag with `,` and `.`
  - `call-last-kbd-macro` on `C-x e`: repeat macro on `e`
- add `eb_count_buffers` and `eb_get_buffer_from_index` for safe buffer navigation
- add transient bindings, known as repeat maps in GNU emacs
- pass `KeyDef **lp` (aka key maps) instead of mode for binding commands
- replace `do_next_buffer` and `do_prevous_buffer` with repeatable command
  `do_buffer_navigation`
- fix `bufed_select` crash bug when selecting buffer from a regular window
2024-05-25 23:37:05 +02:00
Charlie Gordon
a388a95305
Pass QEmacsState pointer to all module_init and module_exit functions (#24) 2024-05-19 19:15:08 +02:00
oguillaumin
f36144d6a8 Change license to MIT
* bumped VERSION to 6.0.0
2023-03-05 02:04:02 +01:00
Charlie Gordon
216b3ff8b7 Fix gcc 12.2 insane optimisation issues fixes issue #11
* use memcpy and other value casts to avoid strict aliasing violations.
  gcc 12.2 was wrongly assuming that utf8_decode(&p) did not modify p
  because *pp was never explicitly set, albeit *(const u8 **)pp = p; was
  storing te updated value of p into it and the code generated for that
  was produced.  The code generator was miscompiling strtokey1 because
  the compiler relied on bogus code analysis at the call site.

  The gcc team is wasting many hours of valuable debugging time.
  They should at least issue a warning about aliasing rules violations.

* fix compiler warning on missing Xvideo header

* fix compiler warning on missing fallthrough

* bump version to 5.4.1c
2022-11-11 17:49:50 +01:00
Charlie Gordon
7e70e611b6 Use char32_t for all code point variables and arrays
- char32_t is defined in cutils.h but may conflict with <uchar.h>
- all qe_isxxx functions take a char32_t
- add etf8x encoding for full range of char32_t type
- add utf8_decode_strict()
- add ustr_match_keyword()
- utf8_encode() / utf8_decode() handle up to 32 bits
- improve detect_charset():
  - detect utf8 and utf8x
  - avoid failure on partial utf8 sequence at end of buffer
  - detect overlong utf8 sequences
- fix display bugs for code points beyond MAX_UNICODE_DISPLAY
- simplify do_compare_windows(), avoid magic char values.
- rename functions:
    eb_encode_uchar -> eb_encode_char32
    eb_insert_uchar -> eb_insert_char32
    eb_insert_uchars -> eb_insert_char32_n
    eb_match_uchar -> eb_match_char32
    eb_delete_uchar -> eb_delete_char32
    eb_replace_uchar -> eb_replace_char32
    utf8_to_unicode -> utf8_to_char32
- use char32_t for all variables and arrays holding code-points
- fix some language syntax parsers.
- fix detect_eol_type_32bit(), used uint16_t instead of uint32_t
- bump VERSION to 5.4.0
2022-10-29 19:43:38 +02:00
Charlie Gordon
d1fb4dde64 Add macros for block comparison, copy and move
After spending a few hours debugging a stupid memcpy size error, I
decided to use a typed version of memcpy, memcmp and memmove wherever
the array type size is greater than 1.

- add blockcmp(p1, p2, n), blockcpy(p1, p2, n), blockmove(p1, p2, n)
  for operation on typed arrays
- add max_uint() and min_uint()
- bumped VERSION to 5.3.4w
2022-09-27 09:32:41 +02:00
Charlie Gordon
f8392d133b Improve describe-key-briefly, fix eb_printf
- fix prefix argument handling for describe-key
- echo prefix keys after "Describe key: " prompt
- move session commands to qe.c, remove them from tqe
- use byte_quote() in do_describe_buffer()
- use b->offset to track insertions in describe-xxx commands
- eb_putc(), eb_puts() and eb_printf() insert at `b->offset` instead of `b->total_size`
- do not use eb_write() in eb_trace_bytes()

- bump VERSION to 5.3.4p
2022-09-08 13:47:02 +02:00
Charlie Gordon
e7c7a14400 Improve qescript parser and evaluator
- improve operator lexer: produce token and precedence on 1 step
- merge parser.c and qescript.c

Fix other bugs
- close display before freeing memory in --free-all
- free TTYState in tty_dpy_close()
- free VarDef memory in --free-all
- fix crash bug on --free-all due to duplicating ModeDef structures

Improve variable handling:
- move do_describe_variable() to variable.c
- add var_alloc and str_alloc flags in VarDef to fix `end` hack
- remove ugly kludge to detect allocated strings
- type variables retrieved from environment
- free variable data on --free-all

- bump VERSION to 5.3.4m
2022-09-05 20:27:48 +02:00
Charlie Gordon
4475afab01 Use isearch pseudo mode for function dispatch
Extend command dispatch system:
- add CMD_ARG_OPAQUE argument type
- add ISS and ISSi command signatures for ISearchState
- add CMDx() macro for disabled and future commands
- restrict command set in parsers
- add opaque argument for exec_command()
- add sort-region command, same as sort-lines

Extend binding system:
- move do_unset_key() from extras.c to qe.c
- accept bindings lists in unset-key commands
- add exact argument for qe_find_binding()
- reorder xxx_bindings arrays

Improve emulation functions:
- improve set-emulation command:
  - add xxx_bindings arrays for emulations
  - add register_emulation_bindings()

Search system:
- use exec_command to dispatch isearch functions
  this allows easy redefinition of bindings, especially
  useful for emacs flavor emulations
- add isearch_commands[] with bindings and command descriptions

- bumped version to 5.3.4g
2022-08-30 10:00:42 +02:00
Charlie Gordon
f85805f683 Improved VT100 emulation in shell buffers
- add screen_top to avoid recomputing from buffer contents
- fix getline behavior on very long lines in shell buffer
- add LF bindings to run qemacs in lldb session
- qe_term_get_pos() returns screen start
- handle \t and wide chars inside shell buffers for xy positioning
- split qe_term_goto_pos() from qe_term_goto_xy()
- add flags in qe_term_goto_pos():
  TG_RELATIVE_COL: column number is relative to offset position
  TG_RELATIVE_ROW: row number is relative to offset position
  TG_RELATIVE: column and/or row is relative
  TG_NOCLIP: do not clip destx/desty coordinates
  TG_NOEXTEND: do not modify buffer to reach destination
- add qe_term_fix_wrap() to break wrapping lines
- fix qe_term_goto_tab() behavior on long lines
- fix qe_term_skip_lines() to handle wrapping lines
- handle UTF-8 for lastc and repeat graphics character
- bump VERSION to 5.3.3e
2022-08-26 12:30:29 +02:00
Charlie Gordon
3bbee69742 Multiple improvements
improve command and bindings registration:
- simplify command and binding registration APIs
- add bindings member in ModeDef structures
- rename qe_register_cmd_table() as qe_register_commands(), change API
- add qe_register_bindings() taking mode, command-name and bindings string
- rename qe_mode_set_key() as qe_register_command_binding()

improve buffer listing:
- add BF_SHELL buffer flag for shell buffers
- show current directory of shell buffers in bufed

improve dired:
- add dired-hide-details-mode on "("
- use details_mask to control long listing

improve trace doctor:
- add EB_TRACE_DEBUG trace flag for debugging traces
- add do_set_trace_flags()
- change do_start_trace_mode() to do_toggle_trace_mode() with arg

misc:
- fix make_user_path() for pathnames without a trailing slash
- use separate commands for prefix_argument handling
- improve strstart(), strend(), pstrcpy(), pstrncpy(), get_dirname()
- add strmatchword() like strstart with check for word boundary
- bumped version to 5.3.3d
2022-08-22 17:13:26 +02:00
Charlie Gordon
fe6edb336e Add more help functions
- add `describe-variable` on `C-h v` (need more work on documentation)
- show_popup() makes buffer READ_ONLY
- bumped version to 5.3.3b
2022-08-19 21:02:55 +02:00
Charlie Gordon
cde31421e7 More command description improvements
- use code characters from emacs (interactive) function
  - 'd' for numeric point value
  - 'p' for numeric prefix argument
  - 'P' for raw prefix argument
  - 'q' for negated numeric prefix argument
- handle synthetic and default arguments in parser.c
- add describe-function, bound to C-h f, need more work
- add sort-columns, sort-numbers, sort-paragraphs
- rename sort-region as sort-lines
- remove reverse-sort-buffer and reverse-sort-region
  passing C-u argument does reverse on all sort commands
- update TODO list
- bumped version to 5.3.3a
2022-08-19 16:52:26 +02:00
Charlie Gordon
8061f9493a Change command definitions
- pass description as 3rd argument to CMDx() macros
- normalize argument specifications
- 'p' means point
- 'a' means argval
- 'A' means argval premultiplied by value
- pass argval before value to do_split_window(),
  do_isearch(), do_sort_span(), do_sort_region(), do_sort_buffer()
- add SF_SILENT flag to suppress messages in eb_sort_span()
- bumped version to 5.3.3
2022-08-19 12:13:52 +02:00
Charlie Gordon
a6db66f470 Add command descriptions
- improve command definitions
- add descriptions for most commands
- bumped version to 5.3.2b
2022-08-18 01:33:00 +02:00
Charlie Gordon
1ba2c2b0bb Simplify and clean up command definitions
- use standard bindings string to all CMDx() definitions
- remove CMDx() key and alt_key
- remove compact key macros: KEY_CTRLX, KEY_CTRLXRET,
  KEY_CTRLH, KEY_CTRLC
- removed qe_register_binding2,
- qe_register_cmd_table() takes array length
- remove CMD_DEF_END and CmdDef chaining
- add CmdDefArray to store commands in const arrays
- strtokeys() takes end pointer
- add C-@ as name for null control key
- removed many hacks in CmdDef handling
- merge electric key commands
- fix ~ minibuffer behavior
- bumped version to 5.3.2
2022-08-16 22:40:44 +02:00
Charlie Gordon
d052ab31ff Fix many compilation warnings for clang -Weverything
- made some local objects static
- fix many const cast issues
- fix comma operator warnings
- add const correct strtol_c(), strtoll_c(), strtold_c()
- add unconst(t) to override const removal warnings
- comment VLAs and flexible arrays
- use get_basename_offset() to enable const correct
  get_basename() and get_basename_nc()
- use get_extension_offset() to enable const correct
  get_extension() and get_extension_nc()
- always include config.h
- use size_t for some size arguments:
  umemmove(), umemcpy(), umemcmp(), qe_memicmp()
- add qe-doc.info and qe-doc.pdf targets
- fix shadowing bug in buf_write: used tor return 0 instead of byte count
- bumped version to 5.3.1e
2022-08-10 18:50:19 +02:00
Charlie Gordon
46d9be3442 Reorganize repository tree
- move language syntax handling to `lang` directory
- move other modes to `modes` directory
- move tools to `tools` directory
- compile tools to `bin` directory
- bump version to 5.3alpha
- remove duplicate node names in qe-doc
- update Makefiles
2020-11-11 19:31:07 +01:00
Renamed from bufed.c (Browse further)