|
From: | Stefan Reichör |
Subject: | Improved help from minibuffer prompts |
Date: | Tue, 13 Apr 2004 08:26:11 +0200 |
User-agent: | Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (berkeley-unix) |
Hi! I am currently working on xtla.el (the arch interface for emacs). In my mode the user is often asked some questions in the minibuffer. Sometimes the questions need some more explanations. So I decided to put the needed help in the function's docstring. The user can ask emacs for the documentation by hitting f1 in the minibuffer prompt. I think the idea could be nice for emacs as well. Here is the relevant code from xtla.el: (defun xtla-display-command-help (command &optional current-prompt) (save-excursion (other-window -1) (let ((cmd-help (when (fboundp command) (documentation command)))) (with-current-buffer (get-buffer-create "*xtla-command-help*") (delete-region (point-min) (point-max)) (insert (if cmd-help (format "Help for %S:\n%s" command cmd-help) (format "No help available for %S" command))))) (Electric-pop-up-window "*xtla-command-help*") (resize-temp-buffer-window) (other-window 1))) (define-key minibuffer-local-map [f1] 'xtla-show-command-help) (define-key minibuffer-local-completion-map [f1] 'xtla-show-command-help) (define-key minibuffer-local-must-match-map [f1] 'xtla-show-command-help) (defvar xtla-command-stack nil) (defun xtla-minibuffer-setup () (push this-command xtla-command-stack)) (add-hook 'minibuffer-setup-hook 'xtla-minibuffer-setup) (defun xtla-minibuffer-exit () (pop xtla-command-stack)) (add-hook 'minibuffer-exit-hook 'xtla-minibuffer-exit) (defun xtla-show-command-help () (interactive) (xtla-display-command-help (car xtla-command-stack) (minibuffer-prompt))) Now you can hit f1 when a minibuffer prompt is displayed and you get the function's docstring. I like this functionality very much - and I think it would be worth to be added to the core emacs. What do you think? -- Stefan.
[Prev in Thread] | Current Thread | [Next in Thread] |