2013-06-12 23:40:20 +02:00
|
|
|
;; Python
|
|
|
|
|
2017-05-08 11:51:23 +02:00
|
|
|
(defun python-set-compiler ()
|
|
|
|
"Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
|
|
|
|
(let* ((firstline
|
2017-05-24 00:27:02 +02:00
|
|
|
(save-excursion (goto-char (point-min)) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
|
2017-05-08 11:51:23 +02:00
|
|
|
(interpreter
|
|
|
|
(if (not (string-match "^#!" firstline))
|
|
|
|
python-shell-interpreter
|
|
|
|
(substring firstline 2))))
|
2017-05-12 08:34:17 +02:00
|
|
|
(setq compile-command
|
2017-05-08 11:51:23 +02:00
|
|
|
(concat interpreter " " (shell-quote-argument buffer-file-name)))))
|
2013-07-03 20:14:06 +02:00
|
|
|
|
2017-05-28 12:03:28 +02:00
|
|
|
(add-hook-and-eval 'python-mode-hook 'python-set-compiler)
|
2013-06-12 23:40:20 +02:00
|
|
|
|
|
|
|
;; Doc lookup. Requires the python.info file to be installed. See
|
|
|
|
;; https://bitbucket.org/jonwaltman/pydoc-info/.
|
2014-02-12 17:37:43 +01:00
|
|
|
;; (add-to-list 'load-path "~/path/to/pydoc-info")
|
|
|
|
;; (require 'pydoc-info nil t)
|
2014-02-12 17:48:29 +01:00
|
|
|
|
2014-02-26 18:22:47 +01:00
|
|
|
(provide 'mode-python)
|