emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] speed commands: error message when a key is not associated with a command
Date: Sat, 30 Apr 2022 11:25:39 +0000	[thread overview]
Message-ID: <87pmkyvmmk.fsf@posteo.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]

Hi,

If we have speed commands activated and we type (by mistake) a character
not associated with a command, the letter is printed at point. I think a
more appropriate behavior would be:

- key associated with a command: the command is activated

- key not associated with a command: an error message is displayed.

Attached a patch with that modification.

Best regards,

Juan Manuel 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org-keys.el-error-message-when-speed-command-is.patch --]
[-- Type: text/x-patch, Size: 1489 bytes --]

From fd380f41420aef9bc91baede9d4cd2cb7eadee0a Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Sat, 30 Apr 2022 13:00:02 +0200
Subject: [PATCH] lisp/org-keys.el: error message when speed command is not
 defined

* (org-speed-command-activate): If a letter is not associated with a
command, an error message is displayed instead of typing the letter.
---
 lisp/org-keys.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 782ffa871..a850abb4f 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -835,12 +835,14 @@ See `org-speed-commands' for configuring them."
   (when (or (and (bolp) (looking-at org-outline-regexp))
 	    (and (functionp org-use-speed-commands)
 		 (funcall org-use-speed-commands)))
-    (cdr (assoc keys
-                ;; FIXME: don't check `org-speed-commands-user' past 9.6
-                (if (boundp 'org-speed-commands-user)
-                    (append org-speed-commands
-                            org-speed-commands-user)
-                  org-speed-commands)))))
+    (let ((defined (cdr (assoc keys
+			       ;; FIXME: don't check `org-speed-commands-user' past 9.6
+			       (if (boundp 'org-speed-commands-user)
+				   (append org-speed-commands
+					   org-speed-commands-user)
+				 org-speed-commands)))))
+      (if defined defined
+	(error "Speed command not defined: \"h\" for help")))))
 
 \f
 ;;; Babel speed keys
-- 
2.36.0


             reply	other threads:[~2022-04-30 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-30 11:25 Juan Manuel Macías [this message]
2022-04-30 13:06 ` [PATCH] speed commands: error message when a key is not associated with a command Ihor Radchenko
2022-04-30 14:41   ` Juan Manuel Macías
2022-04-30 19:39     ` Juan Manuel Macías
2022-05-01  4:01     ` Ihor Radchenko
2022-05-01 11:00       ` Juan Manuel Macías
2022-05-02  3:31         ` Ihor Radchenko
2022-05-03 23:08           ` Juan Manuel Macías

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmkyvmmk.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).