Skip to content

Commit

Permalink
[#1543] Add some getting started instructions to the welcome banner
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Feb 6, 2016
1 parent 5e58c4b commit d6155b1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and try to associate the created connection with this project automatically.
* Typing `s` in a debug session shows the current stack.
* Typing `h` (as in *h*ere) skips all sexps until the current point position.
* [#1507](https://github.com/clojure-emacs/cider/issues/1507): Add the ability to control the REPL's scroll on output functionality via `cider-repl-scroll-on-output`.
* [#1543](https://github.com/clojure-emacs/cider/issues/1543): Add some getting started instructions to the welcome banner.

### Changes

Expand Down
38 changes: 37 additions & 1 deletion cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ you'd like to use the default Emacs behavior use
:type 'symbol
:group 'cider-repl)

(defcustom cider-repl-display-help-banner t
"When non-nil a bit of help text will be displayed on REPL start."
:type 'boolean
:group 'cider-repl
:package-version '(cider . "0.11.0"))


;;;; REPL buffer local variables
(defvar-local cider-repl-input-start-mark nil)
Expand Down Expand Up @@ -287,11 +293,41 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
(cider--clojure-version)
(cider--nrepl-version)))

(defun cider-repl--help-banner ()
"Generate the help banner."
(substitute-command-keys
"\n; ================================================================================
; Welcome to CIDER!
;
; If you're new to CIDER it is highly recommended to go through its manual first.
; Press <\\[cider-view-manual]> to view it.
; In case you're seeing any warnings you should consult the manual's \"Troubleshooting\" section.
;
; Here are few tips to get you started:
;
; * Press <\\[describe-mode]> to see a list of the keybindings available (this will work in every Emacs buffer)
; * Press <\\[cider-repl-handle-shortcut]> to quickly invoke some REPL command
; * Press <\\[cider-switch-to-last-clojure-buffer]> to switch between the REPL and a Clojure source buffer
; * Press <\\[cider-find-var]> to jump to the source of something (e.g. a var, a Java method)
; * Press <\\[cider-doc]> to view the documentation for something (e.g. a var, a Java method)
;
; CIDER is super customizable - try <M-x customize-group cider> to get
; a feel for this.
;
; If you think you've encountered a bug (or have some suggestions for improvements) press <\\[cider-report-bug]>.
;
; Above all else - don't panic! In case of an emergency - procure some (hard) cider and enjoy it responsibly!
;
; You can disable this message from appearing on start by setting `cider-repl-display-help-banner' to nil.
; ================================================================================"))

(defun cider-repl--insert-banner-and-prompt (buffer)
"Insert REPL banner and REPL prompt in BUFFER."
(with-current-buffer buffer
(when (zerop (buffer-size))
(insert (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face)))
(insert (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face))
(when cider-repl-display-help-banner
(insert (propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))))
(goto-char (point-max))
(cider-repl--mark-output-start)
(cider-repl--mark-input-start)
Expand Down

3 comments on commit d6155b1

@Malabarba
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. 👍

@pcn
Copy link

@pcn pcn commented on d6155b1 Feb 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@AdrieanKhisbe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
One less excuse for me to go for clojure&cider :D

Please sign in to comment.