195 Commits

Author SHA1 Message Date
Paul Ackersviller
ac0b03f59a Little bit cleaner method of calling add-zle-hook-widget with no_unset. 2016-12-24 15:59:40 -05:00
Paul Ackersviller
b68c2701d0 Remove stray leftover debug option. 2016-12-21 19:44:18 -05:00
Paul Ackersviller
275943a3eb Allow for all tests to run with no_unset option, and use it via -u flag in makefile. 2016-12-21 19:12:03 -05:00
Paul Ackersviller
a5a28a194a reverse my inital changes to put on branch instead 2016-12-18 23:34:58 -05:00
Paul Ackersviller
b46769b181 synced up to latest 2016-12-18 23:30:55 -05:00
Daniel Shahaf
2cf6a48096 Merge remote-tracking branch 'upstream/master' into upstream/pr/356
* upstream/master:
  'main': Enable fallback to the 'arg0' style.
  'main': Set fallback style for the 'arg0' style.
  dev tools: Automagically handle newlines (\n) in $BUFFER.
  tests: Also test arguments to an anonymous function.
  'main': Directly count spaces to skip, don't leverage proc_buf length
  'main': Highlight several more special (non-alphabetic) parameters.
  'main': Highlight shell's PID ($$) inside double quotes.
  'main': Highlight command substitutions inside double quotes.
  'main': Permit subshells to end at command position.
  'main': Highlight mismatched foreach/end.
  dev tools: Add a TODO to introduce code reuse.
  'main': Highlight mismatched do/done.
  'main': Yet another test for mismatched braces.
  'main' / *_check_path: Precompute $#BUFFER and use it for speed gain
  dev tools: Remove a superfluous empty line.
  'main': Highlight 'always' blocks.
  'main': Don't find command positions within multiline array literals.
  dev tools: Stage the copyright block to make diffs smaller.
  dev tools: Tolerate invalid input.
  'main': Restore compatibility with zsh-4.3.14 and older (after e3182c18de8f).
  dev tools: Automate a recurring step: Set year correctly for new tests.
  'main': Highlight first command word in named functions defined in the sh syntax when MULTI_FUNC_DEF is set.
  'main': More tests for mismstached parentheses and braces.
  'main': Highlight mismatched parentheses and braces.
  driver: Warn just once when a highlighter is missing.
  'main': Support the IGNORE_BRACES option.
  'main': Add tests for the IGNORE_BRACES option.
  'main': Followup to 51614ca2c994: Run cheaper conditions first.
  'brackets': Don't highlight corresponding bracket on accept-line
  driver: Declare global variables
  'main': Avoid triggering a zsh bug related to hashed commands.
  *: error messages: Fix quoting.
  highlighters: Rename entry points.
  driver: Rename highlighter entry points
  driver: Followup to 80148f6c840299f0980f4359ec5307ca63837dff: don't squat on the highlighters' namespace.
  driver: Followup to d711563fe1bf8fa6810bc34ac92a2fd3150290ed: actually make the driver reentrant.
  noop: Rewrap.
  README: Add a reference to upstream's documentation.
  README: Rephrase a question non-negatively^W neutrally.
  noop: Add comments.
  'main': The word after 'sudo' is only a non-command word if it is an option.
  'main': Test for redirection earlier.
  noop: Restructure code for clarity.
  noop: Fix indentation.
  driver: Followup to last: make the value more unique.
  driver: Make it reentrant.
  minor: Fix typo in development usage message.
  driver: Enable highlighting during isearch under zsh≥5.3.
  driver: Don't highlight in isearch
  driver: Always bind zle-line-finish and use it instead of accept-*
  driver: Widget binding: Support binding incomplete/nonexistent widgets
  dev tools: Extend tests/generate.zsh.
  dev tools: Add a script that generates a test-data file.
  'main': Enable test for issue #238.
  'main': Add test for issue #343, concerning the 'command' precommand.
  'main': New test, related to issue #328.
  *: s/echo/print/
  'main': Highlight a broken symlink as a file.
  tests: Add an XFail test for issue #342.
  docs: Minor tweak.
  docs: State highlighters' designated namespace.
  docs: s/myhighlighter/acme/g
  driver: Change a variable name to avoid squatting the highlighters' namespace.
  tests: Add a regression test for issue #267, concerning highlighting a vi linewise region.
  driver: Widget binding: Use ${(k)widgets} instead of $(zle -la)
  Support linewise region.

Conflicts:
	README.md
	zsh-syntax-highlighting.zsh
