init-python.el 866 B

1234567891011121314151617181920212223
  1. ;;; Python
  2. (defun ambrevar/python-set-compiler ()
  3. "Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
  4. (when buffer-file-name
  5. (let* ((firstline
  6. (save-excursion (goto-char (point-min)) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
  7. (interpreter
  8. (if (not (string-match "^#!" firstline))
  9. python-shell-interpreter
  10. (substring firstline 2))))
  11. (setq compile-command
  12. (concat interpreter " " (shell-quote-argument buffer-file-name))))))
  13. (add-hook 'python-mode-hook 'ambrevar/python-set-compiler)
  14. ;;; Doc lookup. Requires the python.info file to be installed. See
  15. ;;; https://bitbucket.org/jonwaltman/pydoc-info/.
  16. ;; (add-to-list 'load-path "~/path/to/pydoc-info")
  17. ;; (require 'pydoc-info nil t)
  18. (provide 'init-python)