emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anthony Lander <anthony@landerfamily.ca>
To: Trevor Vartanoff <tv@codepuzzles.org>
Cc: emacs-orgmode Mode <emacs-orgmode@gnu.org>
Subject: Re: org-metaup / org-metadown nerfed in 7.9.1
Date: Wed, 19 Sep 2012 10:50:33 -0400	[thread overview]
Message-ID: <1B3F071B-9000-46B1-9896-3BA11A885100@landerfamily.ca> (raw)
In-Reply-To: <5059DA33.3030109@codepuzzles.org>

Hi Trevor,

On 12-Sep-19, at 10:44 AM, Trevor Vartanoff wrote:

> And so, example 2, I was receiving "cannot drag element forward/backward" when I was in a heading with no line breaks. That is, a heading where paragraphs are separated with return + indent rather than a full line break of return + return.

I use the M-up/dn behaviour a lot to move property lines up and down. I added some hooks to restore that functionality since property lines aren't recognized as elements. Here's the code. You might be able to adapt it to do what you want.

Hope it helps,


; Fix M-<up> and M-<down> to move individual lines inside a property drawer
(add-hook 'org-metaup-hook 'my-org-metaup-hook)
(defun my-org-metaup-hook ()
  "When on a property line, use M-<up> to move the line up"
  (when (org-region-active-p) (return nil))

  (let ((element (car (org-element-at-point))))
    (if (eq element 'property-drawer)
        (let* ((position (- (point) (line-beginning-position)))
               (a (save-excursion (move-beginning-of-line 1) (point)))
               (b (save-excursion (move-end-of-line 1) (point)))
               (c (save-excursion (goto-char a)
                                  (move-beginning-of-line 0)))
               (d (save-excursion (goto-char a)
                                  (move-end-of-line 0) (point))))
          (transpose-regions a b c d)
          (goto-char c)
          (forward-char position)

(add-hook 'org-metadown-hook 'my-org-metadown-hook)
(defun my-org-metadown-hook ()
  "When on a property line, use M-<down> to move the line down"
  (when (org-region-active-p) (return nil))

  (let ((element (car (org-element-at-point))))
    (if (eq element 'property-drawer)
        (let* ((position (- (point) (line-beginning-position)))
               (at-end-of-line (eq (point) (line-end-position)))
               (a (save-excursion (move-beginning-of-line 1)))
               (b (save-excursion (move-end-of-line 1) (point)))
               (c (save-excursion (next-line)
                                  (move-beginning-of-line 1)))
               (d (save-excursion (next-line)
                                  (move-end-of-line 1) (point))))
          (transpose-regions a b c d)
          (move-beginning-of-line 1)
          (if at-end-of-line            ; Strange boundary condition at end of line
                (next-line)             ; Goes to wrong place. So instead just
                (move-end-of-line 1))   ; go to end of line.
              (forward-char position))

  reply	other threads:[~2012-09-19 14:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 14:44 org-metaup / org-metadown nerfed in 7.9.1 Trevor Vartanoff
2012-09-19 14:50 ` Anthony Lander [this message]
2012-09-22  9:24   ` Bastien
2012-09-23  8:25     ` Nicolas Goaziou
2012-09-23  9:39       ` Bastien
2012-09-23 10:03       ` Carsten Dominik
2012-09-23 17:39         ` Nicolas Goaziou
2012-09-23 18:05           ` Bastien
2012-09-23 19:51     ` Anthony Lander
2012-09-23  8:20 ` Nicolas Goaziou
  -- strict thread matches above, loose matches on Subject: below --
2012-09-27  2:09 Trevor Vartanoff
2012-09-26 23:18 Trevor Vartanoff
2012-09-27  1:49 ` Jonathan Leech-Pepin
2012-09-27  8:18 ` Bastien
2012-09-20 14:29 Trevor Vartanoff
2012-09-18 15:50 Trevor Vartanoff
2012-09-19  6:43 ` Bastien

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=1B3F071B-9000-46B1-9896-3BA11A885100@landerfamily.ca \
    --to=anthony@landerfamily.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=tv@codepuzzles.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).