Commit edfdd0a6 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

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.
parent af22a010
......@@ -1442,13 +1442,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)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment