emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Skipping the SUBTREE visibility state
@ 2018-10-05  8:29 Matthew Palermo
  2018-10-06  7:01 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Palermo @ 2018-10-05  8:29 UTC (permalink / raw)
  To: emacs-orgmode

Hi Org mode list,

I find it really distracting when a large SUBTREE is expanded while
browsing through an Org document. Does anyone else find this
problematic or am I doing something wrong?

Today I explored some ways to avoid this problem and came up with a
patch to the ~org-cycle~ function to allow skipping the SUBTREE state.
I have included the patch to ~org.el~ inline below. This patch makes a
minimal modification to ~org-cycle~, defines a new command
~org-cycle-skip-subtree~ and binds it to C-Tab (overwriting the
original binding). I'd like to hear your feedback.

Thanks. Btw, I'm new to this sending patches via mailing list so
please let me know if I've done something wrong.

diff -u "c:/Users/Matthew Palermo/AppData/Roaming/.emacs.d/org.el"
"c:/Users/Matthew Palermo/AppData/Roaming/.emacs.d/org-skip.el"
--- "c:/Users/Matthew Palermo/AppData/Roaming/.emacs.d/org.el"
2018-04-24 00:17:49.000000000 +1000
+++ "c:/Users/Matthew Palermo/AppData/Roaming/.emacs.d/org-skip.el"
2018-10-05 17:10:33.347064600 +1000
@@ -6677,7 +6677,7 @@
     (apply 'message args)))

 ;;;###autoload
-(defun org-cycle (&optional arg)
+(defun org-cycle (&optional arg skipsubtree)
   "TAB-action and visibility cycling for Org mode.

 This is the command invoked in Org mode by the `TAB' key.  Its main
@@ -6817,7 +6817,7 @@
          (save-excursion (move-beginning-of-line 1)
                  (looking-at org-outline-regexp)))
          (or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
-    (org-cycle-internal-local))
+    (org-cycle-internal-local skipsubtree))

        ;; From there: TAB emulation and template completion.
        (buffer-read-only (org-back-to-heading))
@@ -6849,6 +6849,11 @@
         (org-back-to-heading)
         (org-cycle)))))))

+(defun org-cycle-skip-subtree ()
+  "Calls `org-cycle' except it skips the SUBTREE state"
+  (interactive)
+  (org-cycle nil t))
+
 (defun org-cycle-internal-global ()
   "Do the global cycling action."
   ;; Hack to avoid display of messages for .org  attachments in Gnus
@@ -6890,7 +6895,7 @@
 If POS is nil, use `point' instead."
   (get-char-property (or pos (point)) 'invisible))

-(defun org-cycle-internal-local ()
+(defun org-cycle-internal-local (&optional skipsubtree)
   "Do the local cycling action."
   (let ((goal-column 0) eoh eol eos has-children children-skipped struct)
     ;; First, determine end of headline (EOH), end of subtree or item
@@ -6936,7 +6941,7 @@
     (when (org-invisible-p) (org-flag-heading nil))))
      ((and (or (>= eol eos)
            (not (string-match "\\S-" (buffer-substring eol eos))))
-       (or has-children
+       (or has-children skipsubtree
            (not (setq children-skipped
               org-cycle-skip-children-state-if-no-children))))
       ;; Entire subtree is hidden in one line: children view
@@ -6972,9 +6977,10 @@
       (setq org-cycle-subtree-status 'children)
       (unless (org-before-first-heading-p)
     (run-hook-with-args 'org-cycle-hook 'children)))
-     ((or children-skipped
-      (and (eq last-command this-command)
-           (eq org-cycle-subtree-status 'children)))
+     ((and (not skipsubtree)
+       (or children-skipped
+           (and (eq last-command this-command)
+            (eq org-cycle-subtree-status 'children))))
       ;; We just showed the children, or no children are there,
       ;; now show everything.
       (unless (org-before-first-heading-p)
@@ -19508,6 +19514,7 @@
 (org-defkey org-mode-map "\C-i"       'org-cycle)
 (org-defkey org-mode-map [(tab)]      'org-cycle)
 (org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
+(org-defkey org-mode-map [(control tab)] 'org-cycle-skip-subtree)
 (org-defkey org-mode-map "\M-\t" #'pcomplete)

 ;; The following line is necessary under Suse GNU/Linux

Diff finished.  Fri Oct  5 18:08:00 2018

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Skipping the SUBTREE visibility state
  2018-10-05  8:29 Skipping the SUBTREE visibility state Matthew Palermo
@ 2018-10-06  7:01 ` Nicolas Goaziou
  2018-10-07 22:28   ` Matthew Palermo
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2018-10-06  7:01 UTC (permalink / raw)
  To: Matthew Palermo; +Cc: emacs-orgmode

Matthew Palermo <matt.r.palermo@gmail.com> writes:

> Hi Org mode list,
>
> I find it really distracting when a large SUBTREE is expanded while
> browsing through an Org document. Does anyone else find this
> problematic or am I doing something wrong?

I'm not sure to understand the problem you want to solve. Could you
expound it a bit?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Skipping the SUBTREE visibility state
  2018-10-06  7:01 ` Nicolas Goaziou
@ 2018-10-07 22:28   ` Matthew Palermo
  2018-10-12  0:48     ` Adrian Bradd
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Palermo @ 2018-10-07 22:28 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

Hi Nicolas,

Thankyou for your reply. Sorry I didn't explain myself properly. When using
org-cycle (TAB) I often only want to open  an entry (headline) to its
CHILDREN visibility state, look at the subheadings (sub-entry headlines),
and then fold it back into its FOLDED state. Often these sub-entries will
have an appreciable amount of contents in them. So to go from the CHILDREN
state to the FOLDED state I have to press TAB twice which causes a large
amount of content to appear momentarily on screen. This experience is
unpleasant and distracting, so much so that I am actively trying to find a
way to simply org-cycle straight from the CHILDREN state to the FOLDED
state. My patch demonstrates one possible way of realising this.

Cheers,
Matthew Palermo

On Sat., 6 Oct. 2018, 5:01 pm Nicolas Goaziou, <mail@nicolasgoaziou.fr>
wrote:

> Matthew Palermo <matt.r.palermo@gmail.com> writes:
>
> > Hi Org mode list,
> >
> > I find it really distracting when a large SUBTREE is expanded while
> > browsing through an Org document. Does anyone else find this
> > problematic or am I doing something wrong?
>
> I'm not sure to understand the problem you want to solve. Could you
> expound it a bit?
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #2: Type: text/html, Size: 1786 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Skipping the SUBTREE visibility state
  2018-10-07 22:28   ` Matthew Palermo
@ 2018-10-12  0:48     ` Adrian Bradd
  0 siblings, 0 replies; 4+ messages in thread
From: Adrian Bradd @ 2018-10-12  0:48 UTC (permalink / raw)
  To: Matthew Palermo; +Cc: emacs-orgmode


Hello,

Matthew Palermo <matt.r.palermo@gmail.com> writes:

> Thankyou for your reply. Sorry I didn't explain myself 
> properly. When using
> org-cycle (TAB) I often only want to open  an entry (headline) 
> to its
> CHILDREN visibility state, look at the subheadings (sub-entry 
> headlines),
> and then fold it back into its FOLDED state. 

You can use C-c TAB (`org-ctrl-c-tab) to unfold CHILDREN of the 
current heading and then TAB to fold them again. Actually C-c TAB 
takes a numeric argument N that allows you to unfold to the Nth 
level of the subtree and TAB will still fold the entire subtree 
instead of further expanding.

I use this with org-datetree formatted buffers when I want to view 
headings from all days in a month.

Cheers,

-- 
Adrian Bradd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-12  0:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05  8:29 Skipping the SUBTREE visibility state Matthew Palermo
2018-10-06  7:01 ` Nicolas Goaziou
2018-10-07 22:28   ` Matthew Palermo
2018-10-12  0:48     ` Adrian Bradd

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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