summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wcheck-mode.el49
1 files changed, 28 insertions, 21 deletions
diff --git a/wcheck-mode.el b/wcheck-mode.el
index 5987224..aa6e3c9 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -1805,29 +1805,33 @@ string) or nil."
(number-sequence ?a ?z)))
(chars-actions nil)
- (suggestions
+ (choices
(with-temp-buffer
- (while (and actions chars)
- (let ((action (pop actions))
- (char (pop chars)))
- (push (cons char (cdr action)) chars-actions)
+ (let ((action nil)
+ (char nil)
+ (choice nil))
+ (while (and actions chars)
+ (setq action (pop actions)
+ char (pop chars)
+ choice (concat
+ (propertize (format "[%c]" char)
+ 'face 'font-lock-comment-face)
+ " "
+ (car action)))
- (insert (propertize (format "%c)" char)
- 'face 'bold)
- " "
- (wcheck--clean-string (car action))
- " ")
+ (push (cons char (cdr action)) chars-actions)
+ (let ((line-pos (- (point) (line-beginning-position))))
+ (when (and (> line-pos 0)
+ (>= (+ line-pos 2 (length choice)) ; 2 spaces
+ (window-width (minibuffer-window))))
+ (newline 1)))
- (when (and actions chars
- (> (+ (- (point) (line-beginning-position))
- (length (concat "x) " (caar actions))))
- (window-width (minibuffer-window))))
- (delete-char -2)
- (newline 1))))
+ (when (> (point) (line-beginning-position))
+ (insert " "))
+ (insert choice)))
- (delete-char -2)
(newline 1)
-
+ (add-text-properties (point-min) (point-max) '(read-only t))
(buffer-substring (point-min) (point-max))))
(prompt
@@ -1848,9 +1852,12 @@ string) or nil."
minibuffer-prompt-properties)))
;; Return the choice or nil.
- (cond ((cdr (assq (read-key (concat suggestions prompt))
- chars-actions)))
- (t (message "Abort") nil)))
+ (let ((choice (cdr (assq (read-key (concat choices prompt))
+ chars-actions))))
+ (if choice
+ choice
+ (message "Abort")
+ nil)))
(message "No actions")
nil))