Skip to content

Commit

Permalink
Fix #473: Use vanilla completing-read
Browse files Browse the repository at this point in the history
Close #475.

Sly no longer wraps 'completing-read' to force ido to provide better
UX.  This was interfering with completion frameworks that don't set
the 'completing-read-function' such as 'vertico' and 'mct'.

Co-authored-by: João Távora <joao.tavora@gmail.com>

* lib/sly-messages.el (sly-completing-read): Remove wrapper function
that only serves to force ido-completion

* contrib/sly-mrepl.el (sly-mrepl-shortcut): Use vanilla completing-read
* sly.el (sly-read-package-name): Use vanilla completing-read
(sly--read-interactive-args): Use vanilla completing-read
(sly-prompt-for-connection): Use vanilla completing-read
(sly-switch-to-most-recent): Use vanilla completing-read
(sly-info): Use vanilla completing-read
(sly-db-invoke-restart-by-name): Use vanilla completing-read
(sly-read-connection): Use vanilla completing-read
(sly-read-inspector-name): Use vanilla completing-read
(sly-contrib--read-contrib-name): Use vanilla completing-read
  • Loading branch information
theothornhill authored and joaotavora committed Nov 21, 2021
1 parent 6669067 commit 0470c02
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Upcoming version
----------------

### Remove `sly-completing-read`

SLY no longer bypasses `completing-read-function` to provide basic
`ido` completion. This used to make sense when fewer fancy
well-behaved completion packages existed. That's no longer the case
so we shouldn't override the user's preference.


SLY 1.0.42 (December 2020)
------------------------------

Expand Down
10 changes: 5 additions & 5 deletions contrib/sly-mrepl.el
Original file line number Diff line number Diff line change
Expand Up @@ -1342,11 +1342,11 @@ When setting this variable outside of the Customize interface,

(defun sly-mrepl-shortcut ()
(interactive)
(let* ((string (sly-completing-read "Command: "
(mapcar #'car sly-mrepl-shortcut-alist)
nil 'require-match nil
'sly-mrepl-shortcut-history
(car sly-mrepl-shortcut-history)))
(let* ((string (completing-read "Command: "
(mapcar #'car sly-mrepl-shortcut-alist)
nil 'require-match nil
'sly-mrepl-shortcut-history
(car sly-mrepl-shortcut-history)))
(command (and string
(cdr (assoc string sly-mrepl-shortcut-alist)))))
(call-interactively command)))
Expand Down
19 changes: 0 additions & 19 deletions lib/sly-messages.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,6 @@ SIT-FOR is has the semantincs of `minibuffer-message-timeout', which see."
(or (cl-position ?\n string) most-positive-fixnum)
(1- (window-width (minibuffer-window))))))

(defun sly-completing-read (prompt choices &optional
predicate
require-match
initial-input
hist
def
inherit-input-method)
"Like `completing-read', but tweak `completing-read-function'.
Specifically, if the `completion-read-function' has not been
tweaked, and `icomplete-mode' is not being used, use
`ido-completing-read' to provide a better UX."
(let ((completing-read-function
(if (and (eq completing-read-function 'completing-read-default)
(not icomplete-mode))
#'ido-completing-read
completing-read-function)))
(completing-read prompt choices predicate require-match initial-input hist def
inherit-input-method)))

(defun sly-y-or-n-p (format-string &rest args)
(let ((prompt (apply #'format (concat "[sly] "
format-string)
Expand Down
32 changes: 16 additions & 16 deletions sly.el
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ move to make TARGET visible."
If ALLOW-BLANK may return nil to signal no particular package
selected."
(let* ((completion-ignore-case t)
(res (sly-completing-read
(res (completing-read
(concat "[sly] " prompt)
(sly-eval
`(slynk:list-all-package-names t))
Expand Down Expand Up @@ -1130,7 +1130,7 @@ Helper for M-x sly"
(sly--guess-inferior-lisp-program t))
(list :program program :program-args args)))))
((eq current-prefix-arg '-)
(let ((key (sly-completing-read
(let ((key (completing-read
"Lisp name: " (mapcar (lambda (x)
(list (symbol-name (car x))))
sly-lisp-implementations)
Expand Down Expand Up @@ -2123,7 +2123,7 @@ Respect `sly-keep-buffers-on-connection-close'."
connection-names)
connection-names))
(connection-name (and connection-names
(sly-completing-read
(completing-read
(or prompt "Connection: ")
connection-names
nil (not dont-require-match))))
Expand Down Expand Up @@ -2776,7 +2776,7 @@ Debugged requests are ignored."
With prefix argument, prompt for MODE"
(interactive
(list (if current-prefix-arg
(intern (sly-completing-read
(intern (completing-read
"Switch to most recent buffer in what mode? "
(mapcar #'symbol-name '(lisp-mode
emacs-lisp-mode))
Expand Down Expand Up @@ -4669,9 +4669,9 @@ TODO"
(interactive
(let ((file (sly-info--file)))
(list file
(sly-completing-read "Manual node? (`Top' to read the whole manual): "
(remove '("*") (sly-info--node-names file))
nil t))))
(completing-read "Manual node? (`Top' to read the whole manual): "
(remove '("*") (sly-info--node-names file))
nil t))))
(info (if node (format "(%s)%s" file node) file)))


Expand Down Expand Up @@ -6095,9 +6095,9 @@ Interactively get the number from a button at point."

(defun sly-db-invoke-restart-by-name (restart-name)
(interactive (list (let ((completion-ignore-case t))
(sly-completing-read "Restart: " sly-db-restarts nil t
""
'sly-db-invoke-restart-by-name))))
(completing-read "Restart: " sly-db-restarts nil t
""
'sly-db-invoke-restart-by-name))))
(sly-db-invoke-restart (cl-position restart-name sly-db-restarts
:test 'string= :key 'first)))

Expand Down Expand Up @@ -6151,8 +6151,8 @@ Return the net process, or nil."
(sly-connection-name p) (sly-pid p))))
(candidates (mapcar (lambda (p) (cons (funcall to-string p) p))
sly-net-processes)))
(cdr (assoc (sly-completing-read prompt candidates
nil t (funcall to-string initial-value))
(cdr (assoc (completing-read prompt candidates
nil t (funcall to-string initial-value))
candidates))))

(defun sly-db-step (frame-number)
Expand Down Expand Up @@ -6538,9 +6538,9 @@ was called originally."
(eq major-mode 'sly-inspector-mode)))
when (buffer-local-value 'sly--this-inspector-name b)
collect it))
(result (sly-completing-read "Inspector name: " (cons "default"
names)
nil nil nil nil "default")))
(result (completing-read "Inspector name: " (cons "default"
names)
nil nil nil nil "default")))
(unless (string= result "default")
result)))

Expand Down Expand Up @@ -6996,7 +6996,7 @@ if/when you fix the error" (cl-third n))))
(defun sly-contrib--read-contrib-name ()
(let ((names (cl-loop for c in (sly-contrib--all-contribs) collect
(symbol-name (sly-contrib--name c)))))
(intern (sly-completing-read "Contrib: " names nil t))))
(intern (completing-read "Contrib: " names nil t))))

(defun sly-enable-contrib (name)
"Attempt to enable contrib NAME."
Expand Down

0 comments on commit 0470c02

Please sign in to comment.