emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Skipping the SUBTREE visibility state


From: Matthew Palermo
Subject: [O] Skipping the SUBTREE visibility state
Date: Fri, 5 Oct 2018 18:29:13 +1000

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 via email to

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