From b6344b3be1978695889371de83ac4d15352e4fee Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 11 Mar 2024 12:43:17 +0900 Subject: [PATCH] edit: support "bleopt edit_magic_{expand,accept}=autocd" --- blerc.template | 24 ++++++++-------- docs/ChangeLog.md | 6 ++-- lib/core-complete-def.sh | 3 +- lib/core-complete.sh | 22 +++++++++++++- note.txt | 7 +++++ src/edit.sh | 62 ++++++++++++++++++++++++++-------------- 6 files changed, 86 insertions(+), 38 deletions(-) diff --git a/blerc.template b/blerc.template index 53331954..6e1e6260 100644 --- a/blerc.template +++ b/blerc.template @@ -120,7 +120,7 @@ ## The following option specifies the set of expansions performed by ## magic-space with a colon-separated list of expansion types. "history", -## "sabbrev", and "alias" can be specified. +## "sabbrev", "alias", and "autocd" can be specified. #bleopt edit_magic_expand=history:sabbrev @@ -135,17 +135,17 @@ ## This option specifies the expansions performed on accept-line by a ## colon-separated list. The expansion is performed in a similar way as Bash's -## history expansion. When "sabbrev", "alias", and "history" is specified, the -## respective expansions are attempted on the command line. When "verify" is -## specified, if sabbrev or alias expansions changed the command line, the -## execution of the command line is canceled so the user can examine or -## continue to edit the expanded line. The history expansion can be controlled -## by "shopt -s histverify" in a similar manner. When "verify-syntax" is -## specified and any expansions change the command string, a syntax check is -## performed. The command execution is canceled when the command string is not -## syntactically complete. When "history-line" is specified, the history -## expansion replaces the command line instead of just printing the expansion -## result. The default value of this option is empty. +## history expansion. When "sabbrev", "alias", "autocd", and "history" is +## specified, the respective expansions are attempted on the command line. +## When "verify" is specified, if sabbrev, alias, or autocd expansions changed +## the command line, the execution of the command line is canceled so the user +## can examine or continue to edit the expanded line. The history expansion +## can be controlled by "shopt -s histverify" in a similar manner. When +## "verify-syntax" is specified and any expansions change the command string, a +## syntax check is performed. The command execution is canceled when the +## command string is not syntactically complete. When "history-line" is +## specified, the history expansion replaces the command line instead of just +## printing the expansion result. The default value of this option is empty. #bleopt edit_magic_accept=sabbrev diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 73332850..021ffc29 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -25,9 +25,11 @@ - main: support `bash ble.sh --install` `#D2169` 986d26a3 3801a87e - util(stty): support `bleopt term_stty_restore` (requested by TheFantasticWarrior) `#D2170` e64b02b7 - util: update workaround of Bash 5.2 `checkwinsize` for `term_stty_restore` (reported by TheFantasticWarrior) `#D2184` ef8272a4 -- edit: support `bleopt edit_magic_accept` (requested by pl643, bkerin) `#D2175` 3e9d8907 +- magic expansions + - edit: support `bleopt edit_magic_accept` (requested by pl643, bkerin) `#D2175` 3e9d8907 + - edit: support `bleopt edit_magic_accept=verify-syntax` `#D2178` ac84c153 + - edit: support `bleopt edit_magic_{expand,accept}=autocd` (motivated by Jai-JAP) `#D2187` xxxxxxxx - main: support shell variable `BLE_VER` `#D2177` a12dedab -- edit: support `bleopt edit_magic_accept=verify-syntax` `#D2178` ac84c153 - util(bleopt, blehook, ble-face): support wildcards `*` and `?` and change `@` to match an empty string `#D2182` bf595293 ## Changes diff --git a/lib/core-complete-def.sh b/lib/core-complete-def.sh index 76291c80..7aba307d 100644 --- a/lib/core-complete-def.sh +++ b/lib/core-complete-def.sh @@ -117,7 +117,8 @@ ble/util/autoload "$_ble_base/lib/core-complete.sh" \ ble-decode/keymap:menu_complete/define \ ble-decode/keymap:dabbrev/define \ ble/complete/sabbrev/expand \ - ble/complete/alias/expand + ble/complete/expand:alias \ + ble/complete/expand:autocd bleopt/declare -v complete_source_sabbrev_opts '' bleopt/declare -v complete_source_sabbrev_ignore '' diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 6b9d2da2..955dca7a 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -9391,7 +9391,7 @@ function ble/complete/source:sabbrev { done } -function ble/complete/alias/expand { +function ble/complete/expand:alias { local pos comp_index=$_ble_edit_ind comp_text=$_ble_edit_str ble/complete/sabbrev/locate-key 'command' ((pos