summaryrefslogtreecommitdiff
path: root/cider-scratch.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2016-10-09 12:12:56 +0300
committerBozhidar Batsov <bozhidar@batsov.com>2016-10-09 12:12:56 +0300
commit111d9571897f8aafa816c65f97e2eda87ee68b3c (patch)
tree550e6daedbd19faed01ff6c99dc19689da8053c3 /cider-scratch.el
parent579a8dd8924d24265d0d06cbb48742bd5725ec7e (diff)
[Fix #1789] Make it easier to change the connection of the scratch
buffer It wasn't really apparent how one was supposed to change the connection of a scratch buffer, so the relevant command was added to the mode's menu. I've also added another command to quickly toggle a buffer's connection between Clojure and ClojureScript.
Diffstat (limited to 'cider-scratch.el')
-rw-r--r--cider-scratch.el25
1 files changed, 23 insertions, 2 deletions
diff --git a/cider-scratch.el b/cider-scratch.el
index e794afd3..6dc495fe 100644
--- a/cider-scratch.el
+++ b/cider-scratch.el
@@ -32,12 +32,23 @@
(require 'cider-interaction)
(require 'clojure-mode)
+(require 'easymenu)
(defvar cider-clojure-interaction-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map clojure-mode-map)
(define-key map (kbd "C-j") #'cider-eval-print-last-sexp)
(define-key map [remap paredit-newline] #'cider-eval-print-last-sexp)
+ (easy-menu-define cider-clojure-interaction-mode-menu map
+ "Menu for Clojure Interaction mode"
+ '("Clojure Interaction"
+ (["Eval and print last sexp" #'cider-eval-print-last-sexp]
+ "--"
+ ["Reset" #'cider-scratch-reset]
+ "--"
+ ["Set buffer connection" #'cider-assoc-buffer-with-connection]
+ ["Toggle buffer connection" #'cider-toggle-buffer-connection]
+ ["Reset buffer connection" #'cider-clear-buffer-local-connection])))
map))
(defconst cider-scratch-buffer-name "*cider-scratch*")
@@ -62,14 +73,24 @@ before point, and prints its value into the buffer, advancing point.
\\{cider-clojure-interaction-mode-map}")
+(defun cider--scratch-insert-welcome-message ()
+ "Insert the welcome message for the scratch buffer."
+ (insert ";; This buffer is for Clojure experiments and evaluation.\n"
+ ";; Press C-j to evaluate the last expression.\n\n"))
+
(defun cider-create-scratch-buffer ()
"Create a new scratch buffer."
(with-current-buffer (get-buffer-create cider-scratch-buffer-name)
(cider-clojure-interaction-mode)
- (insert ";; This buffer is for Clojure experiments and evaluation.\n"
- ";; Press C-j to evaluate the last expression.\n\n")
+ (cider--scratch-insert-welcome-message)
(current-buffer)))
+(defun cider-scratch-reset ()
+ "Reset the current scratch buffer."
+ (interactive)
+ (erase-buffer)
+ (cider--scratch-insert-welcome-message))
+
(provide 'cider-scratch)
;;; cider-scratch.el ends here