Skip to content

Commit 54ac59a

Browse files
dpsuttonbbatsov
authored andcommitted
Modeline with connected info
note this changes the `inf-clojure-buffer` to always be a _buffer_ and not the name of a buffer. Seems like renaming can be quite risky since it was just a name of the buffer rather than the buffer.
1 parent f24722c commit 54ac59a

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

inf-clojure.el

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
274274
\(as in :a, :c, etc.)"
275275
:type 'regexp)
276276

277+
(defun inf-clojure--modeline-info ()
278+
"Return modeline info.
279+
Either \"not connected\" or \"repl-type: buffer-name\""
280+
(if (bufferp inf-clojure-buffer)
281+
(with-current-buffer inf-clojure-buffer
282+
(format "%s: %s" inf-clojure-repl-type (buffer-name (current-buffer))))
283+
"not connected"))
284+
277285
(defvar inf-clojure-mode-map
278286
(let ((map (copy-keymap comint-mode-map)))
279287
(define-key map (kbd "C-x C-e") #'inf-clojure-eval-last-sexp)
@@ -358,14 +366,31 @@ mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
358366
["Quit REPL" inf-clojure-quit]))
359367
map))
360368

369+
;;;###autoload
370+
(defcustom inf-clojure-mode-line
371+
'(:eval (format " inf-clojure[%s]" (inf-clojure--modeline-info)))
372+
"Mode line lighter for cider mode.
373+
374+
The value of this variable is a mode line template as in
375+
`mode-line-format'. See Info Node `(elisp)Mode Line Format' for details
376+
about mode line templates.
377+
378+
Customize this variable to change how inf-clojure-minor-mode
379+
displays its status in the mode line. The default value displays
380+
the current connection. Set this variable to nil to disable the
381+
mode line entirely."
382+
:type 'sexp
383+
:risky t)
384+
361385
;;;###autoload
362386
(define-minor-mode inf-clojure-minor-mode
363387
"Minor mode for interacting with the inferior Clojure process buffer.
364388
365389
The following commands are available:
366390
367391
\\{inf-clojure-minor-mode-map}"
368-
:lighter "" :keymap inf-clojure-minor-mode-map
392+
:lighter inf-clojure-mode-line
393+
:keymap inf-clojure-minor-mode-map
369394
(setq-local comint-input-sender 'inf-clojure--send-string)
370395
(inf-clojure-eldoc-setup)
371396
(make-local-variable 'completion-at-point-functions)
@@ -703,7 +728,7 @@ process buffer for a list of commands.)"
703728
(inf-clojure-mode)
704729
(setq-local inf-clojure-repl-type repl-type)
705730
(hack-dir-local-variables-non-file-buffer))))
706-
(setq inf-clojure-buffer "*inf-clojure*")
731+
(setq inf-clojure-buffer (get-buffer "*inf-clojure*"))
707732
(if inf-clojure-repl-use-same-window
708733
(pop-to-buffer-same-window "*inf-clojure*")
709734
(pop-to-buffer "*inf-clojure*")))

0 commit comments

Comments
 (0)