From 3d7f51d872194ebf17fe4eb5cd0bb9411e196726 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 10 Aug 2025 21:08:29 +0300 Subject: [PATCH] * lisp/man.el (man): Use active region for the default value. While reading a manual name, provide text from the selected region as another default value for the second 'M-n' in the minibuffer. Also replace spaces with dashes in the name. --- lisp/man.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/man.el b/lisp/man.el index 9e1d294b1ec..49873c5a87b 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1123,7 +1123,14 @@ for the current invocation." (and (not (equal default-entry "")) default-entry)) #'Man-completion-table - nil nil nil 'Man-topic-history default-entry))) + nil nil nil 'Man-topic-history + `(,default-entry + ,@(when (use-region-p) + (list (string-replace + " " "-" + (buffer-substring-no-properties + (region-beginning) + (region-end))))))))) (if Man-cache-completion-results-flag (read) (let ((Man-completion-cache)) (read))))))