mit-scheme vim slimv: " read-error: no dispatch function defined for #\F" - lisp

It's a very easy scheme function
(define member?
(lambda (a lat)
(cond
((null? lat) #f)
(else (or (eq? (car lat) a)
(member? a (cdr lat))
))
)
)
)
However, when I pressed ,d or ,F in vim to run this function, there is an error
/home/oo/tmp/t.scm:64 read-error: no dispatch function defined for
#\F
Line: 4, Column: 21, File-Position: 64
Stream: #<SB-SYS:FD-STREAM for "file /home/oo/tmp/t.scm" {AC84DA9}>

Chris already pointed out that you tried to use Scheme code with a Common Lisp swank server.
You need to run a Scheme swank server (e.g. swank-mit-scheme.scm, also included in Slimv).
Normally Slimv should autodetect MIT scheme on Linux without any tweaking in the .vimrc. For the autodetection to work properly you need MIT Scheme installed and the scheme command be available.
I suggest that you remove any Slimv related settings from your .vimrc. Then load the .scm in Vim and type this command:
:echo SlimvSwankCommand()
If Scheme was autodetected then this should print the command that runs the Scheme swank server (search for swank-mit-scheme.scm in the output). If the autodetection was unsuccessful then either you don't have the scheme command or Slimv did not find swank-mit-scheme.scm. In this case you need to tell Slimv the command to run the Scheme swank server. You can do in by adding a similar command to your .vimrc:
let g:slimv_swank_cmd = '! xterm -e scheme --load /your-path-to/slime/contrib/swank-mit-scheme.scm &'
But do this only if autodetection fails. If you need some more assistance, please feel free to contact me, I'm the author of Slimv.

Related

Org-mode maxima code-blocks incorrect syntax

I'm new to Emacs, coming from Vim, using Spacemacs on Windows 10 atm. My problem is that when I try to evaluate maxima code blocks in emacs, for example:
#+begin_src maxima
a: 1+1;
print(a);
#+end_src
I get the following error:
#+RESULTS:
"incorrect syntax: / is not a prefix operator"
I think it might be because of how windows is handling the path. I found the following code online and replaced it in "ob-maxima.el" but it didn't help:
(let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
(in-file (org-babel-temp-file "maxima-" ".max"))
(cmd (format "%s --very-quiet -r \"batchload(\\\"%s\\\")$\" %s"
org-babel-maxima-command in-file cmdline)))
Thanks a lot for you help, much appreciated!
Edit 2020.03.26---------------------
I got it working using "choco install maxima", now it executes properly.

In emacs, what is the best way to run an external program in another window that can be closed by a single key command after executing program exits?

I have some elisp that runs an external 'npm' command.
(defun npm-mode-npm-run ()
"Run the 'npm run' command on a project script."
(interactive)
(let ((command
(completing-read
"Run command: " (npm-mode--get-project-scripts))))
(message "Running npm script: %s" command)
(switch-to-buffer npm-mode--buffer-name command)
(erase-buffer)
(ansi-term (getenv "SHELL") "npm-mode-npm-run")
(comint-send-string "*npm-mode-npm-run*" (format "npm run-script %s\n" command))))
While it does the job, when execution completes the user is left in a buffer that must be killed, and that requires additional confirmation to kill the process.
What I would like is once the program exits, I could press the 'q' key to do all of that, leaving the user in their original buffer.
Is their a good example of how to do this best for modern emacs that I could refer to, or any other specific docs that may be helpful?
Many thanks in advance!
As #jpkotta said, compile is a good option. You can bury the buffer easily, send a TERM signal to the underlying process, etc. Also, you get for free error parsing (syntax coloring + the ability to jump to the offending line) for many languages.
Here is an example of how I use it (in this case to do a quick run of any script I am editing):
(defun juanleon/execute-buffer ()
(interactive)
(let ((compile-command nil))
(compile buffer-file-name)))
Easy to modify to adapt to your code. The let is for avoid adding stuff to compile history (since I use compile a lot for regular compilation, and history is useful).

Opening HTML file with nXhtml produces error with flymake

When I open an HTML file with emacs (and nXhtml,) I get the following error from flymake:
Error (flymake): Flymake: Failed to launch syntax check process 'xml'
with args (val
/home/ABC/Downloads/capitals_flymake.html):
Searching for program: no such file or directory, xml. Flymake will be
switched OFF
I assume this means that I need to have a program installed that can be run at the command line with xml. However, I have not been able to find out what this program is in the documentation.
I am also currently using the following gist (with a modification suggested by one of the commenters to change equal to >=) to disable the Mumamo buffer filenames warning in my .emacs:
;; Workaround the annoying warnings:
;; Warning (mumamo-per-buffer-local-vars):
;; Already 'permanent-local t: buffer-file-name
(when
(and
(>= emacs-major-version 24)
(>= emacs-minor-version 2))
(eval-after-load "mumamo"
'(setq mumamo-per-buffer-local-vars
(delq 'buffer-file-name mumamo-per-buffer-local-vars))))
But, I am not sure if that is relevant.
How can I get flymake to work with nXhtml? I am currently on GNU Emacs 24.3.1.
I have this in my .emacs for live validating of XML and HTML, see if this would help.
(defun flymake-xml-init ()
(list "xmllint"
(list "--valid"
(flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))))
(defun flymake-html-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "tidy" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.html$" flymake-html-init))
Also, re xml executable: it might be this one http://packages.ubuntu.com/quantal/amd64/xml2/filelist from how it looks... also you can try apt-file /usr/bin/xml (I'm not sure if apt-file is installed by default, if not, then apt-get install apt-file). Also, maybe this would help: http://www.emacswiki.org/emacs/FlyMake . I couldn't find any setting particular to nXhtml that does something to flymake.
The default program that flymake is told to use (xml) isn't installed on your computer, or its location isn't in your path. You need to tell flymake to use a different syntax checker just like #wvxvw said (see their answer for the code).
However, when you change the syntax checker, you may also need to tell flymake how that new checker will output error messages or else flymake won't know how to read the checker's output.
If your new checker program has an exit code other than 0 (which normally indicates an error) AND flymake didn't see anything that it recognized as error text, then flymake will throw a CFGERR and turn off.
From the flymake manual:
The following errors cause a warning message and switch flymake mode OFF for the buffer.
CFGERR : Syntax check process returned nonzero exit code, but no errors/warnings were reported. This indicates a possible configuration error (for example, no suitable error message patterns for the syntax check tool)
So what you need to do is tell flymake how to interpret the errors from your updated parser. You do this by adding a regex expression to a list that flymake will check against the output of your parser. Add something like this to your .emacs file:
(add-to-list
`flymake-err-line-patterns
'("at line \\([0-9]+\\) of \"\\([^ \n]+\\)\"$" 2 1 nil))
This will then tell flymake that if your parser generates output that matches the regex ("at line \\([0-9]+\\) of \"\\([^ \n]+\\)\"$") to identify it as an error message. The 2 1 nil tell flymake which group in the regex represents the file, line number, and column number, respectively. If the error message doesn't provide that information, then set that parameter to nil. In this example, the error message only identifies the file (second group) and line number (first group), so the column is set to nil.

emacs lisp will not start

I am trying to setup the slime mode in emacs for using common lisp. When I attemp to start slime with M-x slime I get an error message saying:
process inferior-lisp not running.
So, I checked the value of the variable inferior-lisp-program which turned out to be "/opt/sbcl/bin/sbcl". sbcl is an acronym for an implementation of common lisp known as steel bank common lisp. Note that this variable is defined in file slime.el. As I do not have sbcl (the previous directory does not even exist on my machine) installed on my machine (which runs os x 10.8.3) this will not work.
I have the clisp implementation which is located in the directory: /opt/local/bin/. I tried to change the value of the variable inferior-lisp-program by:
(setq inferior-lisp-program '/opt/local/bin/clisp/)
However, this did not work and I do not know what else to try.
How can I get inferior-lisp to run and hence get slime to work?
EDIT: Here is some extra information I believe that could be helpful. If I try to just start common lisp in emacs by executing M-x run-lisp I get the following output from emacs:
(progn (load "/Users/s2s2/.emacs.d/slime/swank-loader.lisp" :verbose t) (funcall \
(read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-s\
erver") "/var/folders/wf/yjgymt8j14v2tqwjnny68wq00000gn/T/slime.28222"))
Can't exec program: /opt/sbcl/bin/sbcl
Process inferior-lisp exited abnormally with code 1
Can't exec program: /opt/sbcl/bin/sbcl
Process inferior-lisp exited abnormally with code 1
Hope this helps! All help is greatly appreciated!
The variable slime-lisp-implementations has higher priority than inferior-lisp-program for slime if set; try this instead (adjust parameters accordingly):
(setq slime-lisp-implementations
'((clisp ("/opt/local/bin/clisp" "-q -I"))
(sbcl ("/usr/local/bin/sbcl") :coding-system utf-8-unix)))
The first thing to try is to run the command in a regular shell window - just type or copy and paste the executable path there and see what bash tells you:
$ sbcl < /dev/null
bash: sbcl: command not found
$ clisp < /dev/null
<<clisp splash screen>>
$ which clisp
/usr/bin/clisp
Once you find out what the correct executable is, you set inferior-lisp to it:
(setq inferior-lisp "/usr/bin/clisp")
Notes:
It should be a string, not a symbol, so you need the quotes ".
It should point to a file, not a directory, so your trailing slash / is wrong

Remote ssh connection from within Emacs

Several questions, including this one, discuss aspects relating to ssh connections from within Emacs. I haven't found an answer to my question though: How can I ssh into a remote machine from within Emacs?
I do not wish to edit a file on the remote machine from within Emacs. I am aware of M-x shell which opens a shell on my local machine and I am aware of using TRAMP to edit a file over ssh on the remote machine. However, neither of these relate to this question.
(Instead of voting to close, maybe migrate the question to another site.)
Edit: Related discussion here.
Firstly, I am unaware of a native elisp ssh client (and do not imagine there is a great deal of motivation for writing one), so you will certainly need to interact with an external ssh client process.
As you wish to use ssh interactively, the ssh process requires a terminal on the local side of the connection.
The question therefore becomes: Does Emacs implement a terminal to which an ssh process can be attached?
The answer is: yes -- term.el provides a robust terminal implementation, through which ssh can be run directly, without the requirement for a shell.
If you run M-x term RET you will be prompted for a program. (It defaults to a shell, but that is certainly not the only type of process you can run.)
For reasons unknown, the interactive term (and ansi-term) functions do not support passing arguments to the specified program, which renders them less useful if you wished to run something like ssh user#host. You could instead specify a script which handled the arguments, but we can manage that in elisp as well:
The term function is actually a simple wrapper which calls make-term to start the program and then sets the appropriate modes. As make-term does accept program arguments, it is quite straightforward to copy-and-modify the definition of term to suit your own purposes.
Here is a very simple implementation:
(defun my-ssh (user host port)
"Connect to a remote host by SSH."
(interactive "sUser: \nsHost: \nsPort (default 22): ")
(let* ((port (if (equal port "") "22" port))
(switches (list host "-l" user "-p" port)))
(set-buffer (apply 'make-term "ssh" "ssh" nil switches))
(term-mode)
(term-char-mode)
(switch-to-buffer "*ssh*")))
or perhaps this is preferable:
(defun my-ssh (args)
"Connect to a remote host by SSH."
(interactive "sssh ")
(let ((switches (split-string-and-unquote args)))
(set-buffer (apply 'make-term "ssh" "ssh" nil switches))
(term-mode)
(term-char-mode)
(switch-to-buffer "*ssh*")))
Obviously there is scope for improvements, but I think that's fairly useful as-is.
You should ensure that you are familiar with the quirks of term-mode. See:
M-: (info "(emacs) Terminal emulator") RET
M-: (info "(emacs) Terminal Mode") RET
C-hf term-mode RET
It turns out, there is what you want:
(setq rlogin-program "ssh")
(setq rlogin-process-connection-type t)
and then M-x rlogin RET <myhost> RET will do that.
Maybe ssh.el is what you are looking for. The ssh command provides a single-step way to create remote shells in Emacs via ssh, including specifying the user name in a natural way, and enabling tramp directory tracking if desired.
I'm not sure I understand. Open up M-x ansi-term and run ssh user#host there?