ठीक है, मुझे ऐसा करने का बेहतर तरीका नहीं मिला। लेकिन मैंने फैसला किया कि एक स्ट्रिंग के रूप में elisp मॉड्यूल में जावास्क्रिप्ट कोड एम्बेड करना ... बहुत अच्छी तरह से काम किया।
ऐसा करने के लिए, मैंने एक छोटा elisp फ़ंक्शन लिखा, जो एक नया elisp मॉड्यूल बनाता है। यह xxxx.el के बजाय पुराने नाम - xxxx-bundle.el पर आधारित एक नया नाम चुनता है। फिर यह मूल .el फ़ाइल से सामग्री को नए नाम के साथ एक फ़ाइल में लिखता है। फिर यह एक ही फाइल में एक साधारण setq
कथन लिखता है; संपूर्ण जावास्क्रिप्ट प्रोग्राम उस कथन में शाब्दिक स्ट्रिंग मान है। setq
आसान है जो pp-to-string
एलीस्प में फ़ंक्शन है, जो सभी जावास्क्रिप्ट कोड को emacs में उपयोग के लिए उपयुक्त एक शाब्दिक स्ट्रिंग में से बचता है।
fn बंडल उत्पन्न करने के लिए इस तरह लग रहा है:
(defun jsshell-produce-bundle (&optional jsshell-el bundle-el jsshell-js)
"Produce a new .el file, which contains all the jsshell.el
function and also embeds the jsshell.js source as a string. The
resulting .el file will then be suitable for a one-file
distribution of JSShell.
JSShell depends on two pieces: jsshell.el and jsshell.js. Rather
than distributing and installing two distinct files, the bundle
embeds the .js file into the .el file, for a one-file
distribution option. This function produces that one file.
Most people will never need to use this function. It's useful only
after modifying either the original jsshell.el or the jsshell.js file,
when you want to produce a new distributable bundle. In other words, it's
useful for the developer of jsshell.el.
"
(let ((jsshell-el (or jsshell-el
(concat (file-name-directory jsshell--load-path) "jsshell.el")
"jsshell.el")))
(let ((bundle-el (or bundle-el
(concat (file-name-directory jsshell-el) "jsshell-bundle.el")))
(jsshell-js (or jsshell-js
(and jsshell-js-tmpf
(file-readable-p jsshell-js-tmpf)
jsshell-js-tmpf)
jsshell-location-of-jsshell-js ;; orig dev wkstation
(concat (file-name-directory jsshell-el) "jsshell.js")))
jssrc)
(with-temp-file bundle-el
(insert (concat
";;; "
(file-name-nondirectory bundle-el)
" -- JSShell generated bundle\n"))
(insert (concat ";;\n;; generated " (current-time-string) "\n;;\n\n"))
(insert-file-contents jsshell-el)
(goto-char (point-max))
(insert "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n")
(insert ";; this is the embedded Javascript code for the JS REPL\n\n")
(setq jssrc (jsshell--minimized-js-contents jsshell-js))
(goto-char (point-max))
(insert (concat "(setq jsshell-js-src "
(pp-to-string jssrc)
")\n"
"\n(provide '"
(file-name-sans-extension (file-name-nondirectory bundle-el))
")\n"
"\n;;; "
(file-name-nondirectory bundle-el)
" ends\n"))))))
सामग्री को कम करने के सहायक fn सिर्फ खाली स्थान के गिर और लगातार नई-पंक्तियों, बात की इस प्रकार की दूर करता है।
परिणामस्वरूप .el फ़ाइल वैरिएबल, jsshell-js-src
का संदर्भ दे सकती है, जिसमें कम से कम जावास्क्रिप्ट स्रोत होता है। यह इस तरह दिखता है:
मैं क्योंकि मुझे लगता है कि दृष्टिकोण शायद के रूप में अच्छी अन्य मॉड्यूल में उपयोगी होगा इस यहाँ पोस्टिंग कर रहा हूँ - कुछ भी एक अलग डेटा फ़ाइल बंडल करने की जरूरत है कि।