emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Enable silent visibility cycling (was: How to turn off visibility-state messages from 'org-cycle?)
Date: Fri, 19 Jul 2013 13:57:40 +0200	[thread overview]
Message-ID: <87mwpiahjf.fsf_-_@gmail.com> (raw)
In-Reply-To: 874nbqgbti.fsf@ucl.ac.uk

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

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Would you wrap it all up in a patch and submit it?  It would be great to
> have incorporated.

ok, done. 

PS
I included this into `outshine.el' too, since outline-cycle showed the
same behaviour. 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: enable silent visibility cycling --]
[-- Type: text/x-patch, Size: 3309 bytes --]

From 0a4dad9119af9aed8e5160a05e81ac35f2bb0044 Mon Sep 17 00:00:00 2001
From: tj <tj@data-driven.de>
Date: Fri, 19 Jul 2013 13:47:20 +0200
Subject: [PATCH] Org: Enable silent visibility cycling

* lisp/org.el: add boolean variable `org-cycle-silently'.
add function `org-toggle-silent-cycling'.
(org-cycle-internal-global): make visibility-state-change messages conditional
on `org-cycle-silently'.

The problem here was that, especially in batch use, unconditionally writing a
message for each visibility-state-change might send a lot of clutter to
stdout.

Modified from a patch proposal by Thorsten Jolitz.
---
 lisp/org.el | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index fb5099e..1eb511d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6494,6 +6494,9 @@ and subscripts."
 
 (defvar org-inlinetask-min-level)
 
+(defvar org-cycle-silently nil
+  "Suppress visibility-state-change messages when non-nil.")
+
 ;;;###autoload
 (defun org-cycle (&optional arg)
   "TAB-action and visibility cycling for Org-mode.
@@ -6661,6 +6664,21 @@ in special contexts.
 	    (org-back-to-heading)
 	    (org-cycle)))))))
 
+(defun org-toggle-silent-cycling (&optional arg)
+  "Toggle silent cycling between visibility states.
+
+  When silent cycling is off, visibility state-change messages are
+  written to stdout (i.e. the *Messages* buffer), otherwise these
+  messages are suppressed. With prefix argument ARG, cycle silently
+  if ARG is positive, otherwise write state-change messages."
+  (interactive "P")
+  (setq org-cycle-silently
+	(if (null arg)
+	    (not org-cycle-silently)
+	  (> (prefix-numeric-value arg) 0)))
+  (message "Silent visibility cycling %s"
+	   (if org-cycle-silently "enabled" "disabled")))
+
 (defun org-cycle-internal-global ()
   "Do the global cycling action."
   ;; Hack to avoid display of messages for .org  attachments in Gnus
@@ -6672,9 +6690,11 @@ in special contexts.
       ;; We just created the overview - now do table of contents
       ;; This can be slow in very large buffers, so indicate action
       (run-hook-with-args 'org-pre-cycle-hook 'contents)
-      (unless ga (message "CONTENTS..."))
+      (unless (or ga org-cycle-silently)
+	(message "CONTENTS..."))
       (org-content)
-      (unless ga (message "CONTENTS...done"))
+      (unless (or ga org-cycle-silently)
+	(message "CONTENTS...done"))
       (setq org-cycle-global-status 'contents)
       (run-hook-with-args 'org-cycle-hook 'contents))
 
@@ -6683,7 +6703,8 @@ in special contexts.
       ;; We just showed the table of contents - now show everything
       (run-hook-with-args 'org-pre-cycle-hook 'all)
       (show-all)
-      (unless ga (message "SHOW ALL"))
+      (unless (or ga org-cycle-silently)
+	(message "SHOW ALL"))
       (setq org-cycle-global-status 'all)
       (run-hook-with-args 'org-cycle-hook 'all))
 
@@ -6691,7 +6712,8 @@ in special contexts.
       ;; Default action: go to overview
       (run-hook-with-args 'org-pre-cycle-hook 'overview)
       (org-overview)
-      (unless ga (message "OVERVIEW"))
+      (unless (or ga org-cycle-silently)
+	(message "OVERVIEW"))
       (setq org-cycle-global-status 'overview)
       (run-hook-with-args 'org-cycle-hook 'overview)))))
 
-- 
1.8.2.3


[-- Attachment #3: Type: text/plain, Size: 22 bytes --]


-- 
cheers,
Thorsten

  reply	other threads:[~2013-07-19 11:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 14:13 How to turn off visibility-state messages from 'org-cycle? Thorsten Jolitz
2013-07-18  8:35 ` Eric S Fraga
2013-07-18  9:32   ` Thorsten Jolitz
2013-07-18  9:52     ` Thorsten Jolitz
2013-07-18  9:57       ` Thorsten Jolitz
2013-07-19  9:04         ` Eric S Fraga
2013-07-19 11:57           ` Thorsten Jolitz [this message]
2013-07-19 12:23             ` [PATCH] Enable silent visibility cycling Jambunathan K
2013-07-22  7:50               ` Thorsten Jolitz
2013-07-22  7:58                 ` Jambunathan K
2013-07-25 10:18                   ` Thorsten Jolitz
2013-07-19 17:54             ` Eric S Fraga
2013-09-02  6:50               ` Carsten Dominik
2013-07-18 11:40 ` How to turn off visibility-state messages from 'org-cycle? Jambunathan K
2013-07-19  6:18   ` Thorsten Jolitz

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=87mwpiahjf.fsf_-_@gmail.com \
    --to=tjolitz@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).