emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] org-check-for-hidden breaks promote/demote in region


From: Matt Lundin
Subject: [Orgmode] org-check-for-hidden breaks promote/demote in region
Date: Thu, 06 May 2010 11:05:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi Carsten,

I find that commit 11baa7cf77245cc2a5f44dd55e034157896ad08d (which
changes the behavior of M-left and M-right) makes it impossible to
promote and demote headlines in a region.[1]

In the past, if I marked a region of folded headlines and used M-left or
M-right, org-mode would promote/demote all the headlines in the region.
Now, it simply throws the following error:

"Hidden subtree, open with TAB or use subtree command
M-S-<left>/<right>" 

The problem: When the region is active, M-S-<left>/<right> (as in the
past) only moves a single subtree, so AFAICT there is currently no way
to promote/demote all headings in a region.

While I appreciate the new safeguard for single outline headings, IMO
the check is irrelevant when attempting to act on headlines in a region,
since (1) the user chooses to move an entire region and (2) the hidden
headlines are normally included in the region.

Here's a patch that skips the check if the region is active:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index 0385383..463a0eb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16146,20 +16146,19 @@ this fucntion returns t, nil otherwise."
        beg end)
     (save-excursion
       (catch 'exit
-       (if (org-region-active-p)
-           (setq beg (region-beginning) end (region-end))
+       (unless (org-region-active-p)
          (setq beg (point-at-bol))
          (beginning-of-line 2)
          (while (and (not (eobp)) ;; this is like `next-line'
                      (get-char-property (1- (point)) 'invisible))
            (beginning-of-line 2))
-         (setq end (point)))
-       (goto-char beg)
-       (goto-char (point-at-eol))
-       (setq end (max end (point)))
-       (while (re-search-forward re end t)
-         (if (get-char-property (match-beginning 0) 'invisible)
-             (throw 'exit t)))
+         (setq end (point))
+         (goto-char beg)
+         (goto-char (point-at-eol))
+         (setq end (max end (point)))
+         (while (re-search-forward re end t)
+           (if (get-char-property (match-beginning 0) 'invisible)
+               (throw 'exit t))))
        nil))))
 
 (defun org-metaup (&optional arg)
--8<---------------cut here---------------end--------------->8---

Thanks,
Matt

Footnotes:

[1] The change was discussed in this thread: http://mid.gmane.org/address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]