Skip to content

Commit b446fee

Browse files
committed
Extract words-of-inspiration and tips into cider-inspiration.el
cider-util.el is meant to be small cross-cutting utilities, but a ~160-line block at the bottom held the random connect-greeting quotes (cider-words-of-inspiration) and the keybinding tips list (cider-tips), plus the trivial pickers around them (cider-random-words-of-inspiration, cider-inspire-me, cider-random-tip, cider-drink-a-sip, cider-user-first-name). All data + trivial random selectors, nothing to do with general utilities. Move that block to its own file. Three modules consume these: - cider.el calls cider-random-words-of-inspiration (default for cider-connection-message-fn) and cider-random-tip (via the docs). - cider-mode.el and cider-repl.el reference cider-drink-a-sip in keybindings. Each gets an explicit (require 'cider-inspiration); cider-util.el no longer carries this data. cider-util.el drops from 905 to 742 lines. cider-inspiration.el is 203 lines.
1 parent b93abfe commit b446fee

5 files changed

Lines changed: 206 additions & 163 deletions

File tree

lisp/cider-inspiration.el

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
;;; cider-inspiration.el --- Inspirational quotes and tips -*- lexical-binding: t -*-
2+
3+
;; Copyright © 2012-2026 Tim King, Phil Hagelberg, Bozhidar Batsov
4+
;; Copyright © 2013-2026 Bozhidar Batsov, Artur Malabarba and CIDER contributors
5+
;;
6+
;; Author: Tim King <kingtim@gmail.com>
7+
;; Phil Hagelberg <technomancy@gmail.com>
8+
;; Bozhidar Batsov <bozhidar@batsov.dev>
9+
;; Artur Malabarba <bruce.connor.am@gmail.com>
10+
;; Hugo Duncan <hugo@hugoduncan.org>
11+
;; Steve Purcell <steve@sanityinc.com>
12+
;; Maintainer: Bozhidar Batsov <bozhidar@batsov.dev>
13+
14+
;; This program is free software: you can redistribute it and/or modify
15+
;; it under the terms of the GNU General Public License as published by
16+
;; the Free Software Foundation, either version 3 of the License, or
17+
;; (at your option) any later version.
18+
19+
;; This program is distributed in the hope that it will be useful,
20+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
;; GNU General Public License for more details.
23+
24+
;; You should have received a copy of the GNU General Public License
25+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
27+
;; This file is not part of GNU Emacs.
28+
29+
;;; Commentary:
30+
31+
;; A small grab-bag of random quotes (`cider-words-of-inspiration', shown
32+
;; on connect via `cider--maybe-inspire-on-connect') and discoverability
33+
;; tips (`cider-tips', surfaced via `cider-drink-a-sip'). Pure data plus
34+
;; the trivial pickers around it.
35+
36+
;;; Code:
37+
38+
;;; Words of inspiration
39+
(defun cider-user-first-name ()
40+
"Find the current user's first name."
41+
(let ((name (if (string= (user-full-name) "")
42+
(user-login-name)
43+
(user-full-name))))
44+
(string-match "^[^ ]*" name)
45+
(capitalize (match-string 0 name))))
46+
47+
(defvar cider-words-of-inspiration
48+
`("The best way to predict the future is to invent it. -Alan Kay"
49+
"A point of view is worth 80 IQ points. -Alan Kay"
50+
"Lisp isn't a language, it's a building material. -Alan Kay"
51+
"Simple things should be simple, complex things should be possible. -Alan Kay"
52+
"Everything should be as simple as possible, but not simpler. -Albert Einstein"
53+
"Measuring programming progress by lines of code is like measuring aircraft building progress by weight. -Bill Gates"
54+
"Controlling complexity is the essence of computer programming. -Brian Kernighan"
55+
"The unavoidable price of reliability is simplicity. -C.A.R. Hoare"
56+
"You're bound to be unhappy if you optimize everything. -Donald Knuth"
57+
"Simplicity is prerequisite for reliability. -Edsger W. Dijkstra"
58+
"Elegance is not a dispensable luxury but a quality that decides between success and failure. -Edsger W. Dijkstra"
59+
"Deleted code is debugged code. -Jeff Sickel"
60+
"The key to performance is elegance, not battalions of special cases. -Jon Bentley and Doug McIlroy"
61+
"First, solve the problem. Then, write the code. -John Johnson"
62+
"Simplicity is the ultimate sophistication. -Leonardo da Vinci"
63+
"Programming is not about typing... it's about thinking. -Rich Hickey"
64+
"Design is about pulling things apart. -Rich Hickey"
65+
"Programmers know the benefits of everything and the tradeoffs of nothing. -Rich Hickey"
66+
"Code never lies, comments sometimes do. -Ron Jeffries"
67+
"The true delight is in the finding out rather than in the knowing. -Isaac Asimov"
68+
"If paredit is not for you, then you need to become the sort of person that paredit is for. -Phil Hagelberg"
69+
"Express Yourself. -Madonna"
70+
"Put on your red shoes and dance the blues. -David Bowie"
71+
"Do. Or do not. There is no try. -Yoda"
72+
"The enjoyment of one's tools is an essential ingredient of successful work. -Donald E. Knuth"
73+
"Not all those who wander are lost. -J.R.R. Tolkien"
74+
"The best way to learn is to do. -P.R. Halmos"
75+
"If you wish to make an apple pie from scratch, you must first invent the universe. -Carl Sagan"
76+
"Learn the rules like a pro, so you can break them like an artist. -Pablo Picasso"
77+
"The only way of discovering the limits of the possible is to venture a little way past them into the impossible. -Arthur C. Clarke"
78+
"Don't wish it were easier. Wish you were better. -Jim Rohn"
79+
"One chord is fine. Two chords is pushing it. Three chords and you're into jazz. -Lou Reed"
80+
"We are all apprentices in a craft where no one ever becomes a master. -Ernest Hemingway"
81+
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. -Antoine de Saint-Exupery"
82+
"Clojure isn't a language, it's a building material."
83+
"Think big!"
84+
"Think bold!"
85+
"Think fun!"
86+
"Code big!"
87+
"Code bold!"
88+
"Code fun!"
89+
"Take this REPL, fellow hacker, and may it serve you well."
90+
"Let the hacking commence!"
91+
"Hacks and glory await!"
92+
"Hack and be merry!"
93+
"Your hacking starts... NOW!"
94+
"May the Source be with you!"
95+
"May the Source shine upon thy REPL!"
96+
"Code long and prosper!"
97+
"Happy hacking!"
98+
"nREPL server is up, CIDER REPL is online!"
99+
"CIDER REPL operational!"
100+
"Your imagination is the only limit to what you can do with this REPL!"
101+
"This REPL is yours to command!"
102+
"Fame is but a hack away!"
103+
"The REPL is not enough, but it is such a perfect place to start..."
104+
"Keep on codin' in the free world!"
105+
"What we do in the REPL echoes in eternity!"
106+
"Evaluating is believing."
107+
"To infinity... and beyond."
108+
"Showtime!"
109+
"Unfortunately, no one can be told what CIDER is. You have to figure this out yourself."
110+
"Procure a bottle of cider to achieve optimum programming results."
111+
"In parentheses we trust!"
112+
"Write you some Clojure for Great Good!"
113+
"Oh, what a day... what a lovely day!"
114+
"What a day! What cannot be accomplished on such a splendid day!"
115+
"Home is where your REPL is."
116+
"The worst day programming is better than the best day working."
117+
"The only thing worse than a rebel without a cause is a REPL without a clause."
118+
"In the absence of parentheses, chaos prevails."
119+
"One REPL to rule them all, One REPL to find them, One REPL to bring them all, and in parentheses bind them!"
120+
"A blank REPL promotes creativity."
121+
"A blank REPL is infinitely better than a blank cheque."
122+
"May your functions be pure, your code concise and your programs a joy to behold!"
123+
,(format "%s, I've a feeling we're not in Kansas anymore."
124+
(cider-user-first-name))
125+
,(format "%s, this could be the start of a beautiful program."
126+
(cider-user-first-name)))
127+
"Scientifically-proven optimal words of hackerish encouragement.")
128+
129+
(defun cider-random-words-of-inspiration ()
130+
"Select a random entry from `cider-words-of-inspiration'."
131+
(nth (random (length cider-words-of-inspiration))
132+
cider-words-of-inspiration))
133+
134+
(defun cider-inspire-me ()
135+
"Display a random inspiration message."
136+
(interactive)
137+
(message (cider-random-words-of-inspiration)))
138+
139+
(defvar cider-tips
140+
'("Press <\\[cider-connect]> to connect to a running nREPL server."
141+
"Press <\\[cider-quit]> to quit the current connection."
142+
"Press <\\[cider-view-manual]> to view CIDER's manual."
143+
"Press <\\[cider-view-refcard]> to view CIDER's refcard."
144+
"Press <\\[describe-mode]> to see a list of the keybindings available (this will work in every Emacs buffer)."
145+
"Press <\\[cider-repl-handle-shortcut]> to quickly invoke some REPL command."
146+
"Press <\\[cider-switch-to-last-clojure-buffer]> to switch between the REPL and a Clojure source buffer."
147+
"Press <\\[cider-doc]> to view the documentation for something (e.g. a var, a Java method)."
148+
"Press <\\[cider-find-resource]> to find a resource on the classpath."
149+
"Press <\\[cider-find-var]> to jump to the source of something (e.g. a var, a Java method)."
150+
"Press <\\[cider-selector]> to quickly select a CIDER buffer."
151+
"Press <\\[cider-test-run-ns-tests]> to run the tests for the current namespace."
152+
"Press <\\[cider-test-run-loaded-tests]> to run all loaded tests."
153+
"Press <\\[cider-test-run-project-tests]> to run all tests for the current project."
154+
"Press <\\[cider-apropos]> to look for a symbol by some search string."
155+
"Press <\\[cider-apropos-documentation]> to look for a symbol that has some string in its docstring."
156+
"Press <\\[cider-eval-defun-at-point]> to eval the top-level form at point."
157+
"Press <\\[cider-eval-dwim]> to eval to run cider-eval-region if a region is active, and cider-eval-defun-at-point otherwise."
158+
"Press <\\[cider-eval-defun-up-to-point]> to eval the top-level form up to the point."
159+
"Press <\\[cider-eval-sexp-up-to-point]> to eval the current form up to the point."
160+
"Press <\\[cider-eval-sexp-at-point]> to eval the current form around the point."
161+
"Press <\\[cider-eval-sexp-at-point-in-context]> to eval the current form around the point in a user-provided context."
162+
"Press <\\[cider-eval-buffer]> to eval the entire source buffer."
163+
"Press <\\[cider-scratch]> to create a Clojure scratchpad. Pretty handy for prototyping."
164+
"Press <\\[cider-read-and-eval]> to evaluate some Clojure expression directly in the minibuffer."
165+
"Press <\\[cider-drink-a-sip]> to get more CIDER tips."
166+
"Press <\\[cider-browse-ns-all]> to start CIDER's namespace browser."
167+
"Press <\\[cider-classpath]> to start CIDER's classpath browser."
168+
"Press <\\[cider-repl-history]> to start CIDER's REPL input history browser."
169+
"Press <\\[cider-macroexpand-1]> to expand the preceding macro."
170+
"Press <\\[cider-inspect]> to inspect the preceding expression's result."
171+
"Press <C-u \\[cider-inspect]> to inspect the defun at point's result."
172+
"Press <C-u C-u \\[cider-inspect]> to read Clojure code from the minibuffer and inspect its result."
173+
"Press <\\[cider-ns-refresh]> to reload modified and unloaded namespaces."
174+
"You can define Clojure functions to be called before and after `cider-ns-refresh' (see `cider-ns-refresh-before-fn' and `cider-ns-refresh-after-fn'."
175+
"Press <\\[cider-describe-connection]> to view information about the connection."
176+
"Press <\\[cider-undef]> to undefine a symbol in the current namespace."
177+
"Press <\\[cider-interrupt]> to interrupt an ongoing evaluation."
178+
"Use <M-x customize-group RET cider RET> to see every possible setting you can customize."
179+
"Use <M-x customize-group RET cider-repl RET> to see every possible REPL setting you can customize."
180+
"Enable `eldoc-mode' to display function & method signatures in the minibuffer."
181+
"Enable `cider-enlighten-mode' to display the locals of a function when it's executed."
182+
"Use <\\[cider-close-ancillary-buffers]> to close all ancillary buffers created by CIDER (e.g. *cider-doc*)."
183+
"Exploring CIDER's menu-bar entries is a great way to discover features."
184+
"Keep in mind that some commands don't have a keybinding by default. Explore CIDER!"
185+
"Tweak `cider-repl-prompt-function' to customize your REPL prompt."
186+
"Tweak `cider-eldoc-ns-function' to customize the way namespaces are displayed by eldoc."
187+
"For no middleware, low-tech and reliable namespace reloading use <\\[cider-ns-reload]>."
188+
"Press <\\[cider-load-buffer-and-switch-to-repl-buffer]> to load the current buffer and switch to the REPL buffer afterwards.")
189+
"Some handy CIDER tips."
190+
)
191+
192+
(defun cider-random-tip ()
193+
"Select a random tip from `cider-tips'."
194+
(substitute-command-keys (nth (random (length cider-tips)) cider-tips)))
195+
196+
(defun cider-drink-a-sip ()
197+
"Show a random tip."
198+
(interactive)
199+
(message (cider-random-tip)))
200+
201+
(provide 'cider-inspiration)
202+
203+
;;; cider-inspiration.el ends here

lisp/cider-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
(require 'clojure-mode)
3535
(require 'cider-eval)
36+
(require 'cider-inspiration)
3637
(require 'cider-test) ; required only for the menu
3738
(require 'cider-eldoc)
3839
(require 'cider-resolve)

lisp/cider-repl.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
(require 'cider-client)
4747
(require 'cider-doc)
48+
(require 'cider-inspiration)
4849
(require 'cider-test)
4950
(require 'cider-eldoc) ; for cider-eldoc-setup
5051
(require 'cider-common)

0 commit comments

Comments
 (0)