diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2016-04-03 11:41:51 +0300 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2016-04-03 11:41:51 +0300 |
commit | 3354b99797df332431045b21df96051b46bb02a6 (patch) | |
tree | b20cc414f8a1b4e0705d81be151f77a98544ef73 | |
parent | 2da311e5bfb67dc6274d436926e6e0ac6d61526f (diff) |
Display eldoc for keywords used to get map keys
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-eldoc.el | 17 |
2 files changed, 10 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f2290fd4..95586a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ an individual test using `C-c C-t t`. * New function `cider-expected-ns` is like `clojure-expected-ns`, but uses classpath for better results. See [clojure-mode#372](https://github.com/clojure-emacs/clojure-mode/issues/372). * A double prefix argument (`C-u C-u`) for `cider-eval-defun-at-point` debugs the sexp at point instead of the entire defun, and offers to create a conditional breakpoint. * New command `cider-load-all-project-ns` allows you to load all project namespaces. +* Display eldoc for keywords used to get map keys. ### Changes diff --git a/cider-eldoc.el b/cider-eldoc.el index 0977d85b..bfca92dd 100644 --- a/cider-eldoc.el +++ b/cider-eldoc.el @@ -147,8 +147,6 @@ if the maximum number of sexps to skip is exceeded." thing ;; ignore empty strings (not (string= thing "")) - ;; ignore keywords - (not (string-prefix-p ":" thing)) ;; ignore strings (not (string-prefix-p "\"" thing)) ;; ignore regular expressions @@ -158,12 +156,15 @@ if the maximum number of sexps to skip is exceeded." ;; ignore numbers (not (string-match-p "^[0-9]" thing))) ;; check if we can used the cached eldoc info - (if (equal thing (car cider-eldoc-last-symbol)) - (cdr cider-eldoc-last-symbol) - (when-let ((eldoc-info (cider-sync-request:eldoc thing))) - (let ((arglist (nrepl-dict-get eldoc-info "eldoc"))) - (setq cider-eldoc-last-symbol (cons thing arglist)) - arglist))))) + (cond + ;; handle keywords for map access + ((string-prefix-p ":" thing) '(("map") ("map" "not-found"))) + (t (if (equal thing (car cider-eldoc-last-symbol)) + (cdr cider-eldoc-last-symbol) + (when-let ((eldoc-info (cider-sync-request:eldoc thing))) + (let ((arglist (nrepl-dict-get eldoc-info "eldoc"))) + (setq cider-eldoc-last-symbol (cons thing arglist)) + arglist))))))) (defun cider-eldoc () "Backend function for eldoc to show argument list in the echo area." |