diff options
| author | Lars Ingebrigtsen | 2015-12-24 22:47:58 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2015-12-24 22:47:58 +0100 |
| commit | edfdd0a6cbdfa9e5e4bd0553e2b489401ca39266 (patch) | |
| tree | 0df01bbb55857751f5f999b16f6c0442949c867a | |
| parent | af22a010d87516c2a646572fb27512c03057784f (diff) | |
| download | emacs-edfdd0a6cbdfa9e5e4bd0553e2b489401ca39266.tar.gz emacs-edfdd0a6cbdfa9e5e4bd0553e2b489401ca39266.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.
| -rw-r--r-- | 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 d5606365396..8ea17e01018 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -1442,13 +1442,14 @@ Differences in #targets are ignored." | |||
| 1442 | (setq file "!")) | 1442 | (setq file "!")) |
| 1443 | ((string-match "\\`[.]" file) | 1443 | ((string-match "\\`[.]" file) |
| 1444 | (setq file (concat "!" file)))) | 1444 | (setq file (concat "!" file)))) |
| 1445 | (let ((count 1)) | 1445 | (let ((count 1) |
| 1446 | (stem file) | ||
| 1447 | (suffix "")) | ||
| 1448 | (when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file) | ||
| 1449 | (setq stem (match-string 1) | ||
| 1450 | suffix (match-string 2))) | ||
| 1446 | (while (file-exists-p (expand-file-name file directory)) | 1451 | (while (file-exists-p (expand-file-name file directory)) |
| 1447 | (setq file | 1452 | (setq file (format "%s(%d)%s" stem count suffix)) |
| 1448 | (if (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file) | ||
| 1449 | (format "%s(%d)%s" (match-string 1 file) | ||
| 1450 | count (match-string 2 file)) | ||
| 1451 | (format "%s(%d)" file count))) | ||
| 1452 | (setq count (1+ count))) | 1453 | (setq count (1+ count))) |
| 1453 | (expand-file-name file directory))) | 1454 | (expand-file-name file directory))) |
| 1454 | 1455 | ||