From: Matthew Leach <matthew@mattleach.net>
To: emacs-devel@gnu.org
Subject: Insert `help-char' when pressed twice.
Date: Tue, 14 Apr 2015 14:35:19 +0100 [thread overview]
Message-ID: <87bniqn888.fsf@mattleach.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 580 bytes --]
Hi all,
I recently came across a small annoyance when I was working in sh-mode.
If we open a temporary .sh file and attempts to insert a conditional
with C-TAB, we are presented with a minibuffer prompt to insert the
conditional. Now, Suppose we wanted to insert `[ $? -ne 0 ]'. This is
next to impossible as pressing `?' will constantly open the temporary
help buffer.
Attached is a patch to help remedy this. If the help message is already
visible to the user, insert the `help-char' that the user pressed into
the minibuffer.
Any feedback would be appreciated.
--
Matt
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Insert-help-char-if-the-help-buffer-is-already-shown.patch --]
[-- Type: text/x-diff, Size: 2080 bytes --]
From 4b42e24835a76d625f865c67622143c0f58c55a4 Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@mattleach.net>
Date: Tue, 14 Apr 2015 14:17:08 +0100
Subject: [PATCH] Insert `help-char' if the help buffer is already shown
* src/keyboard.c (read_char): Call `help-form-show' with the character
that caused the function to be called.
* lisp/help.el (help-form-show): If the temporary help window is
already visible when called, insert the `help-char' that the user
pressed.
---
lisp/help.el | 15 +++++++++++----
src/keyboard.c | 2 +-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/help.el b/lisp/help.el
index fb1719a..cf134d5 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1339,11 +1339,18 @@ the help window if the current value of the user option
;; Called from C, on encountering `help-char' when reading a char.
;; Don't print to *Help*; that would clobber Help history.
-(defun help-form-show ()
- "Display the output of a non-nil `help-form'."
- (let ((msg (eval help-form)))
+(defun help-form-show (char)
+ "Display the output of a non-nil `help-form'. If called while
+`help-form' is being displayed, insert the help char."
+ (let* ((msg (eval help-form))
+ (tmp-help-buf-name " *Char Help*")
+ (tmp-help-buf (get-buffer tmp-help-buf-name))
+ (should-insert-char (and tmp-help-buf
+ (get-buffer-window tmp-help-buf))))
+ (when should-insert-char
+ (insert-char char))
(if (stringp msg)
- (with-output-to-temp-buffer " *Char Help*"
+ (with-output-to-temp-buffer tmp-help-buf-name
(princ msg)))))
\f
diff --git a/src/keyboard.c b/src/keyboard.c
index 068a47c..08c74e1 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3188,7 +3188,7 @@ read_char (int commandflag, Lisp_Object map,
= Fcons (Fcurrent_window_configuration (Qnil),
help_form_saved_window_configs);
record_unwind_protect_void (read_char_help_form_unwind);
- call0 (Qhelp_form_show);
+ call1 (Qhelp_form_show, c);
cancel_echoing ();
do
--
2.3.5
next reply other threads:[~2015-04-14 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 13:35 Matthew Leach [this message]
2015-04-14 16:52 ` Insert `help-char' when pressed twice Stefan Monnier
2015-04-14 16:43 ` Matthew Leach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bniqn888.fsf@mattleach.net \
--to=matthew@mattleach.net \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.