[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: forward/backward-sentence in programming modes
From: |
Raffaele Ricciardi |
Subject: |
Re: forward/backward-sentence in programming modes |
Date: |
Sat, 06 Dec 2014 18:20:30 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
On 05/12/14 23:44, Marcin Borkowski wrote:
But what about, say,
Python or C mode or other ones?
In Python Mode (from "python.el"):
- M-a runs the command python-nav-backward-block
- M-e runs the command python-nav-forward-block
- M-k runs the command kill-sentence
For consistency, M-k could kill to the end of block, instead. Here is
an idea:
--
(defun point-after/rr ($movement-command &rest $args)
"Return what the value of point would be after executing
$MOVEMENT-COMMAND
with $ARGS."
(save-excursion
(apply $movement-command $args)
(point)))
(defun python-kill-block/rr (&optional $arg)
"Kill from point to end of Python block. It doesn't fix indentation.
With $ARG, repeat. With negative argument, kill $ARG times
backward to previous Python block."
(interactive "p")
(or $arg (setq $arg 1))
(kill-region (point)
(point-after/rr #'python-nav-forward-block $arg)))
(define-key python-mode-map (kbd "M-k") #'python-kill-block/rr)
--
> Any ideas?
Context-sensitive versions of M-a and M-e could deal with sentences when
in comments or strings, and do something else in code (like Python Mode
does).