0

I am new to Emacs and struggling to learn it.

How to get rid of the line Emacs: command not found?

   ~/Documents $ eshell-source-file hello.el
   Emacs: command not found
   Hello World
   ~/Documents $ 
  • You might want to take a look at this: gnu.org/software/emacs/manual/html_node/emacs/… – DoMiNeLa10 Jul 21 '17 at 14:49
  • You tagged the question with eshell, but your question says nothing about eshell. Show or describe the relevant parts of your init ifile. – Drew Jul 21 '17 at 15:59
  • 1
    For me, part of learning Emacs has improving my skill in regarding reading the manuals and developing the habit of reading them. I've been at it for several years and think I am getting better, but I still have a long way to go. – ben rudgers Jul 21 '17 at 19:03
  • 1
    Possible duplicate of Command to Run (Eval) "Hello World" in ELISP on Eshell? – ben rudgers Jul 21 '17 at 22:04
  • 1
    Please don't edit questions to ask something different. – ben rudgers Jul 21 '17 at 23:05
2

Put (just) this in "hello.el":

(prin1 "Hello, world!")

Then from the eshell prompt:

~/temp $ eshell-source-file "hello.el"
Hello, world!
~/temp $

I may be misunderstanding your general intent but from your questions, it seems as though you're trying to "run programs" the way you would run C programs - write a source file hello.c, compile it, run it at the command line, it prints "Hello, world!" and exits, and you get a command prompt again. If you're trying to learn elisp using ielm or eshell, you're working with an interpreter (REPL) - programs are built interactively. So if you want to print "Hello world!" you don't need to make a separate source file; just do this:

~/temp $ (prin1 "hello, world!")
hello, world!

But you can also define functions, apply them, and so on:

~/temp $ (defun f (x) (* x x))
f
~/temp $ (f 17)
289
~/temp $ 

You don't need to build a separate source file just to load it into eshell: Just build your program line-by-line in eshell or ielm.

As other people have suggested, in emacs, do C-h-i to bring up info, and check out the documentation there. Good luck!

  • @bikenaga, Thank you, Great answer! – user16438 Aug 4 '17 at 17:28
2

A couple of options:

  1. eshell can be configured to route specific commands (and subcommands) to the regular terminal. See the documentation for visual commands. Whether or not this is worth the trouble, depends on how much getting a tool to perform in a way it was not really designed to perform is worth.

  2. A good tool for interactive sessions with elisp is interactive elisp mode which is invoked using M-x ielm. It provides a full elisp REPL. Files can be loaded using (load name-of-file).

  3. The *scratch* buffer (or any other elisp buffer) is another way of working with elisp files interactively. Using eval-print-last-sexp will print the results of the sexp directly in the buffer. Like any Emacs function eval-print-last-sexp can have any keybinding the user wishes assigned.

  • Hello Ben: I tried all the 3 options: (1) Being a total new person, it is too heavy for me. (2) it is not working (3) (a) It prints the result directly to buffer area, (b) Prints the last message call only. Thanks for your effort. – user16438 Jul 21 '17 at 20:54
  • @user16438 In what ways is ielm not working? I can see why configuring eshell using visual commands is to heavy for a new user because eshell is not really designed to do what you are trying to do anyway. For me, part of being a new user has been learning new ways of doing things and usually those new ways of doing things is not the way "I want". For me, wanting to do things in a 'bad' or 'wrong' way is part of being a new user. As I said, I've spent years learning Emacs and all that learning has been learning to do things in new ways. – ben rudgers Jul 21 '17 at 21:30
  • Method (2): I did: M-x ielm It took to ELISP> Then I entered ELISP> load hello.el it displays *** IELM error *** More than one sexp in input – user16438 Jul 21 '17 at 21:57
  • @user16438 ielm requires elisp code. So the it needs to be (load "hello.el") or a more precise path if the file hello.el is not in the current working directory. For example, entering (+ 3 4) at the ielm prompt will return the value 7. For what it is worth, my favorite elisp tutorial is dantorop.info/project/emacs-animation and I recommend working through a few tutorials because it is worth the effort for a tool that will be used for many years. – ben rudgers Jul 21 '17 at 22:01
  • @user16438 see this question for a more direct solution emacs.stackexchange.com/questions/34239/… – ben rudgers Jul 21 '17 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.