diff options
author | Oliver Kiddle <opk@zsh.org> | 2021-06-03 00:12:54 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2021-06-03 00:12:54 +0200 |
commit | f4b2a03625680ad27a3bc77ccec358582aee9094 (patch) | |
tree | 52ffeacfdd83d1fc3b4c285f06a4c58c565813e2 | |
parent | a21c0b334c38e6d2a29bc7e0d7697b23d720b64c (diff) | |
download | zsh-f4b2a03625680ad27a3bc77ccec358582aee9094.tar.gz zsh-f4b2a03625680ad27a3bc77ccec358582aee9094.tar.xz zsh-f4b2a03625680ad27a3bc77ccec358582aee9094.zip |
48952: expand octal codes for record separators in perl completion
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Completion/Unix/Command/_perl | 99 |
2 files changed, 63 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog index 772ac111a..9edf9418b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2021-06-02 Oliver Kiddle <opk@zsh.org> + * 48952: Completion/Unix/Command/_perl: expand octal codes for + record separators in perl completion + * 48938 (minus _cdrdao changes): Completion/Unix/Command/_pandoc, Completion/Unix/Command/_bpython: remove vim fold and option markers diff --git a/Completion/Unix/Command/_perl b/Completion/Unix/Command/_perl index 0914264fe..4a917903c 100644 --- a/Completion/Unix/Command/_perl +++ b/Completion/Unix/Command/_perl @@ -1,14 +1,10 @@ #compdef perl -# -# zsh completion code for the Perl interpreter -# Adam Spiers <adam@spiers.net> -# -# Completions currently based on Perl 5.14.1. + typeset -A opt_args _perl () { _arguments -s \ - '-0-[input record separator ($/)]:$/ in octal or hex (\0, if no argument)' \ + '-0-[input record separator ($/)]:: :_perl_input_seps' \ '-a[autosplit mode with -n or -p (splits $_ into @F)]' \ '-C-[control some unicode features]: :_perl_unicode_flags' \ "-c[check syntax only (runs BEGIN and END blocks)]" \ @@ -24,7 +20,7 @@ _perl () { '-h[list help summary]' \ '-i-[edit <> files in place (make backup if extension supplied)]:backup file extension: ' \ '*-I-[specify @INC/#include directory (may be used more than once)]:include path:_files -/' \ - '-l-[enable line ending processing, specifies line terminator]:output record separator in octal: ' \ + '-l-[enable line ending processing, specifies line terminator]:: :_perl_output_seps' \ \*{-m,-M}"-[module.. executes \`use/no module...' before executing your script]:module:_perl_m_opt" \ "-n[assume 'while (<>) { ... }' loop around your script]" \ "-p[assume loop like -n but print line also like sed]" \ @@ -63,6 +59,27 @@ _perl_m_opt () { fi } +_perl_input_seps() { + if [[ $#PREFIX -eq 1 && $PREFIX != [0-9a-zA-Z] ]]; then + # convert a non-octal or potential option character into octal representation + compadd -i "$IPREFIX" -U $(( [##8] ##$PREFIX )) + else + _describe -x -t separators "input record separator, $/ in octal or hex (\0, if no argument) [\n]" '( + 0:paragraph\ mode + 777:slurp\ whole\ input\ files + )' || _comp_mesg=yes + fi +} + +_perl_output_seps() { + if [[ $#PREFIX -eq 1 && $PREFIX != [0-9a-zA-Z] ]]; then + # convert a non-octal or potential option character into octal representation + compadd -i "$IPREFIX" -U $(( [##8] ##$PREFIX )) + else + _message -e separators "output record separator, $\\ in octal or hex [$/]" + fi +} + _perl_config_vars () { if (( ! $+_perl_config_vars )); then _perl_config_vars=( $(perl -MConfig -e 'print join("\n", keys %Config);') ) @@ -80,44 +97,48 @@ _perl_config_vars () { _perl_unicode_flags () { _values -s '' 'unicode bitmask or flags' \ - 'I[ 1 STDIN is assumed to be in UTF-8]' \ - 'O[ 2 STDOUT will be in UTF-8]' \ - 'E[ 4 STDERR will be in UTF-8]' \ - 'S[ 7 I + O + E]' \ - 'i[ 8 UTF-8 is the default PerlIO layer for input streams]' \ - 'o[ 16 UTF-8 is the default PerlIO layer for output streams]' \ - 'D[ 24 i + o]' \ + '(S)I[ 1 STDIN is assumed to be in UTF-8]' \ + '(S)O[ 2 STDOUT will be in UTF-8]' \ + '(S)E[ 4 STDERR will be in UTF-8]' \ + '(I O E)S[ 7 I + O + E]' \ + '(D)i[ 8 UTF-8 is the default PerlIO layer for input streams]' \ + '(D)o[ 16 UTF-8 is the default PerlIO layer for output streams]' \ + '(i o)D[ 24 i + o]' \ 'A[ 32 the @ARGV elements are expected to be strings encoded in UTF-8]' \ 'L[ 64 make "IOEioA" conditional on the locale environment variables]' \ 'a[256 set ${^UTF8CACHE} to -1, used for debugging]' \ } _perl_debugging_flags () { - _values -s '' 'debugging bitmask or flags' \ - 'p[ 1 Tokenizing and parsing (with v, displays parse stack)]' \ - 's[ 2 Stack snapshots (with v, displays all stacks)]' \ - 'l[ 4 Context (loop) stack processing]' \ - 't[ 8 Trace execution]' \ - 'o[ 16 Method and overloading resolution]' \ - 'c[ 32 String/numeric conversions]' \ - 'P[ 64 Print profiling info, preprocessor command for -P, source file input state]' \ - 'm[ 128 Memory and SV allocation]' \ - 'f[ 256 Format processing]' \ - 'r[ 512 Regular expression parsing and execution]' \ - 'x[ 1024 Syntax tree dump]' \ - 'u[ 2048 Tainting checks]' \ - 'U[ 4096 Unofficial, User hacking (reserved for private, unreleased use)]' \ - 'H[ 8192 Hash dump -- usurps values()]' \ - 'X[ 16384 Scratchpad allocation]' \ - 'D[ 32768 Cleaning up]' \ - 'S[ 66536 Thread synchronization]' \ - 'T[ 131072 Tokenising]' \ - 'R[ 262144 Include reference counts of dumped variables (eg when using -Ds)]' \ - 'J[ 524288 Do not s,t,P-debug (Jump over) opcodes within package DB]' \ - 'v[1048576 Verbose: use in conjunction with other flags]' \ - 'C[2097152 Copy On Write]' \ - 'A[4194304 Consistency checks on internal structures]' \ - 'q[8388608 quiet - currently only suppresses the "EXECUTING" message]' \ + _values -s '' 'debug flag or bitmask' \ + 'p[ 1 tokenizing and parsing (with v, display parse stack)]' \ + 's[ 2 stack snapshots (with v, display all stacks)]' \ + 'l[ 4 context (loop) stack processing]' \ + 't[ 8 trace execution]' \ + 'o[ 16 method and overload resolution]' \ + 'c[ 32 string/numeric conversions]' \ + 'P[ 64 print profiling info, source file input state]' \ + 'm[ 128 memory and SV allocation]' \ + 'f[ 256 format processing]' \ + 'r[ 512 regular expression parsing and execution]' \ + 'x[ 1024 syntax tree dump]' \ + 'u[ 2048 tainting checks]' \ + 'U[ 4096 unofficial, user hacking (reserved for private, unreleased use)]' \ + 'X[ 16384 scratchpad allocation]' \ + 'D[ 32768 cleaning up]' \ + 'S[ 66536 Op slab allocation]' \ + 'T[ 131072 tokenising]' \ + 'R[ 262144 include reference counts of dumped variables (e.g. when using -Ds)]' \ + "J[ 524288 show s,t,P-debug (don't jump over) on opcodes within package DB]" \ + 'v[ 1048576 verbose: use in conjunction with other flags]' \ + 'C[ 2097152 copy-on-write]' \ + 'A[ 4194304 consistency checks on internal structures]' \ + 'q[ 8388608 quiet - currently only suppresses the "EXECUTING" message]' \ + 'M[ 16777216 trace smart match resolution]' \ + 'B[ 33554432 dump subroutine definitions, including special blocks like BEGIN]' \ + 'L[ 67108864 trace locale-related info]' \ + 'i[134217728 trace PerlIO layer processing]' \ + 'y[268435456 trace y///, tr/// compilation and execution]' } _perl "$@" |