You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use crux-start-or-switch-to with slime-connect function there is problem that slime-connect names its buffer according to the type of common lisp implementation that it connected to, so the resulting buffer can be named "slime-repl sbcl", "slime-repl ccl" etc. I slightly changed the function, adding a helper get-buffer-extended function:
(defun get-buffer-extended (buffer-name &optional match)
"Finds a buffer by its name. If the optional parameter MATCH is then call the standard
GET-BUFFER, if MATCH is :PREFIX, then it looks for buffers with names starting with BUFFER-NAME
and returns the first one that matches. When MATCH is :REGEXP does the same but BUFFER-NAME
is a regular expression."
(cond ((null match) (get-buffer buffer-name))
((eq match :regexp)
(catch 'done
(dolist (buffer (buffer-list))
(let ((name (buffer-name buffer)))
(when (string-match buffer-name name)
(throw 'done buffer))))))
((eq match :prefix)
(catch 'done
(dolist (buffer (buffer-list))
(let ((name (buffer-name buffer)))
(when (string-prefix-p buffer-name name)
(throw 'done buffer))))))))
(defun start-or-switch-to (function buffer-name &optional match)
"Modified crux-start-or-switch-to from https://github.com/bbatsov/crux/blob/master/crux.el
Add MATCH parameter that can be :prefix to find any buffer that starts with BUFFER-NAME or
:REGEXP to use regular expressions in the search string."
(let ((buf (get-buffer-extended buffer-name match)))
(if (not buf)
(progn
(split-window-sensibly (selected-window))
(other-window 1)
(funcall function))
(switch-to-buffer-other-window buf))))
There probably are other cases like this, where the names of the buffers can vary, so maybe such generalization may be of use.
The text was updated successfully, but these errors were encountered:
When trying to use crux-start-or-switch-to with slime-connect function there is problem that slime-connect names its buffer according to the type of common lisp implementation that it connected to, so the resulting buffer can be named "slime-repl sbcl", "slime-repl ccl" etc. I slightly changed the function, adding a helper get-buffer-extended function:
There probably are other cases like this, where the names of the buffers can vary, so maybe such generalization may be of use.
The text was updated successfully, but these errors were encountered: