Comparing directories in Emacs

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
12
down vote

favorite
3












I am experimenting with ediff-directories, but I am not sure I am using it correctly.



I read in the documentation that, once I supply two directories to ediff-directories, if I press == Emacs compares them recursively.



However, if I press == I only get folders with = signs (meaning that the two folders have identical contents) on the level where I run the command. If I want to see which folders have = signs at deeper levels in the folder hierarchy, I need to re-run the == command at each level.



How can I tell emacs to go recursively all the way to the leaves so that I can see all the differences in the directory difference buffer (accessible via the keyboard command D)?



If anybody knows of a tutorial on how to use ediff-directories (other than the official documentation), I would be highly interested.




Also, if I want to exit a session group (comparison of folders at one level), but I have sessions open for deeper levels, if I press q (quit this session group), Emacs complains with the messaage:




This sesssion group has active sessions---cannot exit




How can I exit session groups without exiting the sub-sessions one by one?










share|improve this question



















  • 1




    What I'd pay for ediff to become as usable as Beyond Compare...
    – ckhan
    Sep 4 '12 at 17:26






  • 1




    ztree-diff can diff two directories recursively. github.com/fourier/ztree
    – momeara
    Dec 5 '15 at 1:15















up vote
12
down vote

favorite
3












I am experimenting with ediff-directories, but I am not sure I am using it correctly.



I read in the documentation that, once I supply two directories to ediff-directories, if I press == Emacs compares them recursively.



However, if I press == I only get folders with = signs (meaning that the two folders have identical contents) on the level where I run the command. If I want to see which folders have = signs at deeper levels in the folder hierarchy, I need to re-run the == command at each level.



How can I tell emacs to go recursively all the way to the leaves so that I can see all the differences in the directory difference buffer (accessible via the keyboard command D)?



If anybody knows of a tutorial on how to use ediff-directories (other than the official documentation), I would be highly interested.




Also, if I want to exit a session group (comparison of folders at one level), but I have sessions open for deeper levels, if I press q (quit this session group), Emacs complains with the messaage:




This sesssion group has active sessions---cannot exit




How can I exit session groups without exiting the sub-sessions one by one?










share|improve this question



















  • 1




    What I'd pay for ediff to become as usable as Beyond Compare...
    – ckhan
    Sep 4 '12 at 17:26






  • 1




    ztree-diff can diff two directories recursively. github.com/fourier/ztree
    – momeara
    Dec 5 '15 at 1:15













up vote
12
down vote

favorite
3









up vote
12
down vote

favorite
3






3





I am experimenting with ediff-directories, but I am not sure I am using it correctly.



I read in the documentation that, once I supply two directories to ediff-directories, if I press == Emacs compares them recursively.



However, if I press == I only get folders with = signs (meaning that the two folders have identical contents) on the level where I run the command. If I want to see which folders have = signs at deeper levels in the folder hierarchy, I need to re-run the == command at each level.



How can I tell emacs to go recursively all the way to the leaves so that I can see all the differences in the directory difference buffer (accessible via the keyboard command D)?



If anybody knows of a tutorial on how to use ediff-directories (other than the official documentation), I would be highly interested.




Also, if I want to exit a session group (comparison of folders at one level), but I have sessions open for deeper levels, if I press q (quit this session group), Emacs complains with the messaage:




This sesssion group has active sessions---cannot exit




How can I exit session groups without exiting the sub-sessions one by one?










share|improve this question















I am experimenting with ediff-directories, but I am not sure I am using it correctly.



I read in the documentation that, once I supply two directories to ediff-directories, if I press == Emacs compares them recursively.



However, if I press == I only get folders with = signs (meaning that the two folders have identical contents) on the level where I run the command. If I want to see which folders have = signs at deeper levels in the folder hierarchy, I need to re-run the == command at each level.



How can I tell emacs to go recursively all the way to the leaves so that I can see all the differences in the directory difference buffer (accessible via the keyboard command D)?



