Commit Graph

16693 Commits

Author SHA1 Message Date
Fabian Boehm
30a37d9433 abbr: Make show output actually work
This would print

```
abbr -a -- dotdot --regex ^\\.\\.+\$ --function multicd
```

which expands "dotdot" to "--regex ^\\.\\.+\$...".

Instead, we move the name to right before the replacement, and move
the `--` before that:

```
abbr -a --regex ^\\.\\.+\$ --function -- dotdot multicd
```

It might be possible to improve that, but this at least round-trips.
2022-12-13 19:38:58 +01:00
Fabian Boehm
aca8c52660 CHANGELOG: Make abbr more prominent and explain it a bit more!
This is an *extremely* cool feature, we should tell people why!
2022-12-13 18:38:08 +01:00
Fabian Boehm
886b4b92b2 docs/abbr: Explain ctrl-space
This is now more important because we have regexes and global abbrs
2022-12-13 18:32:56 +01:00
Johannes Altmanninger
9790907ca8 abbr: stop parsing option after first expansion token
Historical behavior is to stop option parsing at the first non-option argument.
Since we have added more options, it seemed impractical to keep that behavior.

However people are using options in their abbr expansions ("abbr e emacs
-nw").  To support this, we ignore options. However, we only ignore them
if they are not valid "abbr" options.  Let's ignore all options in the
expansion definition, which is a small price to pay to keep most existing
configurations working.

Fixes #9410

This does not fix other cases which used to work, like

    abbr x -unknown

Those are hopefully not used by anyone, so I don't think we need to maintain
support for that.
2022-12-13 01:39:31 +01:00
David Adam
d14b4b96f0 CHANGELOG: work on 3.6.0 2022-12-13 07:17:33 +08:00
Johannes Altmanninger
c120305b8d
Merge pull request #9313 from ridiculousfish/mega-abbr
Enhances abbreviations with extra features
- global abbreviations
- trigger on regex match as alternative to literal match
- the ability to expand abbreviations with a user-defined function  
- the ability to set cursor position after expansion
2022-12-12 23:56:11 +01:00
ridiculousfish
6bc545d503 Use actual enum names in wgetopt
No functional change here.
2022-12-11 10:26:39 -08:00
nps1ngh
abc2fc2cb0
Completions for ouch (#9405)
* Completions for `ouch`

* `ouch` completions: also add `l` to subcommands
2022-12-11 15:08:30 +01:00
ridiculousfish
b2ee9c73e1 Call out more forcefully that abbreviations are interactive only 2022-12-10 16:29:46 -08:00
ridiculousfish
4c3953065a Update abbreviation completions to reflect new features 2022-12-10 16:29:43 -08:00
ridiculousfish
d8dbb9b259 Switch abbreviation '-r' flag from --rename to --regex
This will be the more common option and provides consistency with
`string`.
2022-12-10 16:21:39 -08:00
ridiculousfish
e08f4db1f9 Rename abbreviation cursor "sentinel" to "marker"
Also default the marker to '%'. So you may write:

    abbr -a L --position anywhere --set-cursor "% | less"

or set an explicit marker:

   abbr -a L --position anywhere --set-cursor=! "! | less"
2022-12-10 16:15:03 -08:00
ridiculousfish
01039537b0 Remove abbreviation triggers
Per code review, this does not add enough value to introduce now.
Leaving the feature in history should want want to revisit this
in the future.
2022-12-10 16:15:00 -08:00
ridiculousfish
35a4688650 Rename abbreviation triggers
This renames abbreviation triggers from `--trigger-on entry` and
`--trigger-on exec` to `--on-space` and `--on-enter`. These names are less
precise, as abbreviations trigger on any character that terminates a word
or any key binding that triggers exec, but they're also more human friendly
and that's a better tradeoff.
2022-12-10 15:38:50 -08:00
ridiculousfish
5841e9f712 Remove '--quiet' feature of abbreviations
Per code review, this is too risky to introduce now. Leaving the feature
in history should want want to revisit this in the future.
2022-12-10 15:38:50 -08:00
ridiculousfish
695cc74c88 Changelog new abbreviation features 2022-12-10 15:38:50 -08:00
ridiculousfish
22bd43f9d5 Document new abbreviation features 2022-12-10 15:38:50 -08:00
ridiculousfish
c51a1f1f60 Implement trigger-on for abbreviations
trigger-on enables abbreviations to trigger only on "entry" (anything
which closes a token, like space) or only on "exec" (typically enter key).
2022-12-10 15:38:50 -08:00
ridiculousfish
7118cb1ae1 Implement set-cursor for abbreviations
set-cursor enables abbreviations to specify the cursor location after
expansion, by passing in a string which is expected to be found in the
expansion. For example you may create an abbreviation like `L!`:

    abbr L! --position anywhere --set-cursor ! "! | less"

and the cursor will be positioned where the "!" is after expansion, with
the "| less" appearing to its right.
2022-12-10 15:38:50 -08:00
ridiculousfish
1d205d0bbd Reimplement abbreviation expansion to support quiet abbreviations
This reimplements abbreviation to support quiet abbreviations. Quiet
abbreviations expand "in secret" before execution.
2022-12-10 15:38:46 -08:00
ridiculousfish
8135c52c13 Abbreviations to support functions
This adds support for the `--function` option of abbreviations, so that the
expansion of an abbreviation may be generated dynamically via a fish
function.
2022-12-10 15:29:04 -08:00
ridiculousfish
d15855d3e3 Abbreviations to support matching via regex
This adds the --regex option to abbreviations, allowing them to match a
pattern of tokens.
2022-12-10 15:29:04 -08:00
ridiculousfish
470153c0df Refactor abbreviation set into its own type
Previously the abbreviation map was just an unordered map; switch it to a
real class so we can hang methods off of it.
2022-12-10 15:29:04 -08:00
ridiculousfish
1402bae7f4 Re-implement abbreviations as a built-in
Prior to this change, abbreviations were stored as fish variables, often
universal. However we intend to add additional features to abbreviations
which would be very awkward to shoe-horn into variables.

Re-implement abbreviations using a builtin, managing them internally.

Existing abbreviations stored in universal variables are still imported,
for compatibility. However new abbreviations will need to be added to a
function. A follow-up commit will add it.

Now that abbr is a built-in, remove the abbr function; but leave the
abbr.fish file so that stale files from past installs do not override
the abbr builtin.
2022-12-10 15:29:03 -08:00
ridiculousfish
635cc3ee8d Add interactive tests for abbreviations 2022-12-10 15:28:48 -08:00
ridiculousfish
5523eb36db Switch functions tests from abbr to vared
abbr was a random function that was tested by this check, but we no
longer have an abbr function so switch to a new one.
2022-12-10 12:24:43 -08:00
ridiculousfish
d2daa921e9 Introduce re::make_anchored
This allows adjusting a pattern string so that it matches an entire
string, by wrapping the regex in a group like ^(?:...)$

This is a workaround for the fact that PCRE2_ENDANCHORED is unavailable
on PCRE2 prior to 2017, so we have to adjust the pattern instead.

Also introduce an overload of match() which creates its own
match_data_t.
2022-12-10 12:24:43 -08:00
ridiculousfish
fe7d095647 Add maybe_t::value_or
This enables getting the value or returning the passed-in value.
This is helpful for "default if none."
2022-12-10 12:24:43 -08:00
Johannes Altmanninger
892a820672 Make sure that cd to a relative CDPATH results in absolute $PWD
We have had multiple crashes for relative CDPATH entries.  Commit 5e274066e
(Always return absolute path in path_get_cdpath, 2019-10-17) tried to fix
all of them but it failed to do justice to its title.  Let's fix this to
actually return absolute paths, always.  Take care to to normalize the path
because it is used for autosuggestions. The normalization is mostly relevant
for CDPATH=. (the default) but it doesn't hurt others.

Closes #9407
2022-12-10 11:06:54 +01:00
ridiculousfish
b0ec7e07b8 Fix a wgetopt crash and add a test
This has apparently been a problem since forever.
2022-12-09 13:54:00 -08:00
Johannes Altmanninger
f81e8c7deb completions/git: complete refs for "git grep" 2022-12-08 14:57:48 +01:00
Johannes Altmanninger
e9bf8b9a4e Run fish_indent on share/completions/*.fish 2022-12-08 14:57:48 +01:00
David Adam
aa3d2c89b3 CHANGELOG: work on 3.6.0 2022-12-08 19:34:22 +11:00
Fabian Boehm
d640e0d0d6 docs/language: Some slight tweaks
It reads nicer to not have the "see also" thing right in the first
paragraph. I'm not even done reading this, why are you sending me
elsewhere?

(of course if it's a hotlink on a specific word that's different)
2022-12-07 21:47:00 +01:00
Fabian Boehm
02e11773ad docs/css: Make h4s visible
Otherwise this just looks like normal text. Same size as h3 for now,
we might want to think about another indicator - underlines?
background color?
2022-12-07 21:47:00 +01:00
Bagohart
494615891b added completion for git branch --remotes (-r) 2022-12-07 20:19:28 +01:00
ridiculousfish
35bad1f94c Untangle some pointers in wgetopt
wgetopt had a "nameend" parameter which was a confusing pointer. Make it
into a slightly less confusing size_t.
2022-12-04 14:48:20 -08:00
ridiculousfish
962d1083d3 Remove wgeopter_t::wopterr
wopterr was a feature to allow wgetopt to emit error messages; but we do
not use this and never will. Remove its support. No functional change
expected here.
2022-12-04 12:03:13 -08:00
Johannes Altmanninger
6072ea1900 Fix false positive cd higlighting when token ends in slash
We wrongly highlight this as prefix when actually the trailing slash should
invalidate it. Turns out path normalization drops the slash, so let's
sidestep that.

Fixes #9394
2022-12-03 22:36:56 +01:00
ridiculousfish
4159b2a33b Disable shebangless script tests in CI with sanitizers
Sanitizers inject a busted posix_spawn interceptor which mishandles
shebangless scripts. Disable this test under sanitizers.
2022-12-02 17:32:52 -08:00
EmilySeville7cfg
717800cd6c Add nu completion 2022-12-02 13:12:57 -06:00
calfcalfcalfd
e41ba6a2b6 Fixed typo in xrandr completions 2022-12-02 12:46:42 -06:00
Fabian Boehm
e34f0e7c9f docs: Add some more envvars to reference
(and fix a couple of references)
2022-12-01 18:00:06 +01:00
Fabian Boehm
65a00c80b3 docs: Explain what times output means 2022-12-01 17:56:57 +01:00
ridiculousfish
39b7f112c7 Remove the "flag" field from woption
The "flag" field enables an option to discover which flag it was invoked
with. However in practice none of our options use multiple flags so this
parameter was always nullptr. Remove it and fix up all the builtins to
stop passing this.

No functional change here.
2022-11-29 16:08:37 -08:00
exploide
e4cde861a4 completions hostnamectl: updated to systemd 251 2022-11-29 17:31:02 -06:00
Mahmoud Al-Qudsi
063450b8f4 Update likely/unlikely macros to avoid double negation
I believe this should be identical to the previous code and handle the same
cases (I'm guessing going by the comment that this came from a C codebase
without `bool` types).

The problem with the previous code is that it tripped up the `clangd` analyzer
into thinking `assert()` expressions can/should be simplified via DeMorgan's to
improve readability (because it was seeing the fully expanded macro).
2022-11-29 13:26:32 -06:00
ridiculousfish
7ee161af8d Fix the flaky tty_ownership test on Mac
The tty_ownership test was sometimes failing. In this test,
`fish_test_helper` creates a child and transfers the tty to it,
"abandoning" the tty. In some cases, the child was running before the
parent; the child claims the tty. When the parent tries to transfer it to
the child, it get SIGTTIN and stops. Fix this by ignoring SIGTTIN and
SIGTTOU.

This only affects macOS and BSDs.
2022-11-28 15:01:12 -08:00
Aaron Gyes
b6ca8dca27 ksh.fish fixup: remove errant line 2022-11-27 20:50:00 -08:00
Aaron Gyes
fd252daafd ksh completions: add descriptions
Also remove options ksh --help says are obsolete.
FWIW ksh93 does a bit more than what is here but this is pretty
good.
2022-11-27 20:46:14 -08:00