From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Raffaele Ricciardi Newsgroups: gmane.emacs.help Subject: Re: forward/backward-sentence in programming modes Date: Sat, 06 Dec 2014 18:20:30 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1417886726 29401 80.91.229.3 (6 Dec 2014 17:25:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Dec 2014 17:25:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 06 18:25:20 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XxJ6d-0001gu-Rn for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2014 18:25:19 +0100 Original-Received: from localhost ([::1]:55077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxJ6d-0000mC-9s for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2014 12:25:19 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-X-Trace: individual.net WgO3Ogstc0Tpm7AC7BNqXgY51HeRm1GPO4UgEMjS8IhSXrdoDt Cancel-Lock: sha1:LpWwNK+Tw6deCF2sNqQZ7GEwdWM= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: Original-Xref: usenet.stanford.edu gnu.emacs.help:209174 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101449 Archived-At: 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).