Skip to content

Shifted key translation #153

Open
Open
@bernardjoseph

Description

Some key bindings, like C-N for next-line, have shift-select-mode activated when called with an uppercase letter, which activates the mark. This does not work in God mode, because the key sequence is tranlated to C-S-N, which has no binding. For example, when I prees C-N with uppercase N, next-line with a highlighted region (because I have transient-mark-mode set) is called. When I press uppercase N in God mode, I get an error "Unknown key binding for 'C-S-N'". For now, I have modified the :else branch in god-mode-lookup-command as follows, which seems to work for me:

(defun god-mode-lookup-command (key-string)
  "Execute extended keymaps in KEY-STRING, or call it if it is a command."
  (when key-string
    (let* ((key-vector (read-kbd-macro key-string t))
           (binding (key-binding key-vector)))
      (cond ((commandp binding)
             (setq last-command-event
                   (aref key-vector (- (length key-vector) 1)))
             binding)
            ((keymapp binding)
             (god-mode-lookup-key-sequence nil key-string))
            (:else
             (if (and (string-match "S-\\(.\\)\\'" key-string)
                      (string= (get-char-code-property
                                (aref (match-string 1 key-string) 0)
                                'general-category)
                               "Lu"))
                 (god-mode-lookup-command (replace-regexp-in-string
                                           "S-\\(.\\)\\'" "\\1" key-string))
               (error "God: Unknown key binding for `%s`" key-string)))))))

In my understanding, Emacs translates all bindings with uppercase letters without binding to their lowercase counterparts. I do not know if my solution is acceptable; it looks a bit rude to me, but it works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions