Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
Hinterland
==========

Enable code autocompletion menu for every keypress in a code cell, instead of only enabling it with tab.
Enable code autocompletion menu for every keypress in a code cell, instead of
only calling it with tab.

The nbextension adds an item to the help menu to turn auto-hinting on and off,
and offers some options for configuration:


Options
=======

* `hinterland.hint_delay`:
delay in milliseconds between keypress & hint request. This is used to help
ensure that the character from the keypress is added to the CodeMirror editor
*before* the hint request checks the character preceding the cursor against
the regexes below.

* `hinterland.enable_at_start`:
Whether to enable hinterland's continuous hinting when notebook is first
opened, or if false, only when selected from the help-menu item.

* `hinterland.hint_inside_comments`:
Whether to request hints while typing code comments. Defaults to false.

* `hinterland.exclude_regexp`:
A regular expression tested against the character before the cursor, which,
if a match occurs, prevents autocompletion from being triggered. This is
useful, for example, to prevent triggering autocomplete on a colon, which is
included by the default Completer.reinvoke pattern. If blank, no test is
performed. Note that the regex will be created without any flags, making it
case sensitive.

* `hinterland.include_regexp`:
A regular expression tested against the character before the cursor, which
must match in order for autocompletion to be triggered. If left blank, the
value of the notebook's `Completer.reinvoke_re` parameter is used, which can
be modified by kernels, but defaults to `/[%0-9a-z._/\\:~-]/i`. Note that
although the `Completer.reinvoke_re` default is case insensitive by virtue of
its `/i` flag, any regex specified by the user will be created without any
flags, making it case sensitive.

* `hinterland.tooltip_regexp`:
A regular expression tested against the character before the cursor, which if
it matches, causes a tooltip to be triggered, instead of regular
autocompletion. For python, this is useful for example for function calls, so
the default regex matches opening parentheses. Note that the regex will be
created without any flags, making it case sensitive.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ define(function (require, exports, module) {
exclude_regexp: ':',
include_regexp: '',
tooltip_regexp: '\\(',
hint_delay: 20,
hint_inside_comments: false,
};
// flag denoting whether hinting is enabled
var do_hinting;
Expand Down Expand Up @@ -96,6 +98,7 @@ define(function (require, exports, module) {
ch: cur.ch - 1
}, cur);
if ( pre_cursor !== '' &&
(config.hint_inside_comments || editor.getTokenAt(cur).type !== "comment") &&
(config.include_regexp.test(pre_cursor) || config.tooltip_regexp.test(pre_cursor)) &&
!config.exclude_regexp.test(pre_cursor) ) {
if (config.tooltip_regexp.test(pre_cursor)) {
Expand All @@ -106,7 +109,7 @@ define(function (require, exports, module) {
cell.completer.autopick = false;
}
}
}, 200);
}, config.hint_delay);
}
}
return orig_handle_codemirror_keyevent.apply(this, arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@ Description: |
only enabling it with tab
Compatibility: 4.x
Parameters:
- name: hinterland.hint_delay
description: |
delay in milliseconds between keypress & hint request. This is used to help
ensure that the character from the keypress is added to the CodeMirror
editor *before* the hint request checks the character preceding the cursor
against the regexes below.
input_type: number
min: 1
step: 1
default: 20
- name: hinterland.enable_at_start
description: |
Enable hinterland's continuous hinting when notebook is first opened
Enable hinterland's continuous hinting when notebook is first opened, or
if false, only when selected from the help-menu item.
input_type: checkbox
default: true
- name: hinterland.hint_inside_comments
description: |
Whether to request hints while typing code comments.
input_type: checkbox
default: false
- name: hinterland.exclude_regexp
description: |
exclude_regexp:
Expand Down