emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 a7143fa 04/12: Make prettier unique file names in


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] emacs-25 a7143fa 04/12: Make prettier unique file names in eww
Date: Fri, 25 Dec 2015 16:06:00 +0000

branch: emacs-25
commit a7143faf482d9b30c120ff969b1a75f1de7f8017
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make prettier unique file names in eww
    
    (eww-make-unique-file-name): Make unique file names by making
    files like foo(2).jpg instead of foo(1)(2).jpg.
    
    Backport:
    
    (cherry picked from commit edfdd0a6cbdfa9e5e4bd0553e2b489401ca39266)
---
 lisp/net/eww.el |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 90ddd05..a22664b 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1438,13 +1438,14 @@ Differences in #targets are ignored."
       (setq file "!"))
      ((string-match "\\`[.]" file)
       (setq file (concat "!" file))))
-    (let ((count 1))
+    (let ((count 1)
+          (stem file)
+          (suffix ""))
+      (when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
+        (setq stem (match-string 1)
+              suffix (match-string 2)))
       (while (file-exists-p (expand-file-name file directory))
-       (setq file
-             (if (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
-                 (format "%s(%d)%s" (match-string 1 file)
-                         count (match-string 2 file))
-               (format "%s(%d)" file count)))
+        (setq file (format "%s(%d)%s" stem count suffix))
        (setq count (1+ count)))
       (expand-file-name file directory)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]