[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Easy to add with push but not to the end of a list
From: |
Emanuel Berg |
Subject: |
Re: Easy to add with push but not to the end of a list |
Date: |
Tue, 06 Dec 2022 03:52:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Michael Heerdegen wrote:
>> Here is the `push' macro - TBH, I don't know what most of
>> that means ...
>
> That supports generalized variables; you don't need to do
> that (unless you want to).
Are the macros here correct then?
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/file-write-to.el
(require 'subr-x)
;; write
(defun write-to-file (file data)
(setq data (format "%s" data))
(write-region data 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")
;;
;; (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: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/01
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/01
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/01
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/03
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/03
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/05
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/05
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/05
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/05
- Re: Easy to add with push but not to the end of a list,
Emanuel Berg <=
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/06
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/06
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/08
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/29
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/31
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/31
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/12/06
- Re: Easy to add with push but not to the end of a list, Stefan Monnier, 2022/12/06
- Re: Easy to add with push but not to the end of a list, Michael Heerdegen, 2022/12/06