Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:06:00+00:00 2026-06-01T00:06:00+00:00

I’m writing an elisp module that requires an external text file. For the curious,

  • 0

I’m writing an elisp module that requires an external text file.

For the curious, the module integrates the interactive JS REPL for Cscript.exe with shell mode in emacs.
It allows me to run an interactive javascript shell in emacs, on Windows.

This was motivated by js-comint.el, but is a separate implementation dependent upon Windows and cscript.exe.

It’s currently working, but there are two distinct files: the .el file and the .js file. I’d prefer to have just one file.

The question I have is this: how can I package the external .js file which is a pre-requisite for this thing, into the .el file, so that I can have a one-file install?

I imagine I could just define a string variable with the (maybe minified) js file and insert that into the .el module. I suppose there will be a few string-escapement issues but this will work. Is that the best way? Any other suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:06:01+00:00Added an answer on June 1, 2026 at 12:06 am

    ok, I didn’t find a better way to do this. But I did decide that embedding the Javascript code into the elisp module as a string… worked pretty well.

    To make it happen, I wrote a short elisp function, which creates a new elisp module.
    It picks a new name based on the old name – xxxx-bundle.el instead of xxxx.el . Then it writes the content from the original .el file into a file with the new name. Then it writes a simple setq statement into the same file; the entire Javascript program is the literal string value in that statement. The thing that makes the setq easy is the pp-to-string function in elisp, which escapes all the Javascript code into a literal string suitable for use in emacs.

    The fn to generate the bundle Looks like this:

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

    The helper fn to minimize the contents just collapses whitespace and eliminates consecutive newlines, that sort of thing.

    The resulting .el file can then reference the variable, jsshell-js-src, which contains the minimized Javascript source. It looks like this:

    enter image description here

    I’m posting this here because I think the approach would probably be useful in other modules as well – anything that needs to bundle a separate data file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.