From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ratish Punnoose Subject: Re: [WORG] How to ediff folded Org files? Date: Wed, 31 Jul 2013 23:19:34 +0000 (UTC) Message-ID: References: <87y5cwrnw9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4fla-0003IZ-17 for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 19:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4flS-00020T-8w for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 19:25:13 -0400 Received: from plane.gmane.org ([80.91.229.3]:52387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4flS-0001yl-03 for emacs-orgmode@gnu.org; Wed, 31 Jul 2013 19:25:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V4flP-0006z3-D0 for emacs-orgmode@gnu.org; Thu, 01 Aug 2013 01:25:03 +0200 Received: from bcproxy-dmz-ca-02.ca.sandia.gov ([198.206.219.39]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Aug 2013 01:25:03 +0200 Received: from ratish by bcproxy-dmz-ca-02.ca.sandia.gov with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Aug 2013 01:25:03 +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 Thorsten Jolitz gmail.com> writes: > Hi List, > > many files on Worg have this startup option: > > ,-------------------------- > | +STARTUP: ... fold ... > `-------------------------- > > what leads to trouble when there is a merge-conflict in (Ma)git to be > resolved manually with e(diff), because the different versions of the > Org-file are then presented in folded state in the ediff session, so the > diffs are invisible. > > But when I call 'show-all' or so on them, it breaks the ediff session. > Is there a simple trick to avoid this problem? > I was searching for a similar issue and came upon this list. I have a slightly different solution from the ones posted so far. When doing a diff, each org-mode buffer is fully folded. For each diff selection, that portion of the tree for each buffer is expanded. When moving to a new diff, the previous portion of the tree is collapsed and the area surrounding the new diff location is expanded. Acknowledgment: Michael Brand's solution was my starting inspiration. #+BEGIN_SRC emacs-lisp ;; diff hooks for org mode (add-hook 'ediff-select-hook 'f-ediff-org-unfold-tree-element) (add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree) ;; Check for org mode and existence of buffer (defun f-ediff-org-showhide(buf command &rest cmdargs) "If buffer exists and is orgmode then execute command" (if buf (if (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode) (save-excursion (set-buffer buf) (apply command cmdargs))) ) ) (defun f-ediff-org-unfold-tree-element () "Unfold tree at diff location" (f-ediff-org-showhide ediff-buffer-A 'org-reveal) (f-ediff-org-showhide ediff-buffer-B 'org-reveal) (f-ediff-org-showhide ediff-buffer-C 'org-reveal) ) ;; (defun f-ediff-org-fold-tree () "Fold tree back to top level" (f-ediff-org-showhide ediff-buffer-A 'hide-sublevels 1) (f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1) (f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1) ) #+END_SRC