Scheme get last command in guile - scheme

Normally in a terminal (or any other command prompt I've previously used) I'll press the up key to get the last entered command. However, when doing that in the guile interpreter, I just get:
scheme#(guile-user) [1]> ^[[A
What is the easiest way to get the last entered-in command in guile?

Command-line REPLs are often feature-poor. For Guile, a better experience can be had by, for example, running under Geiser in emacs. This allows a running REPL in an emacs buffer, with much better control. As a long-term solution, I would suggest learning how to do something like this.
There is a bit of a learning curve to get productive in emacs (not as much as people often seem to fear, though). Fortunately, Guile provides a solution for those who wish to stick with the regular Guile REPL.
While it is not enabled by default, Guile can make use of the GNU Readline library. This allows navigation of the REPL expression history via the up- and down-arrow keys. To enable this feature from the REPL, enter:
scheme#(guile-user)> (use-modules (ice-9 readline))
scheme#(guile-user)> (activate-readline)
When Guile is started in interactive mode, it first loads the .guile init file from the users home directory. You can take advantage of this by adding the above two lines to the .guile file (create a new .guile file for this purpose if one does not already exist):
;;; Guile Scheme Init File
;; Activate Readline
;; allows navigation of expression history in REPL
(use-modules (ice-9 readline))
(activate-readline)
After updating the .guile file, whenever Guile is run in interactive mode, you will automatically have the Readline functionality.

Related

Chicken Scheme interpreter arrow key not working

I have installed Chicken Scheme on WSL debain Linux.
I can run chicken Scheme interpreter from command line.
but arrow key just not work.
up arrow ^[[A
down arrow ^[[B
here is a screen shot
This is a FAQ. Basically, CHICKEN tries to be relatively minimalistic out of the box, so there's no line editing feature bundled with the core distribution.
You probably want to install the breadline egg and set up your .csirc to load it (see the example).
Alternatively, use rlwrap, which can add line editing capability to any program which lacks it.

Displaying images in an Emacs process running within iTerm2

I want to display inline images in a Emacs process running in iTerm2. Here is a demonstration of what I'm expecting, using imgcat (a iTerm2 shell integration utility).
To begin with, I executed the following code within an *eshell* buffer. The rationale is that if this works out, I can simply setup a separate window dedicated to running eshell, and then update the image with a hook.
imgcat -u https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png
However, all I got is a bunch of base64 characters, even if I have set TERM to xterm-256color (was dumb).
The reason I chose eshell instead of shell, term, ansi-term or anything else is that it's implemented in Emacs Lisp, so it should be the most extensible one. On the other hand, using other terminal emulators is also OK if you find them more handy.

How to install new modes in emacs 23 on OS X?

I just downloaded the Haskell and J modes off of SourceForge, and I'm having trouble figuring out how to make them interface with emacs 23. Google searches yield detailed instructions for emacs 22, but it looks like changes have been made that make it hard to figure out where I'm supposed to stick the source files. The internal documentation seems to assume more experience with emacs internals than I currently have, and the problem has resisted solution for several days. Does anyone know how to get these modes up and running?
EDIT: Thanks to Untwisted for supplying the answer. Ultimately, my real problems were these:
1) I didn't know that .emacs was invisible to the OSX finder but was visible through the terminal.
2) It never occurred to me that I could modify .emacs while an instance of emacs was running.
Once I realized that those were my problems, I used C-x C-f to open ~/.emacs, copied the text of Untwisted's fix, and modified it to reflect my personal file paths. After that, everything worked.
Basically you need to put the .el files somewhere (I keep mine in ~/.emacs_extras/haskell-mode/ ), and edit your ~/.emacs file to load Haskell mode when appropriate. Example of a ~/.emacs file:
(load "~/.emacs_addons/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
That should make Haskell mode work. For more details, other options, etc: http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs

How can I simply "run" lisp files

Python
When I learned Python I installed it on windows with a nice gui installer and all .py files would automatically run in python, from the command line or explorer.
I found this very intuitive and easy, because I could instantly make plain text files and run them.
Lisp
I'm starting to learn lisp and have decided (from reviews) that SBCL is not a bad lisp implementation.
Is there a way to setup SBCL to run .lisp files as easily as with Python?
Are there other lisp implementations that have this?
Executables
SBCL can save executable images, as Greg Harman mentions (see the :EXECUTABLE keyword): http://www.sbcl.org/manual/index.html#Saving-a-Core-Image
Scripts
Lisp files can be executed as scripts, see: http://www.sbcl.org/manual/#Shebang-Scripts
Command Line Options
SBCL has command line options to evaluate/load lisp code on start: http://www.sbcl.org/manual/#Command-Line-Options
SLIME
SLIME is an Emacs interface for Common Lisp. One can use SBCL via SLIME from within Emacs. Many people prefer Emacs Lisp listeners over typical shell interfaces.
Most Common Lisp implementations have similar capabilities. For details consult their manual or ask here for specific implementations.
A few minutes ago someone replied with an answer nearing what I was looking for.
The reply linked to http://www.sbcl.org/manual/Shebang-Scripts.html which was a great help in figuring out my solution. Whoever it was shouldn't have removed their answer as I was about to mark it as correct ;)
My final solution was to create a batch script that is linked through normal program file association as the program to open .lisp files (Right click file->Properties->Opens With->[Change]).
#ECHO OFF
"C:\Program Files\Steel Bank Common Lisp\1.0.37\sbcl.exe" --script %1
When you double click files in explorer it executes them and when you run them in the command line it does the same.
SBCL can save an executable core image via sb-ext:save-lisp-and-die
If you have already downloaded and installed the SBCL interpreter, then in order to run your programs by simply entering them into the command line you need to add the location of the interpreter to your system PATH variable, so that your machine knows where to look.
This is true for any language. What the Python installer did was add the location of the Python interpreter to your PATH environment variable.
Depending on your platform, do a quick Google search on how to set environment variables.

how to setup common emacs environment for windows and linux computers?

I use emacs for text editing and script development. I use both windows and ubuntu emacs 23.1 distribution.
Now I want both my linux and windows environment to replicate the same environment.
I will save my emacs environment here https://bitbucket.org/krish/emacs/, so file synchronisation will not be problem.
I don't have any different resolution settings for both the envionment
I use aspell which need specific path and different installer in windows and linux
I use perl, python, ruby mode along with other html, css, js-2 and nxml
Are there any specific way/advise to manage the common emacs environment between windows and linux? especially how to manage the program path?
There's no real straightforward way. You'd have to isolate most (if not all) your platform specific routines into different files and load them up after checking for platform.
Steve Yegge has some information on how he manages his .emacs file along with the actual code itself over here. One of his points is how he keeps is cross platform hackable. It's worth a read.
I have a very similar setup to yours (Emacs 22.1, 22.2, 23.1 on various Linux versions with and without X and Windows with and without Cygwin). My setup includes ELPA, auctex, emacsw32, CEDET, JDEE, nxml and various other elisp packages. I do not use whatever comes with the system but keep copies of those packages in subversion.
Majority of setup just works in all environments. Regarding paths, I think that majority of stuff one wants to call, such as aspell, can be called outside Emacs from command line too, so it`s worth putting them in $PATH thus avoiding having to specify full paths in Emacs.
For other things, I do
In .emacs:
; Load system-specific library and setup system-specific things that
; must be setup before main setup
(cond ((eq system-type 'windows-nt) (load-library "ntemacs-cygwin"))
((eq system-type 'gnu/linux) (load-library "linux"))
(t (load-library "default")))
(system-specific-setup)
; Set up things as usually, no more system-type queries.
Where in linux.el:
(defun system-specific-setup()
; Default font
(add-to-list
'default-frame-alist
'(font . "-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1"))
(setq my-frame-width 95)
(setq my-frame-height 56)
; Not much else
)
And in ntemacs-cygwin.el:
(defun system-specific-setup()
;; EmacsW32
(setq emacsw32-root (concat private-elisp-lib "EmacsW32"))
(add-to-load-path emacsw32-root)
;; Work around XSymbol initialization bug
;; ("C:\\ImageMagick\\convert" instead of system $PATH? Seriously?)
(setq x-symbol-image-convert-program "convert")
;; etcetera...
)
Basically it is a matter of setting things up on one system, trying them on another and factoring out whatever needs to be different to the system-specific-setup.
And the Steve Yegge´s article in Noufal´s answer is a very good one.
You can look to my emacs configs, where operations for differnet machines are splitted into separate files

Resources