[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org c8f88589cb 09/14: org-persist: Set utf-8 coding whe
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org c8f88589cb 09/14: org-persist: Set utf-8 coding when reading/writing |
Date: |
Sun, 22 Jan 2023 10:58:11 -0500 (EST) |
branch: externals/org
commit c8f88589cb8891cbe0f70aa6969837619cf05f41
Author: TEC <git@tecosaur.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-persist: Set utf-8 coding when reading/writing
* lisp/org-persist.el (org-persist--write-elisp-file,
org-persist--read-elisp-file): Instead of letting `find-auto-coding' be
invoked to determine the coding for org-persist cache files (which can
be surprisingly expensive), we simply set utf-8 coding when
reading/writing.
---
lisp/org-persist.el | 66 ++++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 6fbc8d87b0..385e118115 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -386,37 +386,38 @@ FORMAT and ARGS are passed to `message'."
(defun org-persist--read-elisp-file (&optional buffer-or-file)
"Read elisp data from BUFFER-OR-FILE or current buffer."
- (unless buffer-or-file (setq buffer-or-file (current-buffer)))
- (with-temp-buffer
- (if (bufferp buffer-or-file)
- (set-buffer buffer-or-file)
- (insert-file-contents buffer-or-file))
- (condition-case err
- (let ((coding-system-for-read 'utf-8)
- (read-circle t)
- (start-time (float-time)))
- ;; FIXME: Reading sometimes fails to read circular objects.
- ;; I suspect that it happens when we have object reference
- ;; #N# read before object definition #N=. If it is really
- ;; so, it should be Emacs bug - either in `read' or in
- ;; `prin1'. Meanwhile, just fail silently when `read'
- ;; fails to parse the saved cache object.
- (prog1
- (read (current-buffer))
- (org-persist--display-time
- (- (float-time) start-time)
- "Reading from %S" buffer-or-file)))
- ;; Recover gracefully if index file is corrupted.
- (error
- ;; Remove problematic file.
- (unless (bufferp buffer-or-file) (delete-file buffer-or-file))
- ;; Do not report the known error to user.
- (if (string-match-p "Invalid read syntax" (error-message-string err))
- (message "Emacs reader failed to read data in %S. The error was: %S"
- buffer-or-file (error-message-string err))
- (warn "Emacs reader failed to read data in %S. The error was: %S"
- buffer-or-file (error-message-string err)))
- nil))))
+ (let (;; UTF-8 is explicitly used in `org-persist--write-elisp-file'.
+ (coding-system-for-read 'utf-8)
+ (buffer-or-file (or buffer-or-file (current-buffer))))
+ (with-temp-buffer
+ (if (bufferp buffer-or-file)
+ (set-buffer buffer-or-file)
+ (insert-file-contents buffer-or-file))
+ (condition-case err
+ (let ((read-circle t)
+ (start-time (float-time)))
+ ;; FIXME: Reading sometimes fails to read circular objects.
+ ;; I suspect that it happens when we have object reference
+ ;; #N# read before object definition #N=. If it is really
+ ;; so, it should be Emacs bug - either in `read' or in
+ ;; `prin1'. Meanwhile, just fail silently when `read'
+ ;; fails to parse the saved cache object.
+ (prog1
+ (read (current-buffer))
+ (org-persist--display-time
+ (- (float-time) start-time)
+ "Reading from %S" buffer-or-file)))
+ ;; Recover gracefully if index file is corrupted.
+ (error
+ ;; Remove problematic file.
+ (unless (bufferp buffer-or-file) (delete-file buffer-or-file))
+ ;; Do not report the known error to user.
+ (if (string-match-p "Invalid read syntax" (error-message-string err))
+ (message "Emacs reader failed to read data in %S. The error was:
%S"
+ buffer-or-file (error-message-string err))
+ (warn "Emacs reader failed to read data in %S. The error was: %S"
+ buffer-or-file (error-message-string err)))
+ nil)))))
(defun org-persist--write-elisp-file (file data &optional no-circular pp)
"Write elisp DATA to FILE."
@@ -432,6 +433,9 @@ FORMAT and ARGS are passed to `message'."
;; To read more about this, see the comments in Emacs' fileio.c, in
;; particular the large comment block in init_fileio.
(let ((write-region-inhibit-fsync t)
+ ;; We set UTF-8 here and in `org-persist--read-elisp-file'
+ ;; to avoid the overhead from `find-auto-coding'.
+ (coding-system-for-write 'utf-8)
(print-circle (not no-circular))
print-level
print-length
- [elpa] externals/org updated (b34bdc8719 -> f0dfbf0c39), ELPA Syncer, 2023/01/22
- [elpa] externals/org ddca762329 01/14: org-element--cache-verify-element: Format all the elements in warning, ELPA Syncer, 2023/01/22
- [elpa] externals/org 0af74d33a7 03/14: org-manual: Fix typos in print_bibliography kwd, ELPA Syncer, 2023/01/22
- [elpa] externals/org ffd832d5d6 06/14: org-manual: Update #+include block parsing, ELPA Syncer, 2023/01/22
- [elpa] externals/org e9c0696f79 08/14: org-persist: Inhibit fsync when writing cachefiles, ELPA Syncer, 2023/01/22
- [elpa] externals/org 4b546e04af 02/14: org-element--cache-submit-request: Ensure correct cache synchronization, ELPA Syncer, 2023/01/22
- [elpa] externals/org 7e649050c7 05/14: ox: Pass through unparsed #+include content, ELPA Syncer, 2023/01/22
- [elpa] externals/org c8f88589cb 09/14: org-persist: Set utf-8 coding when reading/writing,
ELPA Syncer <=
- [elpa] externals/org b29f772416 10/14: org-macs: Split org-compile-file into two funs, ELPA Syncer, 2023/01/22
- [elpa] externals/org f0dfbf0c39 14/14: ox-latex: Erase compile buffer at the start, ELPA Syncer, 2023/01/22
- [elpa] externals/org 5cde90e3c8 04/14: ox: Refactor org-export-expand-include-keyword, ELPA Syncer, 2023/01/22
- [elpa] externals/org 506989bed5 07/14: ox: Improve #+include parsing docstring, ELPA Syncer, 2023/01/22
- [elpa] externals/org b84018633e 13/14: ox-latex: Split org-latex-compile into two funs, ELPA Syncer, 2023/01/22
- [elpa] externals/org d0c87c762a 11/14: ox-latex: Do not hardcode fallback compiler, ELPA Syncer, 2023/01/22
- [elpa] externals/org 18d2f871c2 12/14: org: Split org-format-latex into two functions, ELPA Syncer, 2023/01/22