2016-10-17 17:45:02 +00:00
Daniel Shahaf
5591e2adb1 driver: Rewrite without a state variable
Suggested-by: m0viefreak
2016-10-17 15:13:19 +00:00
Daniel Shahaf
9872a186bc noop: Make a whitespace-only change to reduce noise in the next commit. 2016-10-17 14:49:53 +00:00
Paul Ackersviller
0bac9581bb more ERR trap fixes 2016-10-13 20:54:51 -04:00
Paul Ackersviller
4d0c5604d9 nother error trap to prevent 2016-10-12 23:34:29 -04:00
Paul Ackersviller
8c47e82475 run error at sdf 2016-10-12 21:07:47 -04:00
Paul Ackersviller
b267c7b4e7 Quieten non-zero commands reported by err trap. 2016-10-09 23:47:17 -04:00
Daniel Shahaf
0a9b347483 driver: Warn just once when a highlighter is missing.
The heretofore code warned once per keypress.
2016-09-22 04:10:28 +00:00
Daniel Shahaf
a8b842bddb redo _zsh_highlight__function_callable_p 2016-09-16 05:12:20 +00:00
Daniel Shahaf
b30e5b593e driver: Use a different way of checking whether add-zle-hook-widget is present.
Based on code by Bart Schaefer (reference within).

Tested with zsh 5.0.7-5 (debian package) and with 5b4cbcc842c6 (39158,
5.3-to-be of today).
2016-09-16 04:25:14 +00:00
Alyssa Ross
da60234fb2 driver: Declare global variables
This caused warnings with `setopt warn_create_global`.
2016-08-31 16:26:09 +00:00
Daniel Shahaf
51614ca2c9 'main': Avoid triggering a zsh bug related to hashed commands.
This manifested in completion of the form «./foo<TAB>» where there happened to
be a program called 'foo' in $PATH.

Fixes #354.
Closes #355.
2016-08-30 02:56:23 +00:00
Daniel Shahaf
eb506b52b4 driver: Pass zle-line-finish arguments on to _zsh_highlight.
(Currently a noop)
2016-08-24 22:56:09 +00:00
Daniel Shahaf
11c9081967 *: error messages: Fix quoting. 2016-08-16 19:01:25 +00:00
Daniel Shahaf
c7f7d2ff16 *: Change highlighters' namespace.
Fixes #329.

Merge remote-tracking branch 'danielsh/i329-v1'

* danielsh/i329-v1:
  highlighters: Rename entry points.
  driver: Rename highlighter entry points
2016-08-16 17:53:01 +00:00
Daniel Shahaf
a3d5dfcbda driver: Rename highlighter entry points
This updates the docs and the driver, in a manner backwards compatible with
existing highlighters.  (None of the highlighters are touched by this change,
yet tests continue to pass.)

Part of issue #329.
2016-08-16 17:51:43 +00:00
Daniel Shahaf
f91a7b885e driver: Followup to 80148f6c840299f0980f4359ec5307ca63837dff: don't squat on the highlighters' namespace. 2016-08-16 17:49:18 +00:00
Daniel Shahaf
f3242cbd6a driver: Followup to d711563fe1bf8fa6810bc34ac92a2fd3150290ed: actually make the driver reentrant.
Re-fixes #305.
2016-08-16 17:22:39 +00:00
Daniel Shahaf
295d62ec88 driver: Followup to last: make the value more unique.
Part of issue #305.
2016-08-12 09:43:54 +00:00
Daniel Shahaf
d711563fe1 driver: Make it reentrant.
This fixes an infinite recursion in zsh without zle-line-pre-redraw [≤5.2] in
the following situation:

% source zsh-syntax-highlighting.zsh
% eval "my-self-insert() { zle -M 'foobar'; ${(q)widgets[self-insert]#*:} \"\$@\" }"
% zle -N self-insert my-self-insert
% source zsh-syntax-highlighting.zsh

Fixes #305.
2016-08-12 09:19:36 +00:00
m0viefreak
4ad311ec0a driver: Enable highlighting during isearch under zsh≥5.3.
This patch causes a behaviour difference in the [i257] scenario:

- Before this change, the zle_highlight[isearch] is applied and z-sy-h's
  highlighting isn't.

- With this change, both zle_highlight[isearch] and z-sy-h's
  highlighting are applied, so «echo foo» renders the first word in green
  underline (fg=green from ZSH_HIGHLIGHT_STYLES[builtin], underline from
  zle_highlight[isearch]).

This patch causes the presuppositional FAQ entry added in
a8fe22d422515a46a4c2e968ff37762c577059bc to be correct.

This is part of #261, of which #288 was a spin-off.

[i257] https://github.com/zsh-users/zsh-syntax-highlighting/pull/257#issuecomment-168394665
2016-07-30 20:08:12 +00:00
m0viefreak
a8fe22d422 driver: Don't highlight in isearch
zsh version 5.2 and lower don't support ISEARCHMATCH_ACTIVE and
we are unable to re-apply zle_highlight on top. Therefore it is
impossible to see the underlined matched area.

Since that information is more important, completely disable
highlighting in isearch in that case.

