all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to get list of vectors with value from file content...
@ 2010-09-02 10:16 Xah Lee
  2010-09-02 11:15 ` Marc Mientki
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Xah Lee @ 2010-09-02 10:16 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-09-02 21:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-02 10:16 how to get list of vectors with value from file content Xah Lee
2010-09-02 11:15 ` 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

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.