If anybody knows of a tutorial on how to use ediff-directories (other than the official documentation), I would be highly interested.




Also, if I want to exit a session group (comparison of folders at one level), but I have sessions open for deeper levels, if I press q (quit this session group), Emacs complains with the messaage:




This sesssion group has active sessions---cannot exit




How can I exit session groups without exiting the sub-sessions one by one?







emacs diff






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 '12 at 20:00

























asked Dec 18 '11 at 23:02









Amelio Vazquez-Reina

11.9k51125228




11.9k51125228







  • 1




    What I'd pay for ediff to become as usable as Beyond Compare...
    – ckhan
    Sep 4 '12 at 17:26






  • 1




    ztree-diff can diff two directories recursively. github.com/fourier/ztree
    – momeara
    Dec 5 '15 at 1:15













  • 1




    What I'd pay for ediff to become as usable as Beyond Compare...
    – ckhan
    Sep 4 '12 at 17:26






  • 1




    ztree-diff can diff two directories recursively. github.com/fourier/ztree
    – momeara
    Dec 5 '15 at 1:15








1




1




What I'd pay for ediff to become as usable as Beyond Compare...
– ckhan
Sep 4 '12 at 17:26




What I'd pay for ediff to become as usable as Beyond Compare...
– ckhan
Sep 4 '12 at 17:26




1




1




ztree-diff can diff two directories recursively. github.com/fourier/ztree
– momeara
Dec 5 '15 at 1:15





ztree-diff can diff two directories recursively. github.com/fourier/ztree
– momeara
Dec 5 '15 at 1:15











3 Answers
3






active

oldest

votes

















up vote
5
down vote













I have used M-x dired-compare-directories, but there is also EdiffTrees, which might serve you better in the situation you describe.






