unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Easy to add with push but not to the end of a list
Date: Tue, 06 Dec 2022 23:30:29 +0100	[thread overview]
Message-ID: <87pmcwcghm.fsf@dataswamp.org> (raw)
In-Reply-To: 87bkog30ry.fsf@web.de

Michael Heerdegen wrote:

>> Are the macros here correct then?
>
> Depends on what you want.
>
>> (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))) )
>
> Calls of these macros will cause those FILEs to be looked up at macro
> expansion/ compile time, and the file contents will be become a part of
> the .elc.  I guess this is not what you want.

It's supposed to be used for reading FILE into VAR.

In practice I didn't use them since these were better
suited ...

(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)) )

> A second (related) problem is that FILE must be a string -
> a function call like (expand-file-name "my-file"
> "/some/path") will not behave as expected, because your
> helper functions don't expect an expression.

Okay, but how do you check if it's an expression?

Also take a look at this, one should have a cache function and
a function to store arbitrary data and datastructures and the
corresponding to load seam-/losslessly into the same Lisp
datastructures all tho these are not the same/unaware of the ones
that was used (refered to) when saving ...

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/cache.el

(let ((cache-file (format "%svar/data-cache.el" user-emacs-directory)))
  (defun save-char-table ()
    (with-temp-buffer
      (insert "(setq standard-display-table\n\n")
      (prin1 standard-display-table (current-buffer))
      (insert "\n\n)")
      (write-file cache-file) ))
  (declare-function save-char-table nil)

  (defun load-char-table ()
    (when (file-exists-p cache-file)
      (load-file cache-file) ))
  (declare-function load-char-table nil) )

