emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Paul Sexton <psexton@xnet.co.nz>
To: emacs-orgmode@gnu.org
Subject: Make M-up and M-down transpose paragraphs in org buffers
Date: Tue, 21 Jun 2011 23:08:46 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110622T010528-283@post.gmane.org> (raw)

By default, if used within ordinary paragraphs in org mode, M-up and M-down 
transpose *lines* (not sentences). This was not useful to me. The following 
code makes these keys transpose paragraphs, keeping the point at the start
of the moved paragraph. Behaviour in tables and headings is unaffected. It
would be easy to modify this to transpose sentences.

(defun org-transpose-paragraphs (arg)
  (when (and (not (or (org-at-table-p) (org-on-heading-p) (org-at-item-p)))
             (thing-at-point 'sentence))
    (transpose-paragraphs arg)
    (re-search-forward "[[:graph:]]")
    (goto-char (match-beginning 0))

(add-to-list 'org-metaup-hook 
  (lambda () (interactive) (org-transpose-paragraphs -1)))
(add-to-list 'org-metadown-hook 
  (lambda () (interactive) (org-transpose-paragraphs 1)))

             reply	other threads:[~2011-06-21 23:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 23:08 Paul Sexton [this message]
2011-06-28 17:14 ` Make M-up and M-down transpose paragraphs in org buffers Bastien
2011-06-28 18:44   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20110622T010528-283@post.gmane.org \
    --to=psexton@xnet.co.nz \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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