diff options
| author | Eli Zaretskii | 2017-01-10 17:47:10 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-01-10 17:47:10 +0200 |
| commit | 560a384038845e37228226313eccfc8d70132553 (patch) | |
| tree | bdd4bda64aa32f84e4c78a9cef02a90ec44022b4 | |
| parent | ef8c9f8fc922b615aca91b47820d1f1900fddc96 (diff) | |
| download | emacs-560a384038845e37228226313eccfc8d70132553.tar.gz emacs-560a384038845e37228226313eccfc8d70132553.zip | |
Don't use unsafe encoding for the bookmark file
* lisp/bookmark.el (bookmark-write-file): Handle the case when the
explicitly specified encoding of the bookmark file cannot encode the
additional bookmarks just added. (Bug#25365)
| -rw-r--r-- | lisp/bookmark.el | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index e18362bca95..02dd8a9f6fc 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -1432,13 +1432,20 @@ for a file, defaulting to the file defined by variable | |||
| 1432 | ;; arbitrary Lisp objects being stored in bookmark records, | 1432 | ;; arbitrary Lisp objects being stored in bookmark records, |
| 1433 | ;; and some users create objects containing circularities. | 1433 | ;; and some users create objects containing circularities. |
| 1434 | (print-circle t)) | 1434 | (print-circle t)) |
| 1435 | (bookmark-insert-file-format-version-stamp coding-system-for-write) | ||
| 1436 | (insert "(") | 1435 | (insert "(") |
| 1437 | ;; Rather than a single call to `pp' we make one per bookmark. | 1436 | ;; Rather than a single call to `pp' we make one per bookmark. |
| 1438 | ;; Apparently `pp' has a poor algorithmic complexity, so this | 1437 | ;; Apparently `pp' has a poor algorithmic complexity, so this |
| 1439 | ;; scales a lot better. bug#4485. | 1438 | ;; scales a lot better. bug#4485. |
| 1440 | (dolist (i bookmark-alist) (pp i (current-buffer))) | 1439 | (dolist (i bookmark-alist) (pp i (current-buffer))) |
| 1441 | (insert ")") | 1440 | (insert ")") |
| 1441 | ;; Make sure the specified encoding can safely encode the | ||
| 1442 | ;; bookmarks. If it cannot, suggest utf-8-emacs as default. | ||
| 1443 | (with-coding-priority '(utf-8-emacs) | ||
| 1444 | (setq coding-system-for-write | ||
| 1445 | (select-safe-coding-system (point-min) (point-max) | ||
| 1446 | (list t coding-system-for-write)))) | ||
| 1447 | (goto-char (point-min)) | ||
| 1448 | (bookmark-insert-file-format-version-stamp coding-system-for-write) | ||
| 1442 | (let ((version-control | 1449 | (let ((version-control |
| 1443 | (cond | 1450 | (cond |
| 1444 | ((null bookmark-version-control) nil) | 1451 | ((null bookmark-version-control) nil) |