diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-04-28 22:02:17 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-04-28 22:02:17 -0400 |
commit | f092b2ee5d5c1126f940c34ed29100b9eb5be9ee (patch) | |
tree | 1815f75793455a7d6a89a2935acf388e4bb5bf3c /lisp | |
parent | 5ed27ff91798a79b6b8ac4e254718c780d0b7b43 (diff) | |
download | emacs.d-f092b2ee5d5c1126f940c34ed29100b9eb5be9ee.tar.gz |
Add python-shell-send-set-string command
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-python.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/init-python.el b/lisp/init-python.el index da647ef..93a06f9 100644 --- a/lisp/init-python.el +++ b/lisp/init-python.el @@ -96,6 +96,19 @@ This is inspired by `ess-eval-function-or-paragraph-and-step'." (goto-char pos) n)) +(defvar km/python-shell-current-string nil) +(defun km/python-shell-send-set-string (set) + "Send previously set string to Python shell. +If a string has not been set previously or SET is non-nil, prompt +for a new string." + (interactive "P") + (when (or set (not km/python-shell-current-string)) + (let ((initial (and (use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))))) + (setq km/python-shell-current-string (read-string "Python command: " initial)))) + (python-shell-send-string km/python-shell-current-string)) + (defun km/python-indent-post-self-insert-function () "Adjust indentation after insert of specfic characters. This is taken from `python-indent-post-self-insert-function'. @@ -129,6 +142,8 @@ being turned on." (define-key python-mode-map (kbd "C-c C-c") 'km/python-shell-send-function-or-paragraph-and-step) + (define-key python-mode-map (kbd "C-c C-d") 'km/python-shell-send-set-string) + ;; Swap `python-shell-send-defun' and `python-eldoc-at-point'. (define-key python-mode-map (kbd "C-c C-f") 'python-shell-send-defun) (define-key python-mode-map (kbd "C-M-x") 'python-eldoc-at-point) |