Thorsten Jolitz <tjolitz <at> 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