* org-check-for-hidden breaks promote/demote in region
@ 2010-05-06 15:05 Matt Lundin
2010-05-07 7:15 ` Carsten Dominik
0 siblings, 1 reply; 2+ messages in thread
From: Matt Lundin @ 2010-05-06 15:05 UTC (permalink / raw
To: Org Mode
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/l2me4f0b2511004191529s16b84452kb4feea51f06353d4@mail.gmail.com
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: org-check-for-hidden breaks promote/demote in region
2010-05-06 15:05 org-check-for-hidden breaks promote/demote in region Matt Lundin
@ 2010-05-07 7:15 ` Carsten Dominik
0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2010-05-07 7:15 UTC (permalink / raw
To: Matt Lundin; +Cc: Org Mode
Hi Matt,
I agree and have applied your patch, thanks.
- Carsten
On May 6, 2010, at 5:05 PM, Matt Lundin wrote:
> 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/l2me4f0b2511004191529s16b84452kb4feea51f06353d4@mail.gmail.com
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
- Carsten
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-07 7:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-06 15:05 org-check-for-hidden breaks promote/demote in region Matt Lundin
2010-05-07 7:15 ` Carsten Dominik
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.