[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Display of undisplayable characters: \U01F3A8 instead of diamond
From: |
Emanuel Berg |
Subject: |
Re: Display of undisplayable characters: \U01F3A8 instead of diamond |
Date: |
Thu, 08 Sep 2022 14:24:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Tomas Hlavaty wrote:
>>> * You see the effect, decide that it is good, put
>>> (some-hypothetical-other-command) in your init file.
>>> * On the next startup, it reads the file (which is fast), applies the
>>> data (which is supposedly also fast), has the same effect.
>>>
>>> The file name could include some relevant factors such as the terminal
>>> type on which the data depends.
>>
>> You suggest semi-automatically saving the generated code in
>> the init file, instead of the user copying it
>> there manually?
>
> No, he said that the generated code is saved automatically
> in a file and if the user puts
> (some-hypothetical-other-command) in his .emacs manually, it
> will load the saved file. Something like:
*Nothing like :)
> (defun some-hypothetical-other-command ()
> (or (let ((f "~/.emacs.d/cache/some-hypothetical-other-command.el"))
> (when (file-exists-p f)
> (load f)))
> (generate-and-save-that-slow-code)))
Again, the result, not the code ...
I have this [last] which I know works but I don't know what
the prefered format or idiomatic Elisp ways are to store and
retrieve data to and from the filesystem.
So yeah, what do we we have to do that fast and secure and for
arbitrary (nested) data structures?
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/file-write-to.el
(require 'subr-x)
;; write
(defun write-to-file (file str)
(write-region str nil file) )
(defalias 'write-to-file-string #'write-to-file)
(defun write-to-file-integer (file int)
(write-region (number-to-string int) nil file) )
;; read
(defun file-to-string (file)
"A string with the contents of FILE."
(interactive "Ffile: ")
(with-temp-buffer
(insert-file-contents file)
(string-trim
(buffer-substring-no-properties (point-min) (point-max)) )))
(defun file-to-integer (file)
(string-to-number (file-to-string file)) )
(defmacro file-to-variable (file var)
`(setq ,var ,(file-to-string file)) )
(defmacro file-to-variable-integer (file var)
`(setq ,var ,(string-to-number (file-to-string file))) )
;; (write-to-file "~/5ifth.txt" "Leeloo Dallas Multipass")
;; (write-to-file-integer "~/element.txt" 5)
;;
;; (file-to-string "~/5ifth.txt") ; Leeloo ...
;; (file-to-variable "~/5ifth.txt" string-value) ; Leeloo ...
;; string-value ; Leeloo ...
;; (file-to-variable-integer "~/element.txt" integer-value) ; 5
;; integer-value ; 5
(provide 'file-write-to)
--
underground experts united
https://dataswamp.org/~incal
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, (continued)
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Yuri Khan, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Yuri Khan, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Tomas Hlavaty, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Stefan Monnier, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Tomas Hlavaty, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/08
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/08
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond,
Emanuel Berg <=
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Yuri Khan, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/07
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/09
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/09
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/10
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/10
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/10
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Eli Zaretskii, 2022/09/10
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/10
- Re: Display of undisplayable characters: \U01F3A8 instead of diamond, Emanuel Berg, 2022/09/10