ambevar-dotfiles/.emacs.d/lisp/mode-python.el

26 lines
909 B
EmacsLisp
Raw Normal View History

2013-06-12 23:40:20 +02:00
;; Python
(defun python-set-compiler ()
"Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
(let* ((firstline
(save-excursion (beginning-of-buffer) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(interpreter
(if (not (string-match "^#!" firstline))
python-shell-interpreter
(substring firstline 2))))
(set (make-local-variable 'compile-command)
(concat interpreter " " (shell-quote-argument buffer-file-name)))))
2014-02-26 18:22:47 +01:00
(add-hook-and-eval
2013-06-12 23:40:20 +02:00
'python-mode-hook
(lambda ()
(set (make-local-variable 'compilation-scroll-output) t)
(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)