Space character inside an argument (emacs lisp) - emacs

In windows, I set the variable inferior-lisp-program to be (shell-quote-argument "D:/Program Files/ccl/wx86cl.exe").
But when I run inferior lisp with the command run-lisp, emacs responds:
Searching for program: no such file or directory, "D:/Program
It seemed that emacs treats "D:/Program Files/ccl/wx86cl.exe" as two arguments "D:/Program and Files/ccl/wx86cl.exe" separated by a space character.
How can I make emacs treat "D:/Program Files/ccl/wx86cl.exe" as a whole?

Try using the old "Progra~1" compatibility name for "Program Files". So,
(setq inferior-lisp-program "D:/Progra~1/ccl/wx86cl.exe")

Related

emacs init file on MS Windows

There's a huge literature on the topic, but, nevertheless, I cannot get this done.
My ultimate goal is to work with fstar on Microsoft Windows.
C-x C-f resolves ~ as C:/Users/myname which is in line with my HOME environment variable in the Environmental variables Windows section.
(expand-file-name user-emacs-directory), as described here yields, C:/Users/myname/.emacs.d/
In C:/Users/myname/.emacs.d/ I have placed .emacs.el and init.el with the suggested script:
(require 'package) (add-to-list 'package-archives '("melpa" .
"http://melpa.org/packages/") t) (package-initialize)
However M-x returns undefined, no matter if I start Emacs with or without the -q flag (see here). My "Messages" buffer is empty".
A couple of things you could try:
Check the value of the variable user-init-file (use C-h v). That should tell you if Emacs loads the file you want it to load. If you started Emacs with the -q option, the value of this variable should be nil.
The error M-x is undefined can be caused by rebinding the Escape key. (That's because pressing a key while holding down the "Meta" key is equivalent to first pressing Escape and then the key in question.) Is there something in the init file that might cause this to happen?
Try starting Emacs with -Q instead of -q. This makes Emacs skip "site-wide" init files. I can't really think of a reason why your system would have any of those, but it might be worth ruling this out.
You could edit your question and include your entire init file (surround it with ``` on a line by itself), so we could have a look.

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

Emacs elisp expand-file-name behaviour on windows

I encountered strange behaviour of expand-file-name function on windows during installation of last cedet using el-get. The issue is related to generation of autoloads.
The autoload.el on last emacs 24.1.50 contains the following function:
(defun autoload-generated-file ()
(expand-file-name generated-autoload-file
;; File-local settings of generated-autoload-file should
;; be interpreted relative to the file's location,
;; of course.
(if (not (local-variable-p 'generated-autoload-file))
(expand-file-name "lisp" source-directory))))
In my case generated-autoload-file is:
"/home/ngulyamov/.emacs.d/el-get/cedet/lisp/cedet/srecode/loaddefs.el"
as I have $HOME$ environment variable pointed to C:/home/ngulyamov. In this case above function returns:
"d:/home/ngulyamov/.emacs.d/el-get/cedet/lisp/cedet/srecode/loaddefs.el"
due to source-directory contains:
"d:/devel/emacs/emacs-bzr/trunk_jenkins/".
As you can see it changes drive letter from C: to D:.
At the same time on emacs 23.3 this function returns semi-correct value as source-directory contains value:
"c:/Users/Sean/Downloads/emacs-23.3/".
According to expand-file-name function description:
(expand-file-name NAME &optional DEFAULT-DIRECTORY)
Convert filename NAME to absolute, and canonicalize it.
Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative
(does not start with slash or tilde); if DEFAULT-DIRECTORY is nil or missing,
the current buffer's value of `default-directory' is used.
The paths on Windows never start from slash or tilde.
Now my questions:
1. Does expand-file-name function behaviour correct on Windows?
2. Why source-directory contains value of developers paths?
Could we consider expand-file-name as buggy on windows? Or it is just wrongly used in autoload.el?
Thank you in advance.
Finally I figured out the reason. The issue is coming from Makefile of cedet which uses $(abspath) functionality of make 3.8. The cygwin version of make in this case returns UNIX way of path, i.e. /home/ngulyamov/... which then replaces by source-directory root in autoload by d:/home/ngulyamov/.... The GnuWin32 version of make works correctly but by strange reason I have the following issue:
C:\home\ngulyamov\.emacs.d\el-get\cedet>\gnuwin32\bin\make all
Removing loaddefs.el files from subprojects.
Generating autoloads.
make[1]: Entering directory `C:/home/ngulyamov/.emacs.d/el-get/cedet/lisp/cedet'
> autoloads
Wrote C:/home/ngulyamov/.emacs.d/el-get/cedet/lisp/cedet/loaddefs.el
Loading vc-bzr...
Generating autoloads for C:/home/ngulyamov/.emacs.d/el-get/cedet/lisp/cedet/cedet-android.el...
Memory exhausted--use C-x s then exit and restart Emacs
make[1]: *** [autoloads] Error 127
So dirty fix is specifying source-directory in autoload.el itself like:
(setq-default source-directory "C:/home/ngulyamov/.emacs.d/")
Anyway, why source-directory is pointing to developer's computer path is remaining open.

I want to run the cygwin bash shell from native windows emacs app

I have followed instructions from How can I run Cygwin Bash Shell from within Emacs? this question and I have gone further and added the (setq explicit-bash-args '("--login" "-i")) command, however emacs continues to only display the dos prompt when I type M-x shell. In summery my .emacs file looks like this:
(defun cygwin-shell ()
"Run cygwin bash in shell mode."
(interactive)
(let ((explicit-shell-file-name "C:/cygwin/bin/bash"))
(call-interactively 'shell)))
(setq explicit-bash-args '("--login" "-i"))`
Please be gentle with the answers as I am right at the bottom of the famous vertical emacs learning curve!
If you implemented the answer from that question, note that you have to do M-x cygwin-shell to start bash. If you want to use it for every M-x shell you need to call
(setq explicit-shell-file-name "C:/cygwin/bin/bash")
Since you stated that you are learning, here's a few tips when trying this out.
type C-x C-f ~/.emacs to open your .emacs file in your user path.
Enter your function above at the end
M-x load-file [RET] .emacs: loads the buffer (no need to restart emacs)
C-h a: If you are interested in some specific action, you can look it up
C-h v [RET] variable: can inspect the variable, check the value of explicit-bash-args for instance
And, btw, I'm not sure what the "--login -i" does, but someone stated in a comment that you should have that so "ls" would work. If you have your cygwin bin path in your PATH environment variable, bash will find ls anyway. No need to escape the path variable either, this is handled by bash (do an echo $PATH in bash when you get it working and you'll see).

PATH and exec-path set, but emacs does not find executable

My .emacs contains
(setenv "PATH" (concat ".:/usr/texbin:/opt/local/bin" (getenv "PATH")))
(setq exec-path (append exec-path '(".:/usr/texbin:/opt/local/bin")))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
(require 'tex-site)
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
/usr/texbin is where latex/pdflatex/.. are located.
/opt/local/bin/ is where gs can be found.
And yet when I run preview-at-point, which apparently needs both latex and gs, I get
Preview-DviPS finished at Thu Dec 22 11:25:46
DviPS sentinel: Searching for program: No such file or directory, gs
which means that latex could be found all right, but not gs.
I am not sure whether setting exec-path is necessary, perhaps PATH is enough, but I've set it as a debugging measure.
Why can emacs not find gs even though the directory it's in is in both PATH and exec-path?
If you're setting $PATH inside your Emacs, you might well be on OS X. GUI applications are not started via your shell, so they see different environment variables.
Here's a trick which I use to ensure the $PATH inside Emacs is the same one I see if I fire up a terminal (but see "update" below):
(defun set-exec-path-from-shell-PATH ()
"Set up Emacs' `exec-path' and PATH environment variable to match that used by the user's shell.
This is particularly useful under Mac OSX, where GUI apps are not started from a shell."
(interactive)
(let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
Then simply call the set-exec-path-from-shell-PATH function, perhaps from your Emacs init file. I keep that code on github, BTW.
Update: this code has now been improved and published as an elisp library called exec-path-from-shell; installable packages are available in MELPA.
Try replacing the second line with this:
(setq exec-path (append exec-path '("/usr/texbin" "/opt/local/bin")))
I hit a similar problem, but with a correct PATH, including trailing ´:´. It turned out the internal emacs shell program was missing, resulting in a ´Searching for program: No such file or directory´ message.
Fixed with
(setq shell-file-name "bash").
It appears you're missing a path separator : at the end of your path string.