Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #1222] Add option to apply a single face to the results overlay #1245

Merged
merged 1 commit into from
Aug 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New features

* [#1245](https://github.com/clojure-emacs/cider/pull/1245): New variable, `cider-ovelays-use-font-lock` controls whether results overlay should be font-locked or just use a single face.
* [#1235](https://github.com/clojure-emacs/cider/pull/1235): Add support for syntax-quoted forms to the debugger.
* [#1212](https://github.com/clojure-emacs/cider/pull/1212): Add pagination of long collections to inspector.
* [#1237](https://github.com/clojure-emacs/cider/pull/1237): Add two functions for use with `cider-repl-prompt-function`, `cider-repl-prompt-lastname` and `repl-prompt-abbreviated`.
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,21 @@ CIDER integration for `eval-sexp-fu`.
(require 'cider-eval-sexp-fu)
```

### Overlays

When you evaluate code in Clojure files, the result is displayed in the buffer itself, in an overlay right after the evaluated code.
If you want this overlay to be font-locked (syntax-highlighted) like Clojure code, set the following variable.

```el
(setq cider-ovelays-use-font-lock t)
```

You can disable overlays entirely (and display results in the echo-area at the bottom) with the `cider-use-overlays` variable.

```el
(setq cider-use-overlays nil)
```

## Basic Usage

The only requirement to use CIDER is to have a nREPL server to
Expand Down
36 changes: 23 additions & 13 deletions cider-overlays.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@
;;; Customization
(defface cider-result-overlay-face
'((t :inherit font-lock-builtin-face))
"Face used to display result of debug step at point."
:group 'cider-debug
"Face used to display evaluation results at the end of line.
Only used on the result string if `cider-ovelays-use-font-lock' is nil.
If it is non-nil, this face is only used on the prefix (usually a \"=>\")."
:group 'cider
:package-version "0.9.1")

(defcustom cider-ovelays-use-font-lock nil
"If non-nil, results overlays are font-locked as Clojure code.
If nil, apply `cider-result-overlay-face' to the entire overlay instead of
font-locking it."
:group 'cider
:type 'boolean
:package-version '(cider . "0.10.0"))

(defcustom cider-use-overlays 'both
"Whether to display evaluation results with overlays.
If t, use overlays. If nil, display on the echo area. If both, display on
Expand All @@ -47,7 +56,7 @@ see `cider-debug-use-overlays'."
(const :tag "Bottom of screen" nil)
(const :tag "Both" both))
:group 'cider
:package-version "0.10.0")
:package-version '(cider . "0.10.0"))

(defcustom cider-eval-result-prefix "=> "
"The prefix displayed in the minibuffer before a result value."
Expand Down Expand Up @@ -113,16 +122,17 @@ PROPS are passed to `cider--make-overlay' with a type of result."
(when where (goto-char where))
;; Make sure the overlay is actually at the end of the sexp.
(skip-chars-backward "\r\n[:blank:]")
(let ((o (apply
#'cider--make-overlay
(line-beginning-position) (line-end-position)
'result
'after-string
(concat (propertize " " 'cursor 1000)
(propertize cider-eval-result-prefix
'face 'cider-result-overlay-face)
(format "%s" value))
props)))
(let* ((display-string (concat (propertize " " 'cursor 1000)
cider-eval-result-prefix
(format "%s" value)))
(o (apply #'cider--make-overlay
(line-beginning-position) (line-end-position)
'result
'after-string
(if cider-ovelays-use-font-lock
display-string
(propertize display-string 'face 'cider-result-overlay-face))
props)))
(pcase duration
((pred numberp) (run-at-time duration nil #'cider--delete-overlay o))
(`command (add-hook 'post-command-hook #'cider--remove-result-overlay nil 'local)))
Expand Down