diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-08-06 00:03:49 -0700 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-08-06 00:03:49 -0700 |
| commit | 5568c780e1b609a18728c592c0f85d798b6a1a47 (patch) | |
| tree | 0f0c7adccf22f946581d44d33cad3746b5a32c9a | |
| parent | 85868c2c64ee09a33cb2086ed4efff0bdd435998 (diff) | |
Show the default value in the minibuffer prompt
Closes #139
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | helpful.el | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f95cf81..ed5be07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ recognised as being autoloaded. Fixed an issue where we didn't show the source code for advised primitives. +Show the default value for the symbol in the minibuffer prompt. + # v0.12 Added a 'pretty view' for string values, keymap values, and hooks. @@ -2130,11 +2130,21 @@ escapes that are used by `substitute-command-keys'." docstring)) (defun helpful--read-symbol (prompt predicate) - (let ((sym-here (symbol-at-point))) + (let* ((sym-here (symbol-at-point)) + (default-val + (when (funcall predicate sym-here) + (symbol-name sym-here)))) + (when default-val + ;; TODO: Only modify the prompt when we don't have ido/ivy/helm, + ;; because the default is obvious for them. + (setq prompt + (replace-regexp-in-string + (rx ": " eos) + (format " (default: %s): " default-val) + prompt))) (read (completing-read prompt obarray predicate t nil nil - (when (funcall predicate sym-here) - (symbol-name sym-here)))))) + default-val)))) ;;;###autoload (defun helpful-function (symbol) |
