emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matthew Palermo <matt.r.palermo@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Skipping the SUBTREE visibility state
Date: Fri, 5 Oct 2018 18:29:13 +1000	[thread overview]
Message-ID: <CAAg=FEU6smmuBu-n0B8gLHSd4CsrOhpUapxsGCxjsWhzAmUCxg@mail.gmail.com> (raw)

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

             reply	other threads:[~2018-10-05  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05  8:29 Matthew Palermo [this message]
2018-10-06  7:01 ` Skipping the SUBTREE visibility state Nicolas Goaziou
2018-10-07 22:28   ` Matthew Palermo
2018-10-12  0:48     ` Adrian Bradd

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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='CAAg=FEU6smmuBu-n0B8gLHSd4CsrOhpUapxsGCxjsWhzAmUCxg@mail.gmail.com' \
    --to=matt.r.palermo@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

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