unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* forward/backward-sentence in programming modes
@ 2014-12-05 22:44 Marcin Borkowski
  0 siblings, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2014-12-05 22:44 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi there,

does M-a/M-e do anything useful in programming-language modes?  I did a
quick check in elisp mode, and it seems that they are more or less
useless there.  (Apparently, they just stop at a string of more than one
newline.)  I'm wondering whether this is a good behavior.  Maybe they
should be equivalent to forward/backward-sexp?  But what about, say,
Python or C mode or other ones?  Any ideas?

Regards,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: forward/backward-sentence in programming modes
       [not found] <mailman.15351.1417819507.1147.help-gnu-emacs@gnu.org>
@ 2014-12-05 22:59 ` Raffaele Ricciardi
  2014-12-06 17:20 ` Raffaele Ricciardi
  1 sibling, 0 replies; 3+ messages in thread
From: Raffaele Ricciardi @ 2014-12-05 22:59 UTC (permalink / raw)
  To: help-gnu-emacs

On 05/12/14 23:44, Marcin Borkowski wrote:
> Hi there,
>
> does M-a/M-e do anything useful in programming-language modes?

More or less, they  work as expected in strings and comments.  Maybe 
they could be improved by tweaking some settings, but I have never 
looked into it.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: forward/backward-sentence in programming modes
       [not found] <mailman.15351.1417819507.1147.help-gnu-emacs@gnu.org>
  2014-12-05 22:59 ` forward/backward-sentence in programming modes Raffaele Ricciardi
@ 2014-12-06 17:20 ` Raffaele Ricciardi
  1 sibling, 0 replies; 3+ messages in thread
From: Raffaele Ricciardi @ 2014-12-06 17:20 UTC (permalink / raw)
  To: help-gnu-emacs

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).


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-06 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.15351.1417819507.1147.help-gnu-emacs@gnu.org>
2014-12-05 22:59 ` forward/backward-sentence in programming modes Raffaele Ricciardi
2014-12-06 17:20 ` Raffaele Ricciardi
2014-12-05 22:44 Marcin Borkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).