From f092b2ee5d5c1126f940c34ed29100b9eb5be9ee Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 28 Apr 2015 22:02:17 -0400 Subject: Add python-shell-send-set-string command --- lisp/init-python.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lisp') 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) -- cgit v1.2.3