share|improve this answer



























    up vote
    3
    down vote













    I also needed this feature and came up with the following. The function ediff-directories-recursive works like ediff-directories but recurses into sub-directories.



    The magic behind that is temporarily replacing the built-in directory-files by a self-made directory-files-recursive before calling ediff-directories.



    (eval
    (let ((directory-files-original (symbol-function 'directory-files)))
    `(defun directory-files-recursive (directory &optional full match nosort)
    "Like `directory-files' but recurses into subdirectories. Does not follow symbolic links."
    (let* ((prefix (or (and full "") directory))
    dirs
    files)
    (mapc (lambda (p)
    (let ((fullname (if full p (concat prefix "/" p))))
    (when (and (file-directory-p fullname)
    (null (or (string-match "\(^\|/\).$" p)
    (string-match "\(^\|/\)..$" p)
    (file-symlink-p fullname))))
    (setq dirs (cons p dirs)))))
    (funcall ,directory-files-original directory full nil nosort))
    (setq dirs (nreverse dirs))
    (mapc (lambda (p)
    (when (null (file-directory-p (if full p (concat prefix "/" p))))
    (setq files (cons p files))))
    (funcall ,directory-files-original directory full match nosort))
    (setq files (nreverse files))
    (mapc (lambda (d)
    (setq files
    (append files
    (if full
    (apply 'directory-files-recursive (list d full match nosort))
    (mapcar (lambda (n)
    (concat d "/" n))
    (apply 'directory-files-recursive (list (concat prefix "/" d) full match nosort)))))))
    dirs)
    files))))

    (eval
    `(defun ediff-directories-recursive (dir1 dir2 regexp)
    "Like `ediff-directories' but recurses into sub-directories. Does not follow symbolic links."
    ,(interactive-form (symbol-function 'ediff-directories))
    (let ((directory-files-original (symbol-function 'directory-files)))
    (unwind-protect
    (progn
    (fset 'directory-files (symbol-function 'directory-files-recursive))
    (ediff-directories dir1 dir2 regexp)
    (fset 'directory-files directory-files-original))))))





    share|improve this answer






















    • I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
      – nephewtom
      Aug 25 '15 at 10:09

















    up vote
    0
    down vote













    There is ztree package available from Melpa which supports recursive directory tree comparison: M-x ztree-diff using GNU diff utilities to compare corresponding files.



    If you use use-package then to install and configure ztree package, add to your .emacs:



    ;; ** recursive directory tree comparison: M-x ztree-diff
    (use-package ztree
    :ensure t) ; needs GNU diff utility





    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f27128%2fcomparing-directories-in-emacs%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      5
      down vote













      I have used M-x dired-compare-directories, but there is also EdiffTrees, which might serve you better in the situation you describe.






      share|improve this answer
























        up vote
        5
        down vote













        I have used M-x dired-compare-directories, but there is also EdiffTrees, which might serve you better in the situation you describe.






        share|improve this answer






















          up vote
          5
          down vote










          up vote
          5
          down vote









          I have used M-x dired-compare-directories, but there is also EdiffTrees, which might serve you better in the situation you describe.






          share|improve this answer












          I have used M-x dired-compare-directories, but there is also EdiffTrees, which might serve you better in the situation you describe.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 24 '12 at 11:35









          Steen

          16818




          16818






















              up vote
              3
              down vote













              I also needed this feature and came up with the following. The function ediff-directories-recursive works like ediff-directories but recurses into sub-directories.



              The magic behind that is temporarily replacing the built-in directory-files by a self-made directory-files-recursive before calling ediff-directories.



              (eval
              (let ((directory-files-original (symbol-function 'directory-files)))
              `(defun directory-files-recursive (directory &optional full match nosort)
              "Like `directory-files' but recurses into subdirectories. Does not follow symbolic links."
              (let* ((prefix (or (and full "") directory))
              dirs
              files)
              (mapc (lambda (p)
              (let ((fullname (if full p (concat prefix "/" p))))
              (when (and (file-directory-p fullname)
              (null (or (string-match "\(^\|/\).$" p)
              (string-match "\(^\|/\)..$" p)
              (file-symlink-p fullname))))
              (setq dirs (cons p dirs)))))
              (funcall ,directory-files-original directory full nil nosort))
              (setq dirs (nreverse dirs))
              (mapc (lambda (p)
              (when (null (file-directory-p (if full p (concat prefix "/" p))))
              (setq files (cons p files))))
              (funcall ,directory-files-original directory full match nosort))
              (setq files (nreverse files))
              (mapc (lambda (d)
              (setq files
              (append files
              (if full
              (apply 'directory-files-recursive (list d full match nosort))
              (mapcar (lambda (n)
              (concat d "/" n))
              (apply 'directory-files-recursive (list (concat prefix "/" d) full match nosort)))))))
              dirs)
              files))))

              (eval
              `(defun ediff-directories-recursive (dir1 dir2 regexp)
              "Like `ediff-directories' but recurses into sub-directories. Does not follow symbolic links."
              ,(interactive-form (symbol-function 'ediff-directories))
              (let ((directory-files-original (symbol-function 'directory-files)))
              (unwind-protect
              (progn
              (fset 'directory-files (symbol-function 'directory-files-recursive))
              (ediff-directories dir1 dir2 regexp)
              (fset 'directory-files directory-files-original))))))





              share|improve this answer






















              • I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
                – nephewtom
                Aug 25 '15 at 10:09














              up vote
              3
              down vote













              I also needed this feature and came up with the following. The function ediff-directories-recursive works like ediff-directories but recurses into sub-directories.



              The magic behind that is temporarily replacing the built-in directory-files by a self-made directory-files-recursive before calling ediff-directories.



              (eval
              (let ((directory-files-original (symbol-function 'directory-files)))
              `(defun directory-files-recursive (directory &optional full match nosort)
              "Like `directory-files' but recurses into subdirectories. Does not follow symbolic links."
              (let* ((prefix (or (and full "") directory))
              dirs
              files)
              (mapc (lambda (p)
              (let ((fullname (if full p (concat prefix "/" p))))
              (when (and (file-directory-p fullname)
              (null (or (string-match "\(^\|/\).$" p)
              (string-match "\(^\|/\)..$" p)
              (file-symlink-p fullname))))
              (setq dirs (cons p dirs)))))
              (funcall ,directory-files-original directory full nil nosort))
              (setq dirs (nreverse dirs))
              (mapc (lambda (p)
              (when (null (file-directory-p (if full p (concat prefix "/" p))))
              (setq files (cons p files))))
              (funcall ,directory-files-original directory full match nosort))
              (setq files (nreverse files))
              (mapc (lambda (d)
              (setq files
              (append files
              (if full
              (apply 'directory-files-recursive (list d full match nosort))
              (mapcar (lambda (n)
              (concat d "/" n))
              (apply 'directory-files-recursive (list (concat prefix "/" d) full match nosort)))))))
              dirs)
              files))))

              (eval
              `(defun ediff-directories-recursive (dir1 dir2 regexp)
              "Like `ediff-directories' but recurses into sub-directories. Does not follow symbolic links."
              ,(interactive-form (symbol-function 'ediff-directories))
              (let ((directory-files-original (symbol-function 'directory-files)))
              (unwind-protect
              (progn
              (fset 'directory-files (symbol-function 'directory-files-recursive))
              (ediff-directories dir1 dir2 regexp)
              (fset 'directory-files directory-files-original))))))





              share|improve this answer






















              • I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
                – nephewtom
                Aug 25 '15 at 10:09












              up vote
              3
              down vote










              up vote
              3
              down vote









              I also needed this feature and came up with the following. The function ediff-directories-recursive works like ediff-directories but recurses into sub-directories.



              The magic behind that is temporarily replacing the built-in directory-files by a self-made directory-files-recursive before calling ediff-directories.



              (eval
              (let ((directory-files-original (symbol-function 'directory-files)))
              `(defun directory-files-recursive (directory &optional full match nosort)
              "Like `directory-files' but recurses into subdirectories. Does not follow symbolic links."
              (let* ((prefix (or (and full "") directory))
              dirs
              files)
              (mapc (lambda (p)
              (let ((fullname (if full p (concat prefix "/" p))))
              (when (and (file-directory-p fullname)
              (null (or (string-match "\(^\|/\).$" p)
              (string-match "\(^\|/\)..$" p)
              (file-symlink-p fullname))))
              (setq dirs (cons p dirs)))))
              (funcall ,directory-files-original directory full nil nosort))
              (setq dirs (nreverse dirs))
              (mapc (lambda (p)
              (when (null (file-directory-p (if full p (concat prefix "/" p))))
              (setq files (cons p files))))
              (funcall ,directory-files-original directory full match nosort))
              (setq files (nreverse files))
              (mapc (lambda (d)
              (setq files
              (append files
              (if full
              (apply 'directory-files-recursive (list d full match nosort))
              (mapcar (lambda (n)
              (concat d "/" n))
              (apply 'directory-files-recursive (list (concat prefix "/" d) full match nosort)))))))
              dirs)
              files))))

              (eval
              `(defun ediff-directories-recursive (dir1 dir2 regexp)
              "Like `ediff-directories' but recurses into sub-directories. Does not follow symbolic links."
              ,(interactive-form (symbol-function 'ediff-directories))
              (let ((directory-files-original (symbol-function 'directory-files)))
              (unwind-protect
              (progn
              (fset 'directory-files (symbol-function 'directory-files-recursive))
              (ediff-directories dir1 dir2 regexp)
              (fset 'directory-files directory-files-original))))))





              share|improve this answer














              I also needed this feature and came up with the following. The function ediff-directories-recursive works like ediff-directories but recurses into sub-directories.



              The magic behind that is temporarily replacing the built-in directory-files by a self-made directory-files-recursive before calling ediff-directories.



              (eval
              (let ((directory-files-original (symbol-function 'directory-files)))
              `(defun directory-files-recursive (directory &optional full match nosort)
              "Like `directory-files' but recurses into subdirectories. Does not follow symbolic links."
              (let* ((prefix (or (and full "") directory))
              dirs
              files)
              (mapc (lambda (p)
              (let ((fullname (if full p (concat prefix "/" p))))
              (when (and (file-directory-p fullname)
              (null (or (string-match "\(^\|/\).$" p)
              (string-match "\(^\|/\)..$" p)
              (file-symlink-p fullname))))
              (setq dirs (cons p dirs)))))
              (funcall ,directory-files-original directory full nil nosort))
              (setq dirs (nreverse dirs))
              (mapc (lambda (p)
              (when (null (file-directory-p (if full p (concat prefix "/" p))))
              (setq files (cons p files))))
              (funcall ,directory-files-original directory full match nosort))
              (setq files (nreverse files))
              (mapc (lambda (d)
              (setq files
              (append files
              (if full
              (apply 'directory-files-recursive (list d full match nosort))
              (mapcar (lambda (n)
              (concat d "/" n))
              (apply 'directory-files-recursive (list (concat prefix "/" d) full match nosort)))))))
              dirs)
              files))))

              (eval
              `(defun ediff-directories-recursive (dir1 dir2 regexp)
              "Like `ediff-directories' but recurses into sub-directories. Does not follow symbolic links."
              ,(interactive-form (symbol-function 'ediff-directories))
              (let ((directory-files-original (symbol-function 'directory-files)))
              (unwind-protect
              (progn
              (fset 'directory-files (symbol-function 'directory-files-recursive))
              (ediff-directories dir1 dir2 regexp)
              (fset 'directory-files directory-files-original))))))






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Aug 28 '14 at 16:55









              HalosGhost

              3,60592035




              3,60592035










              answered Aug 28 '14 at 16:53









              Tobias

              1315




              1315











              • I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
                – nephewtom
                Aug 25 '15 at 10:09
















              • I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
                – nephewtom
                Aug 25 '15 at 10:09















              I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
              – nephewtom
              Aug 25 '15 at 10:09




              I did eval-buffer and got this: Debugger entered--Lisp error: (wrong-type-argument symbolp (autoload "ediff" 890739 t nil)) interactive-form((autoload "ediff" 890739 t nil)) Any suggestion?
              – nephewtom
              Aug 25 '15 at 10:09










              up vote
              0
              down vote













              There is ztree package available from Melpa which supports recursive directory tree comparison: M-x ztree-diff using GNU diff utilities to compare corresponding files.



              If you use use-package then to install and configure ztree package, add to your .emacs:



              ;; ** recursive directory tree comparison: M-x ztree-diff
              (use-package ztree
              :ensure t) ; needs GNU diff utility





              share|improve this answer
























                up vote
                0
                down vote













                There is ztree package available from Melpa which supports recursive directory tree comparison: M-x ztree-diff using GNU diff utilities to compare corresponding files.



                If you use use-package then to install and configure ztree package, add to your .emacs:



                ;; ** recursive directory tree comparison: M-x ztree-diff
                (use-package ztree
                :ensure t) ; needs GNU diff utility





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  There is ztree package available from Melpa which supports recursive directory tree comparison: M-x ztree-diff using GNU diff utilities to compare corresponding files.



                  If you use use-package then to install and configure ztree package, add to your .emacs:



                  ;; ** recursive directory tree comparison: M-x ztree-diff
                  (use-package ztree
                  :ensure t) ; needs GNU diff utility





                  share|improve this answer












                  There is ztree package available from Melpa which supports recursive directory tree comparison: M-x ztree-diff using GNU diff utilities to compare corresponding files.



                  If you use use-package then to install and configure ztree package, add to your .emacs:



                  ;; ** recursive directory tree comparison: M-x ztree-diff
                  (use-package ztree
                  :ensure t) ; needs GNU diff utility






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 11 mins ago









                  jfs

                  639823




                  639823



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f27128%2fcomparing-directories-in-emacs%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?