]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/diff-mode.el (diff-hunk-file-names): Handle filenames with spaces.
authorSam Steingold <sds@gnu.org>
Thu, 28 Feb 2013 16:34:51 +0000 (11:34 -0500)
committerSam Steingold <sds@gnu.org>
Thu, 28 Feb 2013 16:34:51 +0000 (11:34 -0500)
See <http://stackoverflow.com/questions/14720205>.

lisp/ChangeLog
lisp/vc/diff-mode.el

index 75fc2e77a0c0fb9617873175cdb84fb84824df7c..5713734fd80222a5e764ca9c28482eab224f11b3 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-28  Sam Steingold  <sds@gnu.org>
+
+       * vc/diff-mode.el (diff-hunk-file-names): Handle filenames with spaces.
+       See <http://stackoverflow.com/questions/14720205>.
+
 2013-02-28  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
 
        * net/net-utils.el (net-utils--revert-function): New fun (bug#13831).
index 940457b6cc085af2d4ae0c03722214d735f9d490..d9224b29c2e013bbef9c700ece9841f78d42d30b 100644 (file)
@@ -821,9 +821,11 @@ If the OLD prefix arg is passed, tell the file NAME of the old file."
                       (progn (diff-hunk-prev) (point))
                     (error (point-min)))))
          (header-files
-          (if (looking-at "[-*][-*][-*] \\(\\S-+\\)\\(\\s-.*\\)?\n[-+][-+][-+] \\(\\S-+\\)")
-              (list (if old (match-string 1) (match-string 3))
-                    (if old (match-string 3) (match-string 1)))
+           ;; handle filenames with spaces;
+           ;; cf. diff-font-lock-keywords / diff-file-header-face
+          (if (looking-at "[-*][-*][-*] \\([^\t]+\\)\t.*\n[-+][-+][-+] \\([^\t]+\\)")
+              (list (if old (match-string 1) (match-string 2))
+                    (if old (match-string 2) (match-string 1)))
             (forward-line 1) nil)))
       (delq nil
            (append
@@ -832,6 +834,7 @@ If the OLD prefix arg is passed, tell the file NAME of the old file."
                          (re-search-backward "^Index: \\(.+\\)" limit t)))
               (list (match-string 1)))
             header-files
+             ;; this assumes that there are no spaces in filenames
             (when (re-search-backward
                    "^diff \\(-\\S-+ +\\)*\\(\\S-+\\)\\( +\\(\\S-+\\)\\)?"
                    nil t)