Change the Emacs “send code to interpreter” C-c C-r command in IPython-mode

后端 未结 3 1561
迷失自我
迷失自我 2021-01-03 06:48

The question here is related (but NOT identical) and complementary to Change the "send code to interpreter" (C-c |) command in python-mode .

I work on a M

3条回答
  •  北海茫月
    2021-01-03 06:57

    i did some hacking and here is what i have: by reading the code you should be able to tell how it works.

    (defun block-line-end ()
        (setq indentation (current-indentation))
        (forward-line)
        (while (> (current-indentation) indentation)
          (forward-line))
        (forward-line -1)
        (line-end-position))  
    (defun my-python-shell-send-region (&optional beg end)
        (interactive)
        (let ((beg (cond (beg beg)
                    ((region-active-p) (region-beginning))
                    (t (line-beginning-position))))
              (end (cond (end end)
                    ((region-active-p) 
                     (copy-marker (region-end)))
                    (t (block-line-end)))))
          (python-shell-send-region beg end))
        (forward-line))
    

提交回复
热议问题