From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Adding a "quick-help" menu Date: Fri, 16 Sep 2022 21:03:54 +0000 Message-ID: <8735cr3ubp.fsf@posteo.net> References: <87v8pn4968.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10893"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 16 23:04:56 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZIW7-0002Ye-JK for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Sep 2022 23:04:55 +0200 Original-Received: from localhost ([::1]:43450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZIW6-0002KR-MR for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Sep 2022 17:04:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZIVJ-0001e2-Aw for emacs-devel@gnu.org; Fri, 16 Sep 2022 17:04:05 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:52483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZIVG-0000Ht-R0 for emacs-devel@gnu.org; Fri, 16 Sep 2022 17:04:05 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E5B1C240101 for ; Fri, 16 Sep 2022 23:04:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1663362240; bh=udv/U8zR4Jzq/jgzdqs01cWS6DuwNrSwJXV8X7hXQbs=; h=From:To:Subject:Autocrypt:Date:From; b=SIzvzYnilBnya5YRVTsT4glQRy+K1myPAHeh/WaFMjXpFFacrej2++93jm/KDJWKU VfdbwGi6TOBMtuDc0WxhlvPfJNY0k+jKxAx8CvxxonQJianEDndldBko0CL8EUxZ+t kYcOQ6Lh9iXyQ4Z4qMha0z9mCIRa1ttN0bj83VqhvBAb/SzXPgikbCzlZn5OyeifLO rGTxdrpK+ff/ELRHxCBJCohzQBYCSYYtcaBCFLIqnUmQ7XudL6ERYX9uwsmDc/8DT1 ODwr2aZ4CvcggqLQgj08Cqx4+rscAhK5N7CeedYkoRajB9bPVaNjixCQ9Bn77jfgS0 72HZr9qS7eT4Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MTmlN2WgXz6tn8 for ; Fri, 16 Sep 2022 23:04:00 +0200 (CEST) In-Reply-To: <87v8pn4968.fsf@posteo.net> (Philip Kaludercic's message of "Fri, 16 Sep 2022 15:43:11 +0000") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295505 Archived-At: Philip Kaludercic writes: > There is a fork of mg (MicroEmacs)[0] that binds C-h q to a command that > pops up a buffer with these contents: > > FILE BUFFER WINDOW MARK/KILL MISC > C-x C-c exit C-x C-k close C-0 only other C-space mark C-_ undo > C-x C-f find C-x k other C-1 only this C-w wipe C-s search > C-x C-s save C-x C-b list C-2 split two C-k close C-r r-search > C-x s all C-x b switch C-x ^ enlarge C-y yank M-% replace > C-x i insert C-x g goto ln C-x o other win C-x C-x swap M-q reformat > ______________________________________________________________________________ > C-h q toggle quick help | C-h t show tutorial | C-h b show key bindings > > I notice that in GNU Emacs C-h q is bound to `help-quit', which does > nothing if you are not in the help command loop. Would having a > "quick-help" menu along these lines for common operations make sense for > GNU Emacs as well? > > [0] https://github.com/troglobit/mg Here is a quick sketch of how this could look like: --8<---------------cut here---------------start------------->8--- (defvar help-quick-sections '(("... FILE" (save-buffers-kill-terminal . "exit") (find-file . "find") (save-buffer . "save") (save-some-buffers . "all") (insert-file . "insert")) ("... BUFFER" (kill-buffer . "kill") (other-window . "other") (list-buffers . "list") (switch-to-buffer . "switch") (goto-line . "goto line")) ("... WINDOW" (delete-window . "only other") (delete-other-windows . "only this") (split-window-below . "split vert.") (split-window-right . "split horiz.") (enlarge-window . "enlarge") (other-window . "other")) ("MARK/KILL" (set-mark-command . "mark") (kill-region . "wipe") (kill-line . "kill") (yank . "yank") (exchange-point-and-mark . "swap")) ("MISC" (undo . "undo") (isearch-forward . "search") (isearch-backward . "rev-search") (query-replace . "replace") (fill-paragraph . "reformat"))))z ;; Inspired by a mg fork (https://github.com/troglobit/mg) (defun help-quick () "Display a quick-help buffer." (interactive) (with-current-buffer (get-buffer-create "*Quick Help*") (let ((inhibit-read-only t) blocks) (dolist (section help-quick-sections) (let ((max-key-len 0) (max-cmd-len 0) keys) (dolist (ent (reverse (cdr section))) (let* ((bind (where-is-internal (car ent) nil t)) (key (if bind (propertize (key-description bind) 'face 'help-key-binding) " -/-"))) (setq max-cmd-len (max (length (cdr ent)) max-cmd-len) max-key-len (max (length key) max-key-len)) (push (cons key (cdr ent)) keys))) (let ((fmt (format "%%-%ds %%-%ds " max-key-len max-cmd-len))) (push `(,(propertize (concat (car section) (make-string (- (+ max-key-len 1 max-cmd-len 3) (length (car section))) ?\s)) 'face 'shortdoc-heading) ,@(mapcar (lambda (ent) (format fmt (car ent) (cdr ent))) keys)) blocks)))) (erase-buffer) (dolist (block (nreverse blocks)) (when (> (+ (length (car block)) (current-column)) (window-width)) (goto-char (point-max)) (newline 2)) (save-excursion (insert-rectangle block)) (end-of-line)) (delete-trailing-whitespace)) ;; Display the buffer at the bottom of the page and shrink it ;; immediately. (help-mode) (read-only-mode t) (let ((win (display-buffer-at-bottom (current-buffer) '()))) (fit-window-to-buffer win) (select-window win) (goto-char (point-min))))) --8<---------------cut here---------------end--------------->8---