(defun set-replacement-char-table ()
  (unless (load-char-table)
    (let ((tbl standard-display-table)) ;; WARNING, ugly code ahead!
      (set-char-table-range tbl '(#x102 . #x103)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x108 . #x10b)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x10e . #x111)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x114 . #x115)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x11a . #x121)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x124 . #x129)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x12c . #x12d)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x130 . #x135)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x138 . #x13a)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x13d . #x140)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x147 . #x14b)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x14e . #x155)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x158 . #x159)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x15c . #x15f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x162 . #x169)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x16c . #x171)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x174 . #x178)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x17f . #x2c6)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2c8 . #x2c8)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2ca . #x2d8)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2da . #x2da)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2dc . #x390)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x393 . #x394)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x398 . #x398)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x39b . #x39b)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x39e . #x39e)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3a0 . #x3a0)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3a2 . #x3a3)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3a5 . #x3a6)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3a8 . #x3bb)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3bd . #x3bf)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x3c1 . #x400)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x402 . #x404)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x407 . #x407)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x409 . #x40f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x411 . #x411)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x413 . #x414)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x416 . #x419)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x41b . #x41b)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x41f . #x41f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x423 . #x424)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x426 . #x42f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x431 . #x434)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x436 . #x43d)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x43f . #x43f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x442 . #x442)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x444 . #x444)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x446 . #x450)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x452 . #x454)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x457 . #x457)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x459 . #x4ad)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x4af . #x1fff)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x200b . #x200f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2016 . #x2017)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x201b . #x201b)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x201f . #x201f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2023 . #x2025)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2027 . #x202e)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2031 . #x2038)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x203b . #x20ab)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x20ad . #x2115)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2117 . #x2121)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2123 . #x2129)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x212c . #x218f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2194 . #x2211)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2213 . #x2247)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2249 . #x225f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2261 . #x2263)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2266 . #x2269)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x226c . #x2294)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2297 . #x2297)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x229a . #x229a)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x229d . #x245f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2469 . #x24b5)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x24eb . #x24ff)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2580 . #x2587)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2589 . #x2590)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2593 . #x259f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25a1 . #x25ad)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25af . #x25b1)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25b3 . #x25b3)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25b5 . #x25b5)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25b7 . #x25b7)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25b9 . #x25bb)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25bd . #x25bd)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25bf . #x25bf)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25c1 . #x25c1)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25c3 . #x25c7)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25c9 . #x25ce)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x25d0 . #x260f)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2613 . #x2665)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2667 . #x2716)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2719 . #x2bbc)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#x2bbe . #xfffc)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))
      (set-char-table-range tbl '(#xfffe . #x10ffff)
                            (vconcat (list (make-glyph-code #xfffd 'homoglyph))))

      (save-char-table) )))

(set-replacement-char-table)

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2022-12-06 22:30 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  2:26 Easy to add with push but not to the end of a list Heime
2022-11-28  2:43 ` [External] : " Drew Adams
2022-11-28  3:45   ` Heime
2022-11-28  6:11     ` Drew Adams
2022-11-28 20:00   ` Emanuel Berg
2022-11-28  5:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-28 20:19   ` Emanuel Berg
2022-11-28 21:56     ` [External] : " Drew Adams
2022-11-28 22:45       ` Emanuel Berg
2022-11-28 22:01     ` Heime
2022-11-28 22:24       ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-28 22:58         ` Emanuel Berg
2022-11-30 14:10           ` tomas
2022-11-30 16:12             ` Emanuel Berg
2022-11-28 22:46       ` Emanuel Berg
2022-11-28 22:50       ` Emanuel Berg
2022-11-29  5:23       ` tomas
2022-11-29  5:32         ` Emanuel Berg
2022-11-29  7:56         ` Heime
2022-11-29  8:33           ` Marcin Borkowski
2022-11-29 10:00             ` Emanuel Berg
2022-11-29 10:05               ` Emanuel Berg
2022-11-29 10:15             ` Heime
2022-11-29  8:38           ` tomas
2022-11-29  9:54           ` Emanuel Berg
2022-11-29  8:17         ` Marcin Borkowski
2022-11-29  8:44           ` tomas
2022-11-29 12:08             ` Dr Rainer Woitok
2022-11-29 19:54               ` Of cars and mice [was: Easy to add with push but not to the end of a list] tomas
2022-11-30  1:17                 ` Emanuel Berg
2022-11-30  1:13               ` Easy to add with push but not to the end of a list Emanuel Berg
2022-11-28 19:59 ` Emanuel Berg
2022-11-28 21:56   ` [External] : " Drew Adams
2022-11-28 22:18     ` Heime
2022-11-28 22:41       ` Drew Adams
2022-11-29 11:17   ` Dr Rainer Woitok
2022-11-30 17:10 ` Michael Heerdegen
2022-11-30 18:17   ` [External] : " Drew Adams
2022-11-30 19:30   ` Emanuel Berg
2022-12-01 15:11     ` Michael Heerdegen
2022-12-01 17:25       ` Emanuel Berg
2022-12-03 21:29         ` Michael Heerdegen
2022-12-05 23:35           ` Emanuel Berg
2022-12-06  1:36             ` Michael Heerdegen
2022-12-06  1:43               ` Emanuel Berg
2022-12-06  2:17                 ` Michael Heerdegen
2022-12-06  2:40                   ` Emanuel Berg
2022-12-06 13:56                     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-06 14:45                     ` Michael Heerdegen
2022-12-06  2:52                   ` Emanuel Berg
2022-12-06 17:22                     ` Michael Heerdegen
2022-12-06 22:30                       ` Emanuel Berg [this message]
2022-12-08 23:15                         ` Michael Heerdegen
2022-12-28 23:52                           ` Emanuel Berg
2022-12-31 16:57                             ` Michael Heerdegen
2022-12-31 22:09                               ` Emanuel Berg
2023-01-01 12:16                                 ` Michael Heerdegen
2023-01-08  4:40                                   ` Emanuel Berg
2023-01-09  6:32                                     ` Emanuel Berg
2023-01-14 12:05                                       ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmcwcghm.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).