[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13599: 24.2; (max-char) is too low (and hard to change)

From: Stefan Monnier
Subject: bug#13599: 24.2; (max-char) is too low (and hard to change)
Date: Fri, 01 Feb 2013 09:24:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> Yes, I've been using
>     (define-key key-translation-map (kbd "s-8") (kbd "["))
> It works in most cases. But unfortunately read-char does not care about
> this translation, leaving lots of functions broken. That lead me to
> keyboard-translate, then here.

I think the problem is in read-char.

You might like to try the following redefinition of read-char, which I've
been using locally for a while (i.e. tested for a reasonably long time
but only by a single user):

   (defun read-char (&optional prompt) ;; (inherit-input-method seconds)
     "Read a character from the command input (keyboard or macro).
   It is returned as a number.
   If the character has modifiers, they are resolved and reflected to the
   character code if possible (e.g. C-SPC -> 0).
   If the user generates an event which is not a character (i.e. a mouse
   click or function key event), `read-char' signals an error.  As an
   exception, switch-frame events are put off until non-character events
   can be read.
   If you want to read non-character events, or ignore them, call
   `read-event' or `read-char-exclusive' instead.
   If the optional argument PROMPT is non-nil, display that as a prompt.
   If the optional argument INHERIT-INPUT-METHOD is non-nil and some
   input method is turned on in the current buffer, that input method
   is used for reading a character.
   If the optional argument SECONDS is non-nil, it should be a number
   specifying the maximum number of seconds to wait for input.  If no
   input arrives in that time, return nil.  SECONDS may be a
   floating-point value."
     ;; if (! NILP (prompt))
     ;;   message_with_string ("%s", prompt, 0);
     ;; val = read_filtered_event (1, 1, 1, ! NILP (inherit_input_method),
     ;;                            seconds);
     ;; return (NILP (val) ? Qnil
     ;;         : make_number (char_resolve_modifier_mask (XINT (val))));
     (let ((inherit-input-method nil) (seconds nil))
       ;; `read-key' doesn't explicitly inhibit the input method, but in
       ;; practice it disables at least quail input methods because it
       ;; binds overriding-terminal-local-map.
       (if inherit-input-method (error "Not implemented"))
       (catch 'read-char-exclusive
         (let ((timer (when seconds
                        (run-with-timer seconds nil
                                        (lambda ()
                                          (throw 'read-char-exclusive nil))))))
               (let ((event (read-key prompt)))
                 (if (numberp event)
                   (setq unread-command-events
                         (nconc (mapcar 'identity 
                   (error "Non-character input-event")))
             (when timer (cancel-timer timer)))))))

-- Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]