From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz 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 Message-ID: <87mwpiahjf.fsf_-_@gmail.com> References: <878v158eag.fsf@gmail.com> <87a9lkmfk0.fsf@ucl.ac.uk> <87txjsgqmy.fsf@gmail.com> <87oba0gpon.fsf@gmail.com> <87k3kogpgd.fsf@gmail.com> <874nbqgbti.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V09Jw-000308-MX for emacs-orgmode@gnu.org; Fri, 19 Jul 2013 07:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V09Jv-0005Dc-FB for emacs-orgmode@gnu.org; Fri, 19 Jul 2013 07:58:00 -0400 Received: from plane.gmane.org ([80.91.229.3]:60694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V09Jv-0005DP-8q for emacs-orgmode@gnu.org; Fri, 19 Jul 2013 07:57:59 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V09Jq-0002PQ-4W for emacs-orgmode@gnu.org; Fri, 19 Jul 2013 13:57:54 +0200 Received: from e178059032.adsl.alicedsl.de ([85.178.59.32]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jul 2013 13:57:54 +0200 Received: from tj by e178059032.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jul 2013 13:57:54 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Eric S Fraga 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Org-Enable-silent-visibility-cycling.patch Content-Description: enable silent visibility cycling >From 0a4dad9119af9aed8e5160a05e81ac35f2bb0044 Mon Sep 17 00:00:00 2001 From: tj 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 --=-=-= Content-Type: text/plain -- cheers, Thorsten --=-=-=--