emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [RFC] Extend+slight change to C-c C-k and C-c TAB
@ 2019-07-11 13:03 Marco Wahl
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Wahl @ 2019-07-11 13:03 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi all,

For some time I use the realizations of C-c C-k
(`org-kill-note-or-show-branches') and C-c TAB (`org-ctrl-c-tab') as
found in the patches below.

With the patch the keys apply also above the first headline opposed to
the former version.  In this case the whole file is treated as the
subtree to act on.

This moves Org a tiny bit into the direction to treat Org files as
subtrees.  IIRC Gustav once pointed out that it might be a good idea to
regard Org files as Org subtrees.

Further with the patch the behavior of C-c TAB is slightly different
since it folds every unfolded subtree opposed to the previous version.

Of course I'm all for this change.

Is this worth to go into orgmode?  What do you think?


Ciao,
-- 
Marco


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-function-to-flag-region-above-first-heading.patch --]
[-- Type: text/x-patch, Size: 1069 bytes --]

From add2614cf95d7ab569c95521747ec80f5eca2225 Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Thu, 11 Jul 2019 12:08:47 +0200
Subject: [PATCH 1/4] Add function to flag region above first heading

* lisp/org.el (org-flag-above-first-heading): New function.
---
 lisp/org.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 5d6cc757d..3326aa542 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17908,6 +17908,15 @@ Use `\\[org-edit-special]' to edit table.el tables"))
     (org-reset-file-cache))
   (message "%s restarted" major-mode))
 
+(defun org-flag-above-first-heading (&optional arg)
+  "Hide from bob up to the first heading.
+Move point to the beginning of first heading or end of buffer."
+  (goto-char (point-min))
+  (unless (org-at-heading-p)
+    (outline-next-heading))
+  (unless (bobp)
+    (org-flag-region 1 (1- (point)) (not arg) 'outline)))
+
 (defun org-kill-note-or-show-branches ()
   "Abort storing current note, or call `outline-show-branches'."
   (interactive)
-- 
2.22.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Add-function-to-show-just-every-headline-in-buffer.patch --]
[-- Type: text/x-patch, Size: 1050 bytes --]

From ee4fcc2aaa54d81fe3d5c49f203c41f13589b43f Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Thu, 11 Jul 2019 12:12:37 +0200
Subject: [PATCH 2/4] Add function to show just every headline in buffer

* lisp/org.el (org-show-branches-buffer): New function.
---
 lisp/org.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 3326aa542..e6117dcdf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17917,6 +17917,16 @@ Move point to the beginning of first heading or end of buffer."
   (unless (bobp)
     (org-flag-region 1 (1- (point)) (not arg) 'outline)))
 
+(defun org-show-branches-buffer ()
+  "Show all branches in the buffer."
+  (org-flag-above-first-heading)
+  (outline-hide-sublevels 1)
+  (unless (eobp)
+    (outline-show-branches)
+    (while (outline-get-next-sibling)
+      (outline-show-branches)))
+  (goto-char (point-min)))
+
 (defun org-kill-note-or-show-branches ()
   "Abort storing current note, or call `outline-show-branches'."
   (interactive)
-- 
2.22.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Make-show-branches-applicable-to-whole-file.patch --]
[-- Type: text/x-patch, Size: 1457 bytes --]

From 3e76a9fc447f0c6e6f7f53f4808590354ea6d63d Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Thu, 11 Jul 2019 12:16:35 +0200
Subject: [PATCH 3/4] Make show-branches applicable to whole file

* lisp/org.el (org-kill-note-or-show-branches): Extend and refactor.
---
 lisp/org.el | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e6117dcdf..fecfc451c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17928,17 +17928,15 @@ Move point to the beginning of first heading or end of buffer."
   (goto-char (point-min)))
 
 (defun org-kill-note-or-show-branches ()
-  "Abort storing current note, or call `outline-show-branches'."
+  "Abort storing current note, or show just branches."
   (interactive)
-  (if (not org-finish-function)
-      (save-excursion
-	(save-restriction
-	  (org-narrow-to-subtree)
-	  (org-flag-subtree t)
-	  (call-interactively 'outline-show-branches)
-	  (org-hide-archived-subtrees (point-min) (point-max))))
-    (let ((org-note-abort t))
-      (funcall org-finish-function))))
+  (if org-finish-function
+      (let ((org-note-abort t))
+        (funcall org-finish-function))
+    (if (org-before-first-heading-p)
+        (org-show-branches-buffer)
+      (outline-hide-subtree)
+      (outline-show-branches))))
 
 (defun org-delete-indentation (&optional arg)
   "Join current line to previous and fix whitespace at join.
-- 
2.22.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-Make-show-children-applicable-to-whole-file.patch --]
[-- Type: text/x-patch, Size: 1448 bytes --]

From f561ed24863ee0b501c538ffa565e290c0eeb99e Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Thu, 11 Jul 2019 12:21:12 +0200
Subject: [PATCH 4/4] Make show-children applicable to whole file

* lisp/org.el (org-ctrl-c-tab): Extend and refactor.
---
 lisp/org.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index fecfc451c..de5b5855f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18070,14 +18070,20 @@ context.  See the individual commands for more information."
   (interactive)
   (org-return t))
 
-(defun org-ctrl-c-tab (&optional _arg)
+(defun org-ctrl-c-tab (&optional arg)
   "Toggle columns width in a table, or show children.
 Call `org-table-toggle-column-width' if point is in a table.
-Otherwise, call `org-show-children'."
+Otherwise, call `org-show-children'.  ARG is the level to hide."
   (interactive "p")
-  (call-interactively
-   (if (org-at-table-p) #'org-table-toggle-column-width
-     #'org-show-children)))
+  (if (org-at-table-p)
+      (call-interactively #'org-table-toggle-column-width)
+    (if (org-before-first-heading-p)
+        (progn
+          (org-flag-above-first-heading)
+          (outline-hide-sublevels (or arg 1))
+          (goto-char (point-min)))
+      (outline-hide-subtree)
+      (org-show-children arg))))
 
 (defun org-ctrl-c-star ()
   "Compute table, or change heading status of lines.
-- 
2.22.0


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

* Re: [RFC] Extend+slight change to C-c C-k and C-c TAB
@ 2019-07-11 20:38 Gustav Wikström
  2019-07-13 21:32 ` Marco Wahl
  0 siblings, 1 reply; 3+ messages in thread
From: Gustav Wikström @ 2019-07-11 20:38 UTC (permalink / raw)
  To: marcowahlsoft@gmail.com; +Cc: emacs-orgmode@gnu.org

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

Hi Marco,

I (ofc!) support this.

/Gustav

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

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

* Re: [RFC] Extend+slight change to C-c C-k and C-c TAB
  2019-07-11 20:38 Gustav Wikström
@ 2019-07-13 21:32 ` Marco Wahl
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Wahl @ 2019-07-13 21:32 UTC (permalink / raw)
  To: Gustav Wikström; +Cc: emacs-orgmode@gnu.org

Hi!

> I (ofc!) support this.

Thanks for your support!

I committed the stuff.


Ciao,  Marco

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

end of thread, other threads:[~2019-07-13 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 13:03 [RFC] Extend+slight change to C-c C-k and C-c TAB Marco Wahl
  -- strict thread matches above, loose matches on Subject: below --
2019-07-11 20:38 Gustav Wikström
2019-07-13 21:32 ` Marco Wahl

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