;;;; Indentation.
(defcustom python-indent 4
- "*Number of columns for a unit of indentation in Python mode.
+ "Number of columns for a unit of indentation in Python mode.
See also `\\[python-guess-indent]'"
:group 'python
:type 'integer)
(defcustom python-guess-indent t
- "*Non-nil means Python mode guesses `python-indent' for the buffer."
+ "Non-nil means Python mode guesses `python-indent' for the buffer."
:type 'boolean
:group 'python)
(defcustom python-indent-string-contents t
- "*Non-nil means indent contents of multi-line strings together.
+ "Non-nil means indent contents of multi-line strings together.
This means indent them the same as the preceding non-blank line.
Otherwise preserve their indentation.
:group 'python)
(defcustom python-continuation-offset 4
- "*Number of columns of additional indentation for continuation lines.
+ "Number of columns of additional indentation for continuation lines.
Continuation lines follow a backslash-terminated line starting a
statement."
:group 'python
;;;; pychecker
(defcustom python-check-command "pychecker --stdlib"
- "*Command used to check a Python file."
+ "Command used to check a Python file."
:type 'string
:group 'python)
;; Fixme: Make sure we can work with IPython.
(defcustom python-python-command "python"
- "*Shell command to run Python interpreter.
+ "Shell command to run Python interpreter.
Any arguments can't contain whitespace.
Note that IPython may not work properly; it must at least be used
with the `-cl' flag, i.e. use `ipython -cl'."
:type 'string)
(defcustom python-jython-command "jython"
- "*Shell command to run Jython interpreter.
+ "Shell command to run Jython interpreter.
Any arguments can't contain whitespace."
:group 'python
:type 'string)
(compilation-shell-minor-mode 1))
(defcustom inferior-python-filter-regexp "\\`\\s-*\\S-?\\S-?\\s-*\\'"
- "*Input matching this regexp is not saved on the history list.
+ "Input matching this regexp is not saved on the history list.
Default ignores all inputs of 0, 1, or 2 non-blank characters."
:type 'regexp
:group 'python)
(setq python-buffer (current-buffer)))
(accept-process-output (get-buffer-process python-buffer) 5)
(inferior-python-mode)))
- (if (eq 'python-mode major-mode)
+ (if (derived-mode-p 'python-mode)
(setq python-buffer (default-value 'python-buffer))) ; buffer-local
;; Load function definitions we need.
;; Before the preoutput function was used, this was done via -c in
(python-switch-to-python t))
(defcustom python-source-modes '(python-mode jython-mode)
- "*Used to determine if a buffer contains Python source code.
+ "Used to determine if a buffer contains Python source code.
If a file is loaded into a buffer that is in one of these major modes,
it is considered Python source by `python-load-file', which uses the
value to determine defaults."
;; isn't one for `python-buffer'.
(unless (comint-check-proc python-buffer)
(run-python nil t))
- (get-buffer-process (or (if (eq major-mode 'inferior-python-mode)
- (current-buffer)
- python-buffer))))
+ (get-buffer-process (or (if (derived-mode-p 'inferior-python-mode)
+ (current-buffer)
+ python-buffer))))
(defun python-set-proc ()
"Set the default value of `python-buffer' to correspond to this buffer.
(defun python-try-complete (old)
"Completion function for Python for use with `hippie-expand'."
- (when (eq major-mode 'python-mode) ; though we only add it locally
+ (when (derived-mode-p 'python-mode) ; though we only add it locally
(unless old
(let ((symbol (python-partial-symbol)))
(he-init-string (- (point) (length symbol)) (point))
(if (featurep 'hippie-exp)
(set (make-local-variable 'hippie-expand-try-functions-list)
(cons 'python-try-complete hippie-expand-try-functions-list)))
+ ;; Python defines TABs as being 8-char wide.
+ (set (make-local-variable 'tab-width) 8)
(when python-guess-indent (python-guess-indent))
+ ;; Let's make it harder for the user to shoot himself in the foot.
+ (unless (= tab-width python-indent)
+ (setq indent-tabs-mode nil))
(set (make-local-variable 'python-command) python-python-command)
(python-find-imports)
(unless (boundp 'python-mode-running) ; kill the recursion from jython-mode
(custom-add-option 'python-mode-hook 'imenu-add-menubar-index)
(custom-add-option 'python-mode-hook
- '(lambda ()
- "Turn off Indent Tabs mode."
- (set (make-local-variable 'indent-tabs-mode) nil)))
+ (lambda ()
+ "Turn off Indent Tabs mode."
+ (set (make-local-variable 'indent-tabs-mode) nil)))
(custom-add-option 'python-mode-hook 'turn-on-eldoc-mode)
(custom-add-option 'python-mode-hook 'abbrev-mode)
(custom-add-option 'python-mode-hook 'python-setup-brm)