Skip to content

Instantly share code, notes, and snippets.

@treyharris
Created July 26, 2020 18:34
Show Gist options
  • Save treyharris/1ca9e26397a0e7740f19777336bf3434 to your computer and use it in GitHub Desktop.
Save treyharris/1ca9e26397a0e7740f19777336bf3434 to your computer and use it in GitHub Desktop.

ediff org files…

Annoyingly, ediff tends to fire up org-mode files folded, which makes it impossible to see the hunks. A fix from Rémi Vanicat:

;; 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)
  )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment