From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Sexton Subject: Make M-up and M-down transpose paragraphs in org buffers Date: Tue, 21 Jun 2011 23:08:46 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZA4B-0003Ei-5L for emacs-orgmode@gnu.org; Tue, 21 Jun 2011 19:09:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZA4A-0003OC-B3 for emacs-orgmode@gnu.org; Tue, 21 Jun 2011 19:09:07 -0400 Received: from lo.gmane.org ([80.91.229.12]:57265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZA4A-0003O4-5g for emacs-orgmode@gnu.org; Tue, 21 Jun 2011 19:09:06 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QZA43-0005cg-72 for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 01:09:04 +0200 Received: from rp.young.med.auckland.ac.nz ([130.216.140.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Jun 2011 01:08:59 +0200 Received: from psexton by rp.young.med.auckland.ac.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Jun 2011 01:08:59 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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) (interactive) (when (and (not (or (org-at-table-p) (org-on-heading-p) (org-at-item-p))) (thing-at-point 'sentence)) (transpose-paragraphs arg) (backward-paragraph) (re-search-forward "[[:graph:]]") (goto-char (match-beginning 0)) t)) (add-to-list 'org-metaup-hook (lambda () (interactive) (org-transpose-paragraphs -1))) (add-to-list 'org-metadown-hook (lambda () (interactive) (org-transpose-paragraphs 1)))