5
votes

I am trying to properly configure emacs to write my Clojure code. I based my Emacs configurations on this good blog post.

However, I did change a few settings like the theme he is using etc. I have been checking to get Auto-Complete (Eldoc? I am not sure) to display the docstring of the functions in Clojure, and from my own code.

I want to see the documentation like in that screenshot:

eldoc

However, I cannot get the "yellow" documentation box to appear. I am not sure if this is due to a misconfiguration in my .emacs file, or if it is a command I have to use or...

Here is my .emacs file:

(add-to-list 'custom-theme-load-path "~/.emacs.d/lib/noctilux-theme")

(require 'package):
  (add-to-list 'package-archives
    '("marmalade" . "http://marmalade-repo.org/packages/")
    '("melpa" . "http://melpa.milkbox.net/packages/"))

;; Initialize all the ELPA packages (what is installed using the packages commands)    
(package-initialize)  

;; Set bigger fonts
(set-default-font "Courier New-13")  

;; Setup to have a french keyboard layout working   
(require 'iso-transl)  

;; Show parenthesis mode
(show-paren-mode 1)  

;; rainbow delimiters
(global-rainbow-delimiters-mode)

;; paredit
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'nrepl-mode-hook 'paredit-mode)
(global-set-key [f7] 'paredit-mode)

;; theme
(load-theme 'noctilux t)

;; clojure-mode
(global-set-key [f9] 'cider-jack-in)
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode)

;; nrepl
(add-hook 'nrepl-interaction-mode-hook 'nrepl-turn-on-eldoc-mode)
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "*nrepl*")
(add-hook 'nrepl-mode-hook 'paredit-mode)

;; Auto complete
(require 'auto-complete-config)
;(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(setq ac-delay 0.0)
;(setq ac-use-quick-help t)
(setq ac-quick-help-delay 0.0)
;(setq ac-use-fuzzy 1)
;(setq ac-auto-start 1)
;(setq ac-auto-show-menu 1)
(ac-config-default)

;; ac-nrepl
(require 'ac-nrepl)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'nrepl-mode))


(defun set-auto-complete-as-completion-at-point-function ()
  (setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)

(add-hook 'cider-repl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)


;; scroll one line at a time (less "jumpy" than defaults)

(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time

(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling

(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse

(setq scroll-step 1) ;; keyboard scroll one line at a time

Update based on @syohex's comment bellow

Here is what I see in my CLJ buffers:

CLJ buffer popup

In the NREPL, I do see a "v" instead of a "d" (by the way, what does these letters means?). As I said in my comment, in NREPL, I do see the yellow box appearing, then when the popup appears, then the doc yellow box disapear. In the CLJ code buffers, the yellow box never open.

Final Update

After some more testing, everything is working as expected. When the popup first shows, the yellow box disapear. However, when I start selecting different choices, then it reappears, at the right place.

Also, it started working in the CLJ buffers, and I see the letter "v" instead of "d" as seen in the sreenshot above. Maybe I forgot to start the NREPL, would have to re-test.

In any case, everything is working as expected.

4
rather late, but since I'm here and wondering the same thing: by the way, what does these letters means? Here as defined in source code.birdspider
As a note to future travelers, CIDER now recommends using company for autocompletionJosh.F

4 Answers

3
votes

nrepl-mode-hook, nrepl-interaction-mode-hook, nrepl-mode are obsoleted. You should use cider-mode-hook, cider-repl-mode-hook, cider-mode instead of them respectively.

And you should set ac-quick-help-delay to value more than 0(for example 0.5). Patch is below.

--- nconf-orig.el   2014-05-21 16:51:40.056185465 +0900
+++ conf-new.el 2014-05-21 16:53:11.936182181 +0900
@@ -43,7 +43,7 @@
 ;(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
 (setq ac-delay 0.0)
 ;(setq ac-use-quick-help t)
-(setq ac-quick-help-delay 0.0)
+(setq ac-quick-help-delay 0.5)
 ;(setq ac-use-fuzzy 1)
 ;(setq ac-auto-start 1)
 ;(setq ac-auto-show-menu 1)
@@ -51,9 +51,10 @@

 ;; ac-nrepl
 (require 'ac-nrepl)
-(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
-(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
-(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'nrepl-mode))
+(add-hook 'cider-mode-hook 'ac-nrepl-setup)
+(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
+(add-to-list 'ac-modes 'cider-mode)
+(add-to-list 'ac-modes 'cider-repl-mode)


 (defun set-auto-complete-as-completion-at-point-function ()
3
votes

Actually this configuration and the former ac-nrepl is deprecated, refer to the new package ac-cider

(require 'ac-cider)
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(add-hook 'cider-mode-hook 'ac-cider-setup)
(add-hook 'cider-repl-mode-hook 'ac-cider-setup)
(eval-after-load "auto-complete"
    '(add-to-list 'ac-modes 'cider-mode))
0
votes

the yellow box appears first, then when the autocompletion popup appears, the yellow box with the docs disapear.

This behavior is caused by(setq ac-quick-help-delay 0.5) since 0.5s is too fast

Change 0.5 to a bigger number (minimal value to work is 0.9 on my computer, but this may dependent on your computer's performance) or delete (setq ac-quick-help-delay 0.5) Since this would use the default: about 2.5s, it can resolve the problem.

0
votes

I am viewing this in 2020 and ac-cider is deprecated but you can use company-mode instead.

Use M-x package-install company to install and follow the cider docs to configure it for cider-repl-mode and cider-mode