aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2015-12-24 22:47:58 +0100
committerLars Ingebrigtsen2015-12-25 17:02:48 +0100
commita7143faf482d9b30c120ff969b1a75f1de7f8017 (patch)
tree0b548b5ebbbf009cc73344ccc8ac1dad68c8acdd
parent90f82ffa5dee8314edd8c73d72ef2f82ee617a11 (diff)
downloademacs-a7143faf482d9b30c120ff969b1a75f1de7f8017.tar.gz
emacs-a7143faf482d9b30c120ff969b1a75f1de7f8017.zip
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)
-rw-r--r--lisp/net/eww.el13
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 90ddd05b845..a22664bfbb5 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1438,13 +1438,14 @@ Differences in #targets are ignored."
1438 (setq file "!")) 1438 (setq file "!"))
1439 ((string-match "\\`[.]" file) 1439 ((string-match "\\`[.]" file)
1440 (setq file (concat "!" file)))) 1440 (setq file (concat "!" file))))
1441 (let ((count 1)) 1441 (let ((count 1)
1442 (stem file)
1443 (suffix ""))
1444 (when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
1445 (setq stem (match-string 1)
1446 suffix (match-string 2)))
1442 (while (file-exists-p (expand-file-name file directory)) 1447 (while (file-exists-p (expand-file-name file directory))
1443 (setq file 1448 (setq file (format "%s(%d)%s" stem count suffix))
1444 (if (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
1445 (format "%s(%d)%s" (match-string 1 file)
1446 count (match-string 2 file))
1447 (format "%s(%d)" file count)))
1448 (setq count (1+ count))) 1449 (setq count (1+ count)))
1449 (expand-file-name file directory))) 1450 (expand-file-name file directory)))
1450 1451