Function: python-shell-completion-native-setup
python-shell-completion-native-setup is a byte-compiled function
defined in python.el.gz.
Signature
(python-shell-completion-native-setup)
Documentation
Try to setup native completion, return non-nil on success.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-completion-native-setup ()
"Try to setup native completion, return non-nil on success."
(let* ((process (python-shell-get-process))
(output (python-shell-send-string-no-output "
def __PYTHON_EL_native_completion_setup():
try:
import readline
__PYTHON_EL_wrap_completer()
# Ensure that rlcompleter.__main__ and __main__ are identical.
# (Bug#76205)
import sys
try:
__IPYTHON__
sys.modules['rlcompleter'].__main__ = sys.modules['__main__']
except (NameError, KeyError):
pass
if readline.__doc__ and 'libedit' in readline.__doc__:
raise Exception('''libedit based readline is known not to work,
see etc/PROBLEMS under \"In Inferior Python mode, input is echoed\".''')
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
# Require just one tab to send output.
readline.parse_and_bind('set show-all-if-ambiguous on')
# Avoid ANSI escape characters in the output
readline.parse_and_bind('set colored-completion-prefix off')
readline.parse_and_bind('set colored-stats off')
# Avoid replacing common prefix with ellipsis.
readline.parse_and_bind('set completion-prefix-display-length 0')
print ('python.el: native completion setup loaded')
except:
import sys
print ('python.el: native completion setup failed, %s: %s'
% sys.exc_info()[:2])
__PYTHON_EL_native_completion_setup()" process)))
(when (string-match-p "python\\.el: native completion setup loaded"
output)
(python-shell-completion-native-try))))