2017-10-08 20:36:28 +02:00
|
|
|
;;; Python
|
2013-06-12 23:40:20 +02:00
|
|
|
|
2018-02-15 13:28:49 +01:00
|
|
|
(defun ambrevar/python-set-compiler ()
|
2017-05-08 11:51:23 +02:00
|
|
|
"Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
|
2017-06-04 13:16:31 +02:00
|
|
|
(when buffer-file-name
|
|
|
|
(let* ((firstline
|
|
|
|
(save-excursion (goto-char (point-min)) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
|
|
|
|
(interpreter
|
|
|
|
(if (not (string-match "^#!" firstline))
|
|
|
|
python-shell-interpreter
|
|
|
|
(substring firstline 2))))
|
|
|
|
(setq compile-command
|
|
|
|
(concat interpreter " " (shell-quote-argument buffer-file-name))))))
|
2013-07-03 20:14:06 +02:00
|
|
|
|
2018-02-15 13:28:49 +01:00
|
|
|
(add-hook 'python-mode-hook 'ambrevar/python-set-compiler)
|
2013-06-12 23:40:20 +02:00
|
|
|
|
2017-10-08 20:36:28 +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
|
|
|
|
2017-06-18 18:50:31 +02:00
|
|
|
(provide 'init-python)
|