To do that, we need to make sure we are actually called when
something changes in isearch.

Trumps #257.

The FAQ entry presupposes #245 will be fixed (in time for the release) too.
2016-07-29 21:07:48 +00:00
m0viefreak
5bae621900 driver: Always bind zle-line-finish and use it instead of accept-*
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps #259.
Fixes #284.
2016-07-29 20:41:06 +00:00
m0viefreak
9e569bb0fe driver: Widget binding: Support binding incomplete/nonexistent widgets 2016-07-29 20:41:06 +00:00
Daniel Shahaf
a7470586a9 driver: Hook zle-line-finish.
Compare issue #288.
2016-07-29 20:33:59 +00:00
Daniel Shahaf
3409a2e4d2 *: s/echo/print/
Just in case one of the interpolated variables contains a backslash.
2016-07-21 04:01:50 +00:00
Daniel Shahaf
3e59ab41b6 driver: Change a variable name to avoid squatting the highlighters' namespace.
Part of issue #329.
2016-07-12 06:50:49 +00:00
Daniel Shahaf
d13da0cf00 'main': Support vi linewise region (REGION_ACTIVE == 2).
Merge remote-tracking branch 'danielshahaf/i267-linewise-region-v1'

* danielsh/i267-linewise-region-v1:
  tests: Add a regression test for issue #267, concerning highlighting a vi linewise region.
  Support linewise region.
2016-07-01 02:00:10 +00:00
m0viefreak
b9112aec79 driver: Widget binding: Use ${(k)widgets} instead of $(zle -la)
Avoids a fork.
2016-06-20 18:37:11 +00:00
Daniel Shahaf
98aab2024c driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw'
This feature will be released in zsh 5.3.  Older zsh's will use the existing
codepath.
2016-06-15 23:26:23 +00:00
Daniel Shahaf
ef41c9232d wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650). 2016-06-15 21:45:55 +00:00
Daniel Shahaf
750aebc553 driver: Stop requiring function_argzero.
Instead, use the %N prompt expando, as suggested by Bart in users/21637.

Avoid the `print -P %N` syntax to save a fork on Cygwin, at the expense
of not supporting zsh's from 2001 through c. 2004 vintages.

Fixes #338.
2016-06-10 15:18:46 +00:00
Daniel Shahaf
4b77af73fb minor: Fix typo in comment.
Two instances.
2016-06-03 08:41:45 +00:00
m0viefreak
3ce01076b5 driver: load zsh/parameter if available 2016-05-13 02:24:57 +00:00
Daniel Shahaf
a7a7f8b422 Support linewise region.
Fixes #267.
2016-05-09 04:10:02 +00:00
Daniel Shahaf
15db71abd0 driver: Track rename of an unreleased upstream API.
ISEARCH_ACTIVE was renamed ISEARCHMATCH_ACTIVE in workers/38921
(commit f06be0ffcf2c to zsh itself).

Fixes #299.
2016-05-09 03:38:27 +00:00
Matthew Martin
fd061b5730 tests: Test ZSH_HIGHLIGHT_STYLES keys directly
Closes #287. Testing the keys directly removes the need for
unused_highlight which will be removed next.
2016-05-05 12:28:39 -05:00
Daniel Shahaf
f34714b8ee Bump copyright years. 2016-04-30 02:11:17 +00:00
Matthew Martin
341a3ae1f0 highlighters: Use _zsh_highlight_add_highlight
_zsh_highlight_add_highlight appends to region_highlight $1 $2 and the
next non-null parameter. If there is no non-null parameter, do nothing,
This is so that highlighters can add a style with fallbacks if the most
specific style is not defined. If none of the applicable styles are
defined, do the right thing and don't add an invalid entry to
region_highlight.

The pattern highlighter doesn't use this function as it'd need too large
of an API change.
2016-04-29 10:09:16 -05:00
Daniel Shahaf
c54c076cfa cleanup: Avoid colon after parameter expansion to avoid risking introducing a colon modifier. 2016-04-24 17:08:08 +00:00
m0viefreak
79e4d3d124 apply suffix and isearch zle_highlights on top 2016-03-28 18:24:29 +02:00
Daniel Shahaf
cb02451a4e widget binding: Fix crucial typo in last commit. 2016-03-18 15:14:09 +00:00
Daniel Shahaf
11d378332e widget binding: Further unbreak the build.
7e7e291b2047 broke 'zle -C' completions, as reported in #278 just now.
2016-03-18 15:12:04 +00:00
Daniel Shahaf
6a634fac9f widget binding: Properly escape widget names at definition.
Re-Fixes zsh-users/zsh-syntax-highlighting#278.
2016-03-18 14:53:53 +00:00
Daniel Shahaf
47a664447c noop: Remove stray statement terminators and line joiners. 2016-03-18 14:47:53 +00:00