all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: how to get list of vectors with value from file content...
Date: Thu, 2 Sep 2010 03:16:02 -0700 (PDT)	[thread overview]
Message-ID: <90f84f94-37e7-4dc7-ade3-5ef12ad6ce63@b4g2000pra.googlegroups.com> (raw)

a pure academic question on emacs lisp.

basically, i want to set a variable who's value is a list of vectors,
each vector is a pair.
Like this form:

(setq findReplacePairsList (list [A B] [A B] [A B]) )

the element of the vector are strings, each are read from a file
content.
(i have 6 files, corresponds to the 3 vectors above.)

i have 2 questions.

(1) here's how i get the file content for each file:

  (find-file "findreplace_01_A.txt" ) (setq findreplace_01_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_01_B.txt" ) (setq findreplace_01_B (buffer-
string)) (kill-buffer )
  (find-file "findreplace_02_A.txt" ) (setq findreplace_02_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_02_B.txt" ) (setq findreplace_02_B (buffer-
string)) (kill-buffer )
  (find-file "findreplace_03_A.txt" ) (setq findreplace_03_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_03_B.txt" ) (setq findreplace_03_B (buffer-
string)) (kill-buffer )

seems a kludge to me. Is there a better way?

(2) elisp vector elements are not evaluated. So, i cannot simply write

(setq myPairList (list [A B] [A B] [A B]) )

where the A B are already variables.

i need to use aset.

Is there a better way to do what i want?

Here's the current form of my code, does the job but seems very silly.
Huge number of temp vars and intermeditate steps.

--------------------------------------------------

(defvar findReplacePairsList nil
 "A list of replacement pairs. Each element is a vector of 2 elements.
Each element is a string, from a file content.")

(let (
      findreplace_01_A
      findreplace_01_B
      findreplace_02_A
      findreplace_02_B
      findreplace_03_A
      findreplace_03_B
      fr1
      fr2
      fr3
      )
  (find-file "findreplace_01_A.txt" ) (setq findreplace_01_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_01_B.txt" ) (setq findreplace_01_B (buffer-
string)) (kill-buffer )
  (find-file "findreplace_02_A.txt" ) (setq findreplace_02_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_02_B.txt" ) (setq findreplace_02_B (buffer-
string)) (kill-buffer )
  (find-file "findreplace_03_A.txt" ) (setq findreplace_03_A (buffer-
string)) (kill-buffer )
  (find-file "findreplace_03_B.txt" ) (setq findreplace_03_B (buffer-
string)) (kill-buffer )

  (setq fr1 ["dummy" "dummy"] )
  (setq fr2 ["dummy" "dummy"] )
  (setq fr3 ["dummy" "dummy"] )

  (aset fr1 0 findreplace_01_A)
  (aset fr1 1 findreplace_01_B)
  (aset fr2 0 findreplace_02_A)
  (aset fr2 1 findreplace_02_B)
  (aset fr3 0 findreplace_03_A)
  (aset fr3 1 findreplace_03_B)

  (setq findReplacePairsList (list
                              fr1
                              fr2
                              fr3
                              ))
  )

thanks.

seems my second problem is solved if i have list of list instead of
list of vectors. With list of list, i can simply write

(setq findReplacePairsList
      (list
       (list findreplace_01_A findreplace_01_B)
       (list findreplace_02_A findreplace_02_B)
       (list findreplace_03_A findreplace_03_B)
       ))

 Xah ∑ http://xahlee.org/

             reply	other threads:[~2010-09-02 10:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-02 10:16 Xah Lee [this message]
2010-09-02 11:15 ` how to get list of vectors with value from file content Marc Mientki
2010-09-02 21:15   ` Xah Lee
2010-09-02 12:42 ` TheFlyingDutchman
2010-09-02 13:00 ` TheFlyingDutchman
2010-09-02 13:29 ` TheFlyingDutchman
2010-09-02 14:31   ` TheFlyingDutchman
2010-09-02 21:02     ` Xah Lee

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

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

  git send-email \
    --in-reply-to=90f84f94-37e7-4dc7-ade3-5ef12ad6ce63@b4g2000pra.googlegroups.com \
    --to=xahlee@gmail.com \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.