can't find any symbol in common lisp in emacs with slime - emacs

According to the guide on the Internet, we can search in the HyperSpec for the symbol like "format" in emacs by typing C-c C-d h , However, I just cannot have it work, emacs just prompts that there's no completion for the symbol. Can somebody cope with it? thanks in advance!

Are you actually using the Slime REPL mode? Sometimes, when starting Slime without any configuration, you're not getting the REPL mode, and instead you'll be sitting in the *inferior-lisp* buffer.
First of all, check what the title of the buffer is. If it's *inferior-lisp*, it's not the correct one. It should read *slime-repl sbcl* (where sbcl refers to the CL implementation you're using).
If this is the case, then you need to make sure you enable slime-fancy in your Emacs init file. This is what I have:
(defun init-slime-configuration ()
(slime-setup '(slime-fancy slime-fuzzy))
(setq slime-load-failed-fasl 'never)
(define-key slime-repl-mode-map (kbd "C-<tab>") 'slime-fuzzy-complete-symbol)
(define-key slime-mode-map (kbd "C-<tab>") 'slime-fuzzy-complete-symbol))
(add-hook 'slime-load-hook 'init-slime-configuration)
This also allows me to use C-TAB for fuzzy expand.

I ran into this very problem after switching from the version of SLIME installed using Quicklisp (version 2.9) to that installed from MELPA (version 20141010.1357, as a dependency of ac-slime).
Using SLIME from Quicklisp worked fine with my local copy of the HyperSpec, using the settings:
(require 'slime-autoloads)
(add-to-list 'slime-contribs 'slime-fancy)
(setq slime-lisp-implementations
'((ccl ("ccl"))
(clisp ("clisp"))
(cmucl ("cmucl"))
(ecl ("ecl"))
(sbcl ("sbcl"))))
(setq slime-default-lisp 'sbcl)
(setq common-lisp-hyperspec-root "file:/usr/share/doc/HyperSpec/")
(setq common-lisp-hyperspec-symbol-table "file:/usr/share/doc/HyperSpec/Data/Map_Sym.txt")
I then completely removed and reinstalled Quicklisp (without reinstalling SLIME!), then installed ac-slime from MELPA using the Emacs package manager.
By chance I happened to notice that when I tried to lookup documentation in the HyperSpec, Emacs opened a hidden buffer with an empty file named "Map_Sym.txt" in it.
Looking at the full pathname of this file using C-h v buffer-file-name [RET] revealed that it was set to "/home/miki/file:/usr/share/doc/HyperSpec/Data/Map_Sym.txt".
As an experiment, I tried removing the "file:/" from the last two lines of my settings, to make them read:
(setq common-lisp-hyperspec-root "/usr/share/doc/HyperSpec/")
(setq common-lisp-hyperspec-symbol-table "/usr/share/doc/HyperSpec/Data/Map_Sym.txt")
It appears to have resolved the issue. Why this works, I don't know (it differs from the documentation). A bug or undocumented change, maybe?

Related

Why Emacs project C-c p is undefined?

I am new to Emacs. I have installed Projectile.
When I do C-c p, it says:
C-c p is undefined
Wondering what is wrong?
Following is my ~/.emacs file.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(defvar required-packages
'(
projectile
) "a list of packages to ensure are installed at launch.")
(require 'cl)
; method to check if all packages are installed
(defun packages-installed-p ()
(loop for p in required-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
; if not all packages are installed, check one by one and install the missing ones.
(unless (packages-installed-p)
; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
; install the missing packages
(dolist (p required-packages)
(when (not (package-installed-p p))
(package-install p))))
(require 'projectile)
(projectile-global-mode)
Edit
My .projectile file
-/venv
-*.pyc
-*.pyc~
-.git
-.gitignore
-.DS_Store
Edit 2
C-h v output for projectile-keymap-prefix as below:
projectile-keymap-prefix is a variable defined in `projectile.el'.
Its value is "^Cp"
Documentation:
Projectile keymap prefix.
You can customize this variable
Edit 3
I am using OS X 10.10.4. I start emacs from command line $emacs. I have installed Emacs using following commands:
brew install emacs --with-cocoa
And, very first time (when I launch emacs). If do M-x, I don't get project-switch-project, rather I get project-switch-to-buffer. After switching buffer, I can switch project.
You now need to explicitly enable it and set a prefix. The steps to enable Projectile with a C-c C-p prefix:
(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)
This has changed a couple times in 2018. Boris used to set C-c p as the default leader, then changed it to C-c C-p to be in accordance with the emacs keybinding conventions (bullet #2 mentions it.). But now it's removed altogether, so you should set it yourself.
You need to manually activate projectile mode in your ~/.emacs file:
(projectile-mode 1)
Projectile's default keymap prefix is defined by the variable projectile-keymap-prefix. You can use C-h v to see value of that variable. If not set or is not ^Cp, you can use the code below to set it to C-c p
(setq projectile-keymap-prefix (kbd "C-c p"))
or any else key binds as you like.
I encountered a similar problem recently that projectile-global-mode doesn't work as how it worked before after I had pinned the projectile package to the melpa stable archive, which was of the version v0.14.0.
The way that projectile-global-mode behaved before is that when turned on the keybindings are available from any buffer, but now I can't get it to work when in the splash screen (which is in Fundamental mode) after emacs starts, like Menno Smits points out in the comment.
For the sake of curiosity, I git bisect the source code history of projectile to find out which commit introduces this behavior change and finally get this, which no longer uses define-globalized-minor-mode to define the global minor mode but defines the projectile-mode as global by default with (define-minor-mode xxxxxx :global t), the difference could be told from the doc of define-globalized-minor-mode I think:
Globally enabling the mode also affects buffers subsequently created by visiting files, and buffers that use a major mode other than Fundamental mode; but it does not detect the creation of a new buffer in Fundamental mode. Source
Not sure if this relates, but this's how I figured it out and hope it helps anyone having the same confusion as mine.

C-c C-c does not work anymore to compile a tex under Emacs

I just upgraded my Ubuntu from 12.04 to 14.04.
When I edited .tex file under 12.04, I have set up my Emacs in such a way that C-c C-c launched automatically Latex, View or BibTex according to the circumstance. Consequently, I just needed to keep pressing C-c C-c to compile and view a simple .tex file. A part of the ~/.emacs file is as follows:
(require 'server)
(or (server-running-p)
(server-start))
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
(defun pdf-with-okular ()
(add-to-list 'TeX-output-view-style
(quote ("^pdf$" "." "okular %o %(outpage)"))))
(add-hook 'LaTeX-mode-hook 'pdf-with-okular t)
(setq TeX-view-program-list '(("Okular" "okular %o")))
(setq TeX-view-program-selection '((output-pdf "Okular") (output-dvi "Okular")))
(eval-after-load "tex"
'(setcdr (assoc "LaTeX" TeX-command-list)
'("%`%l%(mode) -shell-escape%' %t"
TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")))
(custom-set-variables
'(LaTeX-command "latex -synctex=1")
'(cua-mode t nil (cua-base))
'(show-paren-mode t)
'(tool-bar-mode nil))
After upgrading, this mechanism does not work anymore: C-c C-c launches Command [pdflatex], and if I just press Enter, it could not find the .tex file.
Does anyone know what is wrong?
It sounds like the command you expect to be bound to C-c C-c is not -- some other command is.
C-h m tells you what mode you are in, and some things about it. C-h k C-c C-c tells you what command is bound to C-c C-c, and it gives you a link to the library where that command is defined.
This info, together with your init file and the Lisp source code, will help you find out why C-c C-c is not bound to the command you expect.
And you might want to start your search by bisecting your init file, to narrow it down to the code that causes the problem.
In sum, the answer is to ask Emacs first.
The command that you describe comes from the AUCTeX extension, which replaces the built-in LaTeX mode of Emacs. It appears that AUCTeX was not properly upgraded or removed from your system, so you are back to the built-in mode, which is pretty primitive compared to AUCTeX.
Check whether AUCTeX is still available in your Emacs session (e.g. M-x locate-library RET auctex). Also, check whether the AUCTeX package is still installed, and reinstall it if necessary.
Alternatively, you can obtain AUCTeX from GNU ELPA with Emacs' built-in package manager, which makes your Emacs setup independent from your system.

How to connect Hyperspec documentation to Emacs SLIME on MS Windows

With this minimal init file:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
Everything seems to work, such as slime-eval-defun and slime-complete-symbol, except for looking up documentation. M-x slime-describe-symbol RET print RET results in this error:
CLHS-ROOT: variable *CLHS-ROOT-DEFAULT* has no value
What do I need to add in my init file to make it work?
I also tried downloading the hyperspec tar file and extracting it to a directory, and this code:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp"
common-lisp-hyperspec-root "c:/run/HyperSpec/"
common-lisp-hyperspec-symbol-table "c:/run/HyperSpec/Data/Map_Sym.txt")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
That doesn't work either. I do not know if the bug is in that init file, or in the SLIME version I am using, because this is my first time with SLIME.
Versions:
MS Windows 7
Emacs version 24.3.1 (probably latest stable)
SLIME version 20130626.1151 (latest from MELPA) (One from Marmalade says it can't compile nil, I don't know what that means and so I am using one from MELPA instead)
GNU CLISP 2.49 (latest stable)
UPDATE
C-c C-d f RET print RET works fine. This is bound to slime-describe-function, which is undocumented, and not listed in SLIME menu. There is also slime-documentation-lookup which is bound to C-c C-d C-d which can open documentation for variables (not just functions) in a browser, and that works too. Looks like only `slime-describe-symbol doesn't work.
I haven't done it on Windows, but if I were you, I'd try to do this with Quicklisp: (ql:quickload "clhs") and follow the printed directions.
I'd also get SLIME from Quicklisp via (ql:quickload "quicklisp-slime-helper"), but if your slime works ok, no real need.
Assuming that SLIME is installed from an emacs package archive (preferably MELPA) (and that GNU CLISP is installed), here is combination of relevant portions from How to install Common Lisp and SLIME on MS Windows:
Assuming starting from scratch after commenting out any SLIME customization code you already have, start by putting the following code to your init file which should be evaluated after package-initialize:
(setq inferior-lisp-program "clisp")
(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))
What that does is defining my-slime-setup and make sure the function runs just once if you are using SLIME that day. my-slime-setup is also a container to which you can add your own SLIME customization code.
Now to connect the downloaded documentation to SLIME, extract the downloaded archive and you will get a folder with name Hyperspec, and then you move that folder to the Emacs bin directory, or its parent directory, or its grandparent directory, Put the following code in Emacs init file.
(defun my-hyperspec-setup ()
(let ((dir (locate-dominating-file invocation-directory "HyperSpec/")))
(if dir
(progn
(setq common-lisp-hyperspec-root (expand-file-name "HyperSpec/" dir)))
(warn "No HyperSpec directory found"))))
and add my-hyperspec-setup to my-slime-setup like this:
(defun my-slime-setup ()
(my-hyperspec-setup)
(require 'slime)
(slime-setup))
and restart Emacs.
And now when you do M-x slime-describe-symbol RET print RET in a lisp buffer, it should show the description of PRINT in another buffer.
I should confess that I am sourcing from my own article and also answering my own question after about 8 months. The answer is tested with latest SLIME from MELPA and on a vanilla GNU Emacs.

Running Clojure and other Lisp at the same time on Emacs

I use Aquamacs, and Aquamacs is pre-equipped with SLIME.
(setq inferior-lisp-program "/usr/local/bin/sbcl") #####!!!
(add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME/contrib")
(add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME")
(require 'slime)
(slime-setup)
As is asked in somewhere, I try to use Clojure by adding this code.
(add-to-list 'load-path "~/clojure/clojure-mode")
(setq inferior-lisp-program "/Users/smcho/bin/clj") ################
(require 'clojure-mode)
(setq auto-mode-alist
(cons '("\\.clj$ . clojure-mode")
auto-mode-alist))
(add-hook 'clojure-mode-hook
'(lambda ()
(define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)))
)
I couldn't make it Clojure run with SLIME, but I'm satisfied with the current setting, the only problem is that because of the (setq inferior-lisp-program ...) code, I have to change the .emacs code depending on I use Clojure or SBCL.
Is there any way to solve this problem? Can I choose between multiple (inferior) Lisps?
Added
I could make Clojure run on Aquamacs. Please refer to Running Clojure with 'lein swank' on Aquamacs problem. Forget about the settings written above, if you want to run Aquamacs/Clojure. You need just one line, (slime-setup '(slime-repl)) and lein swank.
Sure, you can use C-u M-x slime instead of just M-x slime to have SLIME ask you for the name of the Lisp executable to be launched, with whatever is your default already filled in.
There's also a slime-lisp-implementations variable which I have configured like so:
(setq slime-lisp-implementations
`((clojure ,(swank-clojure-cmd) :init swank-clojure-init)
(sbcl ("sbcl") :coding-system utf-8-unix)))
I have to say that I just can't remember what this does for me anymore (if indeed it does anything)... Type C-h v slime-lisp-implementations to learn roughly what it's supposed to do. I seem to have to type sbcl if I want to start that, which is fine by me due to the high Clojure-to-SBCL ratio in my SLIME'ing.
Update:
I have just rediscovered M-- M-x slime (that first key is meta-minus for a negative argument), which prompts for one of the names of Lisp implementations in slime-lisp-implementations (with tab completion) and then starts the required Lisp. With the above example config, M-- M-x slime sbcl starts SBCL.
(I find this useful mostly because of how it allows one to configure more complex commands to start Lisp -- e.g. (sbcl-options ("sbcl" "--an-option" "--another-option") ...), (sbcl-clbuild ("/path/to/clbuild" "lisp") ...) -- and refer to them by name.)

How do I set up Aquamacs for Clojure development?

I've tried to migrate to Emacs several times for Clojure development, following a variety of blogposts, screencast and tutorials, but somewhere along the way something always went wrong - keybindings that didn't work, incompatible versions, etc, and I found myself scrambling back to Vim. But I know I want Paredit and SLIME.
So, I'm going to try again, this time backed by the powerful Stack Overflowâ„¢ community.
I hope that the answer to this question will remain up-to-date, and can serve as a reference for tentative converts like me.
What I'd like is:
The latest stable release of Clojure
Aquamacs (if it's good enough for Rich Hickey, it's good enough for me), a recent version
Clojure Mode
SLIME/SWANK
Paredit
Anything else that's indispensible?
Step-by-step instructions to install the above would be excellent - preferably in shell script format. I'd also like some hints on how to get started with the most common Clojure-related actions (including key-bindings), including links to documentation and cheatsheets.
These are the steps I took to set them up without using ELPA. Hope this helps.
Get SLIME using MacPorts
sudo port -v install slime
Get paredit
curl -O http://mumble.net/~campbell/emacs/paredit.el
Get clojure & clojure-contrib
Either using MacPorts
sudo port -v install clojure clojure-contrib
Or downloading directly
curl -O http://build.clojure.org/snapshots/org/clojure/clojure/1.1.0-master-SNAPSHOT/clojure-1.1.0-master-20091202.150145-1.jar
curl -O http://build.clojure.org/snapshots/org/clojure/clojure-contrib/1.1.0-master-SNAPSHOT/clojure-contrib-1.1.0-master-20091212.205045-1.jar
Get clojure-mode and swank-clojure (Emacs side)
git clone http://github.com/technomancy/clojure-mode.git
git clone http://github.com/technomancy/swank-clojure.git
Get swank-clojure (Clojure side)
Either downloading pre-built jar file
curl -O http://repo.technomancy.us/swank-clojure-1.1.0.jar
Or building from source (assuming lein is installed)
cd path/to/dir/swank-clojure
lein jar
Put clojure, clojure-contrib and swank-clojure .jar files in ~/.swank-clojure or ~/.clojure (the default places where swank-clojure.el searches for them).
Add to either ~/.emacs or ~/Library/Preferences/Aquamacs Emacs/customization.el (change paths to match your own settings)
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/")
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/contrib/")
;; Change these paths to match your settings
(add-to-list 'load-path "path/to/dir/clojure-mode/")
(add-to-list 'load-path "path/to/dir/swank-clojure/")
(add-to-list 'load-path "path/to/dir/paredit/")
;; Customize swank-clojure start-up to reflect possible classpath changes
;; M-x ielm `slime-lisp-implementations RET or see `swank-clojure.el' for more info
(defadvice slime-read-interactive-args (before add-clojure)
(require 'assoc)
(aput 'slime-lisp-implementations 'clojure
(list (swank-clojure-cmd) :init 'swank-clojure-init)))
(require 'slime)
(require 'paredit)
(require 'clojure-mode)
(require 'swank-clojure)
(eval-after-load "slime"
'(progn
;; "Extra" features (contrib)
(slime-setup
'(slime-repl slime-banner slime-highlight-edits slime-fuzzy))
(setq
;; Use UTF-8 coding
slime-net-coding-system 'utf-8-unix
;; Use fuzzy completion (M-Tab)
slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
;; Use parentheses editting mode paredit
(defun paredit-mode-enable () (paredit-mode 1))
(add-hook 'slime-mode-hook 'paredit-mode-enable)
(add-hook 'slime-repl-mode-hook 'paredit-mode-enable)))
;; By default inputs and results have the same color
;; Customize result color to differentiate them
;; Look for `defface' in `slime-repl.el' if you want to further customize
(custom-set-faces
'(slime-repl-result-face ((t (:foreground "LightGreen")))))
(eval-after-load "swank-clojure"
'(progn
;; Make REPL more friendly to Clojure (ELPA does not include this?)
;; The function is defined in swank-clojure.el but not used?!?
(add-hook 'slime-repl-mode-hook
'swank-clojure-slime-repl-modify-syntax t)
;; Add classpath for Incanter (just an example)
;; The preferred way to set classpath is to use swank-clojure-project
(add-to-list 'swank-clojure-classpath
"path/to/incanter/modules/incanter-app/target/*")))
Download and install Aquamacs.
Download and install ELPA (http://tromey.com/elpa/install.html)
Do M-x package-list-packages
Mark the lines called "clojure-mode" and "swank-clojure" with "I" then press "X".
Done.
Here's a blog post that mentions Aquamacs: Setting up Clojure, Incanter, Emacs, Slime, Swank, and Paredit
There seems to be a fairly easy way to set up Aquamacs 2.4 and SLIME for clojure:
Install Clojure
Install Aquamacs 2.4 from here "http://aquamacs.org/"
Install the Aquamacs SLIME package from here "http://aquamacs.org/download.shtml"
This will not work so...
Get the latest version of SLIME from here "http://common-lisp.net/project/slime/#downloading" - you want the CVS snapshot tar file
Unpack the SLIME tar file and copy it into
/Library/Application Support/Aquamacs Emacs/SLIME
Seems to work OK for me...
I know the OP wants to use Emacs for Clojure dev. I'm an emacs fan myself, but I found using Enclojure (http://www.enclojure.org/home) to be a great way to get started quickly with hacking Clojure.
Today I would head for https://github.com/tehcurtis/aquamacs-emacs-starter-kit/network
this is for ruby and wont work at first but anyway. git clone and copy things to Preferences.el according to readme. Fix the brokenness by edit the ~/Library/Preferences/Aquamacs Emacs/ and comment out almost everything in modes.el (I have only (setq-default indent-tabs-mode nil) left in the file)
The good part: you have installed elpa-package-manager with less hassle
now: use
M-x package-list-packages
go to
clojure-mode (press I)
slime (press I)
slime-repl (press I)
Press X to install
done.
Caveat: clojure-jack-in wont work so you have to
M-x slime-connect
and press enter twice and y to start.