diff options
| author | Teemu Likonen <tlikonen@iki.fi> | 2026-04-25 16:55:29 +0300 |
|---|---|---|
| committer | Teemu Likonen <tlikonen@iki.fi> | 2026-04-25 20:03:46 +0300 |
| commit | d9cea40a86751e646bfeb06826454c94e18bb2d7 (patch) | |
| tree | a5d59cb62c4ed07b699ced2dac16540afaf47213 | |
| parent | 2266582fc65dba667a39f4f5b4f9076e1dfedbbb (diff) | |
Improve the logic and appearance of --choose-action-minibufferexternals/wcheck-mode
| -rw-r--r-- | wcheck-mode.el | 49 |
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)) |
