slime-fancy not loading with emacs sbcl slime windows configuration - windows

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)

Related

Flycheck UsePackage with C++11

I use use-package for my emacs configuration.
Unfortunately I cannot properly configure the flycheck package to work with C++11 extension.
Here what I have so far:
;; == Flycheck ==
(use-package flycheck
:ensure t
:defer t
:init
(global-flycheck-mode)
:config
(setq flycheck-clang-language-standard "c++11"))
Although I set the proper variable, the flycheck gives me an error on c++11 syntax (e.g. auto i = 10).
What am I missing?
I think I had the same problem once. I cannot test it right now (will do it later today) but what I finally did was adding a hook to c++-mode rather than setting flycheck-clang-language-standard variable.
Here is code from my init file.
(add-hook 'c++-mode-hook
(lambda () (setq flycheck-clang-language-standard "c++11")))
You can try to use it in your use-package.
EDIT
Okay, I just checked it. When in my init.el file I have only
(require 'flycheck)
(flycheck-mode)
(setq flycheck-clang-language-standard "c++11")
flycheck highlights auto variable in a cpp file and I can see in the minibuffer following information.
rvalue references are a C++ extension
When I change my init.el file to
(require 'flycheck)
(flycheck-mode)
(add-hook 'c++-mode-hook
(lambda () (setq flycheck-clang-language-standard "c++11")))
There is no error.

Emacs company-mode completion not working

I just began using emacs a few days ago and I've been having trouble setting up company-mode. I installed company-mode using package-install and added the following in my .emacs file :-
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
Yet, when I go over to haskell-mode, company-mode completion doesn't pop up at all (likewise with racket-mode) when I wait for a few seconds on a keyword. Could I have installed something that could have been messing up or conflicting with company-mode?
Also, when I try to invoke company-complete manually, it just says "no completion found".
Edit: Tried out auto-complete as an alternative and code completion does not work when I press tab, but when i invoke auto-complete on a word, it works.
Edit2: got auto-complete to work.
https://i.imgur.com/Vn4f2GX.png
It looks like flyspell-mode was conflicting with auto-complete. But, No luck with getting company mode to work.
Really appreciate any help.
I got completion to work for company-mode in haskell without much hassle.
All I had to do was add company backends to my .emacs :-
(add-to-list 'company-backends 'company-dabbrev-code)
(add-to-list 'company-backends 'company-yasnippet)
(add-to-list 'company-backends 'company-files)
And get the package intero which adds company-mode support for haskell. Like so :-
(add-hook 'haskell-mode-hook 'company-mode)
(add-hook 'haskell-mode-hook 'intero-mode))
As for racket-mode, I add this in my .emacs :-
(defun my-racket-mode-hook ()
(set (make-local-variable 'company-backends)
'((company-capf company-dabbrev-code)))
(company-quickhelp-mode 0))
(add-hook 'racket-mode-hook 'my-racket-mode-hook)
(add-hook 'racket-mode-hook 'company-mode)
(add-hook 'racket-repl-mode-hook 'my-racket-mode-hook)
(add-hook 'racket-repl-mode-hook 'company-mode)

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.

ANSI Coloring in Compilation Mode

Have anyone added support for ansi-color in compilation-mode Emacs? If so what property/attribute does the color-writing program have to check for in order to make sure its active terminal supports ANSI-escape coloring.
There's already a function for applying color to comint buffers. You simply need to enable it on compilation buffers:
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region compilation-filter-start (point))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
Color writing programs should check the TERM environment variable and the terminfo database to check if the terminal supports color. In practice, a lot of programs ignore this and rely on a user setting. Emacs will set the compilation terminal type to dumb by default but this can be overriden by setting the compilation-environment variable.
Update: Note that in Emacs 24.5 the two calls to (toggle-read-only) in the code above are not needed.
My optimized solution which don't pollute M-x grep (only for M-x compile):
(ignore-errors
(require 'ansi-color)
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
As of emacs 28.1, this is now a built in !
(require 'ansi-color)
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
Or with use-package
(use-package ansi-color
:hook (compilation-filter . ansi-color-compilation-filter))
Riffing on #gavenkoa's solution:
(when (require 'ansi-color nil t)
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
This will not block errors but will still not raise an error if ansi-color is unavailable. Personally, I find the wildcard catch semantics of ignore-error distasteful.
Riffing on #stribb's solution, which riffs on #gavenkoa's solution, this is how to set it up with the awesome use-package:
(use-package ansi-color
:config
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
:hook (compilation-filter . my-colorize-compilation-buffer))
As of 2020, the most modern way appears to be the xterm-color Emacs package.
See my answer on the duplicate question for details.

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