Emacs + SLIME + SBCL (Windows) - windows

I'm attempting to get Emacs, Slime and SBCL to work together on a Windows 7 machine. I use Linux typically, so I'm not experienced with the process. The problem is that I get this error when I attempt to start SLIME: Searching for program: permission denied, sbcl
Here's my Emacs 24 init.el:
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(setq package-enable-at-startup nil)
(setq inferior-lisp-program "sbcl")
(setq slime-auto-connect 'ask)
(defun my-slime-setup ()
(require 'slime)
(slime-setup))
(defvar my--slime-setup-done nil)
(defun my-slime-setup-once ()
(unless my--slime-setup-done
(my-slime-setup)
(setq my--slime-setup-done t)))
(defadvice lisp-mode (before my-slime-setup-once activate)
(my-slime-setup-once))
My SBCL path is C:\Program Files\Steel Bank Common Lisp\1.2.7\sbcl if that makes any difference. Any help would be greatly appreciated

On mine I had to do this to get it working on Windows:
(setq slime-lisp-implementations '((sbcl ("C:\\Program Files\\Steel Bank Common Lisp\\1.2.8\\sbcl.exe" "--core" "C:\\Program Files\\Steel Bank Common Lisp\\1.2.8\\sbcl.core"))))

Related

Emacs: cmdproxy.exe has encountered an issue and needs to close

I opened up emacs today and I got an error when I started typing into the #include:
This only happens when I start typing. At first I thought it had something to do with my ~/.emacs file so I opened it up and commented certain things. Eventually I found that when I comment the following line the problem goes away:
(ac-config-default)
I'm using yasnippet and auto-complete packages in my lisp file for my editor. The problem seems to be the above line when using auto-complete This is the full script of my ~/.emacs up to that point:
(require 'cc-mode)
(load (expand-file-name "~/quicklisp/slime-helper.el"))
;; Replace "sbcl" with the path to your implementation
(setq inferior-lisp-program "sbcl")
(setq-default c-basic-offset 4 c-default-style "linux")
(setq-default tab-width 4 indent-tabs-mode t)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
; start package.el with emacs
(require 'package)
; add MELPA to repository list
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
; initialize package.el
(package-initialize)
; start auto-complete with emacs
(require 'auto-complete)
; do default config for auto config
(require 'auto-complete-config)
; THIS LINE IS THE PROBLEM:
(ac-config-default)
Is there something wrong I've done here? Something I may have forgotten to do?
First try running emacs as admin and see if the problem goes away, I've had trouble with permissions issues in windows before similar to this.
The error is almost certainly caused by the gtags autocomplete source for C.
If you are not using gtags, you can likely fix the problem by removing the source from autocomplete.
(add-hook 'c-mode-common-hook
(lambda () (remove-from-list 'ac-sources 'ac-source-gtags)) t t)
Not a perfect solution, but a possible one.

Indent with tab instead of spaces in Emacs ruby-mode

I've been trying to configure Emacs so that it insert a 'tab' instead of a series of 'spaces' when indenting Ruby code.
So far, I've tried setting the var ruby-indent-tabs-mode to t so that, as per the documentation, it would "insert tabs in ruby mode if this is non-nil.". But so far, no dice.
I've also tried customising it via Easy customisation, which inserted the following into my init.el:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ruby-indent-tabs-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
And after inspecting the variable via C-h v, it reports the variable is set to t, but pressing TAB keeps on inserting spaces.
I even tried editing the .el file for ruby-mode and re-compiling it to no effect.
Help would be appreciated.
----- EDIT -----
Here's the minor modes reported active via C-h m:
Enabled minor modes: Abbrev Auto-Complete Auto-Composition
Auto-Compression Auto-Encryption File-Name-Shadow Font-Lock
Global-Auto-Complete Global-Font-Lock Inf-Ruby Line-Number Menu-Bar
Show-Smartparens Show-Smartparens-Global Smartparens
Smartparens-Global Transient-Mark
The init.el file currently has:
(require 'cask "/Users/snowingheart/.cask/cask.el")
(cask-initialize)
(require 'pallet)
(add-to-list 'load-path "~/elisp")
(load "php-mode")
(add-to-list 'auto-mode-alist
'("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(global-set-key (kbd "C-x >") 'mc/mark-next-like-this)
(global-set-key (kbd "C-x <") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(require 'smartparens-config)
(require 'smartparens-ruby)
(require 'smartparens-erb)
(smartparens-global-mode)
(show-smartparens-global-mode t)
(sp-with-modes '(rhtml-mode)
(sp-local-pair "<%=" "%>")
(sp-local-pair "<%-" "%>"))
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories
"~/.emacs.d/.cask/24.3.50.1/elpa/auto-complete-20130724.1750/dict")
(ac-config-default)
(setq ac-ignore-case nil)
(add-to-list 'ac-modes 'enh-ruby-mode)
(add-to-list 'ac-modes 'web-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(indent-tabs-mode t)
'(ruby-indent-tabs-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(setq-default indent-tabs-mode t)
(setq enh-ruby-indent-tabs-mode t)
(smart-tabs-insinuate 'ruby)
(smart-tabs-advice ruby-indent-line ruby-indent-level)
(setq ruby-indent-tabs-mode t)
Try adding the following to your init.el (below the customizations you already have):
(setq-default indent-tabs-mode t)
From the documentation for indent-tabs-mode:
Indentation can insert tabs if this is non-nil.
I don't use ruby-mode so I don't know about possible interactions between indent-tabs-mode and ruby-indent-tabs-mode. It might just be enough to set indent-tabs-mode to t (and erase the customizations you made to ruby-indent-tabs-mode). But when you add the snippet above to your configuration, the default behavior for Emacs will be to insert tabs for indentation.
EDIT
As can be seen here, enh-ruby-mode defines a customizable variable called enh-ruby-indent-tabs-mode with a default value of nil. Later on the value of this variable is used to override the value of indent-tabs-mode, which is why setting indent-tabs-mode to t has no effect on buffers with enh-ruby-mode enabled.
So unless you enable any other modes besides ruby-mode and enh-ruby-mode that might be modifying the indent-tabs-mode variable, adding
(setq enh-ruby-indent-tabs-mode t)
to your init.el should fix your problem.
Another EDIT (working solution)
(Credits: This answer put me on the right track.)
Using
Emacs 24.3.1
ruby-mode version 1.2 (built-in)
enh-ruby-mode version 20140406.252 (installed via M-x package-install ...)
I was able to make it work by adding the following to an otherwise completely empty init.el file:
(package-initialize)
(setq-default tab-width 2)
(setq enh-ruby-indent-tabs-mode t)
(defvaralias 'enh-ruby-indent-level 'tab-width)
(defvaralias 'enh-ruby-hanging-indent-level 'tab-width)
This solution works for both the GUI and the console version of Emacs. It will probably integrate fine with your other customizations but you will need to remove the custom-set-variables section and everything below it from the version of your init.el you posted above.
Note also that if you do come across a situation in which Emacs inserts a space instead of a tab you can always delete it and force insertion of a tab by quoting it via C-q TAB.
Wrapping up
Turns out there is a bug in enh-ruby-mode which causes indentation to fail for blocks starting from the second level when enh-ruby-indent-tabs-mode is set to t. The author/maintainer of enh-ruby-mode has no plans of fixing it, but the bug report includes a patch that supposedly fixes the issue.
Updated answer au goût du jour (Emacs 28.2):
Set the indent-tabs-mode and ruby-indent-tabs-mode to t.
Globally, in your ~/.emacs.el:
(setq indent-tabs-mode t)
(setq ruby-indent-tabs-mode t)
(setq tab-width 2)
(setq ruby-indent-level 2)
Or better, limited to a particular project, in a ~/src/your-project/.dir-locals.el (for example) file:
((ruby-mode . ((indent-tabs-mode . t)
(ruby-indent-tabs-mode . t)
(tab-width . 2)
(ruby-indent-level . 2))))

slime-fancy not loading with emacs sbcl slime windows configuration

I have slime with sbcl working in emacs 24.1 but can not get a slime repl to open.
I can use M-x slime to make a connection to sbcl in a inferior-lisp buffer but I can not invoke the slime-repl or get a nice lisp auto-indent when editing lisp files even though I am loading the slime-fancy contrib in .emacs. I don't get any error messages during start-up.
When I try M-x slime-repl I get [No match].
my .emacs file:
(setq inferior-lisp-program "sbcl")
(add-to-list 'load-path "c:/home/bin/emacs/site-lisp/slime/")
(require 'slime)
(require 'slime-autoloads)
(slime-setup '(slime-fancy))
I used this method for the installation:
http://www.pchristensen.com/blog/articles/installing-sbcl-emacs-and-slime-on-windows-xp
I have noticed a pattern that almost everything I try with Python and Clojure works as described and almost nothing I try related to common lisp works. I have also tried cusp with eclipse. I am willing to try yet another approach if there is something more recent for common lisp in windows.
After playing with Sujoy's answer and trimming it down to get it to work, I realized my original problem was caused by the (require 'slime) statement. The following .emacs file gets the slime repl to open as expected.
(setq inferior-lisp-program "sbcl")
(require 'slime-autoloads)
(slime-setup '(slime-fancy))
Only 'slime-fancy will not setup the REPL. Try the below snippet. Put it in a buffer and eval.
Of course, you do not need to setup the hyperspec root as well, but that helps a lot :)
EDIT: missed out on the autoloads I am using, so here's the full config.
the keybinding (using minor-mode keymap, global mapping can be used just as easily)
(define-key my-keys-map (kbd "<f5>") 'slime)
the autoloads
;; slime mode
(autoload 'slime "my-slime" "Slime mode." t)
(autoload 'slime-connect "my-slime" "Slime mode." t)
Here's my-slime.el
(provide 'my-slime)
(eval-after-load "slime"
(setq slime-lisp-implementations
(slime-setup '(slime-asdf
slime-autodoc
slime-editing-commands
slime-fancy
slime-fontifying-fu
slime-fuzzy
slime-indentation
slime-mdot-fu
slime-package-fu
slime-references
slime-repl
slime-sbcl-exts
slime-scratch
slime-xref-browser))
(slime-autodoc-mode)
(setq slime-complete-symbol*-fancy t
slime-complete-symbol-function 'slime-fuzzy-complete-symbol
slime-when-complete-filename-expand t
slime-truncate-lines nil
slime-autodoc-use-multiline-p t)
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))))
(require 'slime)

Receiving Flymake error in Windows & Ubuntu Emacs for PHP

I am receiving this error.
Error (flymake): Flymake: Failed to launch syntax check process 'php' with args (-f test_flymake.php -l): Searching for program: no such file or directory, php. Flymake will be switched OFF
I am on windows 7 with emacs 24 GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601)
There is an article which highlights this error but it is referring to checking /etc in linux however I am on windows. http://sachachua.com
This is the currently relevant part of my .emacs, what can I do to get it working.
(add-to-list 'load-path "C:/Users/renshaw family/AppData/Roaming/.emacs.d/elpa/flymake-0.4.11")
(require 'flymake)
(global-set-key [f3] 'flymake-display-err-menu-for-current-line)
(global-set-key [f4] 'flymake-goto-next-error)
;;(require 'flymake-php)
(require 'zencoding-mode)
(add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes
(defun flymake-php-init ()
"Use php to check the syntax of the current file."
(let* ((temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
(local (file-relative-name temp (file-name-directory buffer-file-name))))
(list "php" (list "-f" local "-l"))))
(add-to-list 'flymake-err-line-patterns
'("\\(Parse\\|Fatal\\) error: +\\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)$" 3 4 nil 2))
(add-to-list 'flymake-allowed-file-name-masks '("\\.php$" flymake-php-init))
;; Drupal-type extensions
(add-to-list 'flymake-allowed-file-name-masks '("\\.module$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.install$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.inc$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.engine$" flymake-php-init))
(add-hook 'php-mode-hook (lambda () (flymake-mode 1)))
(define-key php-mode-map '[M-S-up] 'flymake-goto-prev-error)
(define-key php-mode-map '[M-S-down] 'flymake-goto-next-error)
Edit:
I have now tried this in ubuntu 12.04 as well and receive the same error.
It looks like flymake can't find the PHP interpreter. Try adding an explicit hint about where to find PHP.
One way you could do this is by adding the following defun to your .emacs:
(defun my-flymake-get-php-cmdline (source base-dir)
"Gets the command line invocation needed for running a flymake
session in a PHP buffer. This gets called by flymake itself."
(list "C:\Path\to\PHP\php.exe"
;; Or the path to the PHP CLI executable on the Ubuntu machine you mentioned.
(list "-f" source "-l")))
Then modifying the flymate-php-init you're using now into this:
(defun flymake-php-init ()
"Use php to check the syntax of the current file."
(let* (
(temp
(flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
(local
(file-relative-name temp (file-name-directory buffer-file-name))))
(get-cmdline-f 'my-flymake-get-php-cmdline)))
This advice is heavily based on this answer from someone else using flymake on Windows for PHP. You might also find that answer helpful, since their situation is similar to yours.

About auto complete and yasnippet in emacs

I'm using auto-complete and yasnippet in Emacs and I am confused by their settings. I placed the following code in my .emacs:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas/global-mode 1)
(global-set-key (kbd "C-i") 'yas/expand)
(setq yas/also-auto-indent-first-line t)
(add-to-list 'load-path "~/.emacs.d/plugins/autocomplete/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/plugins/autocomplete/ac-dict")
(ac-config-default)
(setq ac-use-menu-map t)
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)
(defun ac-js-mode()
(setq ac-sources '(ac-source-yasnippet
ac-source-symbols
ac-source-words-in-buffer
ac-source-words-in-same-mode-buffers
ac-source-files-in-current-dir
)))
(add-hook 'js-mode-hook 'ac-js-mode)
I am trying to set yasnippet as the first candidate in the auto-complete popup menu. However, as the example below shows, this doesn't work with my current settings: when I type the word for, formatItem is in first position and for in second. formatItem is just a local function in current buffer.
for_____________
|formatItem |
|for a|
|for s|
|force s|
|foreachv s|
----------------
So my question is: how can I make yasnippet the first candidate in auto-complete? And is there something missing in my .emacs config?
Any help is appreciated.
ac-config-default installs hooks to setup sensible default ac-sources values. These hooks (especially ac-common-setup) might interfere with your settings.
You can check this by looking at the actual value of ac-sources (C-h vac-sources) in a js-mode buffer to see if it has been modified by comparison to your custom value.
If this is the case, I see two solutions:
stop using ac-config-default and specifiy all autocomplete settings,
advise the faulty hook to put ac-source-yasnippet at the beginning of ac-sources after it has run. Assuming ac-common-setup is indeed the troublemaker, this would look like:
(defadvice ac-common-setup (after give-yasnippet-highest-priority activate)
(setq ac-sources (delq 'ac-source-yasnippet ac-sources))
(add-to-list 'ac-sources 'ac-source-yasnippet))

Resources