unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13599: 24.2; (max-char) is too low (and hard to change)
@ 2013-01-31 18:42 Magnar Sveen
  2013-01-31 19:08 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Magnar Sveen @ 2013-01-31 18:42 UTC (permalink / raw)
  To: 13599

Due to my weird norwegian keyboard, I'm trying to map my s-8 to [.

Doing a M-: (read-char) s-8 gives me the key value of 8388664.

Following that up with (keyboard-translate 8388664 ?\[) does not work,
since it fails the (characterp) test. Turns out that (max-char) is a C
function that returns the highest allowed keycode. On my Emacs, that
is 4194303.

Since (max-char) is a function and not a variable, and a C function at
that (not advisable when called from another C function (characterp)) -
I am left without options to rectify it. Or maybe I could use a hex
editor. :-)

So, is this a bug? Is it weird that max-char is a function? In C? Ought
4194303 chars be enough for anybody? That's up to you guys to decide.

Kind regards,
Magnar Sveen


In GNU Emacs 24.2.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36)
 of 2012-09-04 on fi-bp-202.local
Windowing system distributor `Apple', version 10.3.1038
Configured using:
 `configure '--prefix=/usr/local/Cellar/emacs/24.2' '--without-dbus'
 '--enable-locallisppath=/usr/local/share/emacs/site-lisp'
 '--infodir=/usr/local/Cellar/emacs/24.2/share/info/emacs' '--with-ns'
 '--disable-ns-self-contained' 'CC=/usr/bin/gcc-4.2' 'CFLAGS=-Os -w
 -pipe -march=core2 -msse4 -mmacosx-version-min=10.6'
 'LDFLAGS=-L/usr/local/lib''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  elisp-slime-nav-mode: t
  hardcore-mode: t
  show-paren-mode: t
  global-hl-line-mode: t
  ido-ubiquitous-mode: t
  eproject-mode: t
  paredit-mode: t
  persp-mode: t
  yas/global-mode: t
  yas/minor-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-subword-mode: t
  subword-mode: t
  recentf-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
c s-8 <down-mouse-1> <mouse-1> C-y C-x C-e s-8 C-_ 
C-a M-f - u n C-d C-e C-b C-w C-_ <backspace> <backspace> 
<backspace> <backspace> C-e C-x C-e s-8 s-8 C-_ C-_ 
C-_ C-_ C-_ C-e C-x C-e s-8 C-q s-8 C-_ C-_ M-_ M-_ 
M-_ M-_ C-d C-d C-d C-b <backspace> <backspace> <backspace> 
<backspace> C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-u C-n C-p C-p 
C-p C-p u n C-e C-x C-e C-a C-k C-b C-x C-e q s-8 s-8 
C-q s-8 <f1> f r e a d - c h a r <return> M-: ( r e 
a d - c h a r ) <return> s-8 <f1> k C-q <S-right> <tab> 
<return> C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-q s-8 M-: <up> <return> s-8 
C-n C-n C-n C-n C-n C-x b <return> C-x C-e <S-right> 
q M-: <up> <return> s-8 C-x C-e <S-left> <S-right> 
<tab> <tab> <return> <S-right> <up> <up> <return> C-n 
C-n C-n C-n <f1> f c h a r a c t e r p <return> <S-right> 
M-: ( m a x - x h a r <backspace> <backspace> <backspace> 
<backspace> c h a r ) <return> M-: <up> C-g <f1> f 
m a x - c h a r <return> <S-right> <tab> <return> C-g 
q <f1> f c h a r a c t e r p <return> <S-right> <tab> 
C-n C-n C-n C-n C-a M-w <S-tab> <return> C-g q M-x 
e m a c s - r e b <backspace> p o <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> r e p o r t <r
eturn>

Recent messages:
4194303 (#o17777777, #x3fffff)
Quit

windmove-do-window-select: No window right from selected window
mouse-2, RET: find function's definition
Quit
Type "q" in help window to restore its previous buffer.
mouse-2, RET: find function's definition
Copied to end of line
mouse-2, RET: find function's definition
Quit

Load-path shadows:
/Users/fimasvee/.emacs.d/elpa/hardcore-mode-1.0.0/hardcore-mode hides /Users/fimasvee/.emacs.d/site-lisp/hardcore-mode/hardcore-mode
/Users/fimasvee/.emacs.d/site-lisp/fill-column-indicator/fill-column-indicator hides /Users/fimasvee/.emacs.d/site-lisp/fill-column-indicator
~/.emacs.d/users/fimasvee/init hides ~/.emacs.d/init
/Users/fimasvee/.emacs.d/elpa/magit-20130109.2027/rebase-mode hides /usr/local/share/emacs/site-lisp/rebase-mode
/Users/fimasvee/.emacs.d/site-lisp/delsel/delsel hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/delsel
~/.emacs.d/custom hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/custom
/usr/local/share/emacs/site-lisp/trampver hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/trampver
/usr/local/share/emacs/site-lisp/tramp hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp
/usr/local/share/emacs/site-lisp/tramp-uu hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-uu
/usr/local/share/emacs/site-lisp/tramp-smb hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-smb
/usr/local/share/emacs/site-lisp/tramp-sh hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-sh
/usr/local/share/emacs/site-lisp/tramp-loaddefs hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-loaddefs
/usr/local/share/emacs/site-lisp/tramp-gw hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-gw
/usr/local/share/emacs/site-lisp/tramp-ftp hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-ftp
/usr/local/share/emacs/site-lisp/tramp-compat hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-compat
/usr/local/share/emacs/site-lisp/tramp-cmds hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-cmds
/usr/local/share/emacs/site-lisp/tramp-cache hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-cache
/Users/fimasvee/.emacs.d/elpa/magit-20130109.2027/.dir-locals hides /usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/gnus/.dir-locals

Features:
(shadow sort mail-extr emacsbug debug dired-aux git-commit-mode rx
php-mode flymake cc-langs setup-magit magit-svn magit-bisect
magit-key-mode magit diff-mode log-edit pcvs-util add-log mule-util
zencoding-mode rename-sgml-tag crappy-jsp-mode js-mode-expansions js
json cc-mode-expansions cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs jsp-expansions
html-mode-expansions tagedit sgml-mode hippie-exp css-mode-expansions
css-mode misearch multi-isearch tabify conf-mode newcomment org-wl
org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs
org-html org-exp ob-exp org-exp-blocks find-func org-agenda org-info
org-gnus org-docview org-bibtex bibtex org-bbdb network-stream starttls
tls vc-git adventur-mode alternatives-mode adv-refill refill
adv-indentation adv-keybindings adv-defuns adv-refactorings
adv-new-number adv-named-rooms adv-search adv-enter adv-tab adv-escape
adv-dash adv-jump-candidate adv-syntax-highlighting adv-intelli nrepl
arc-mode archive-mode setup-clojure-mode clj-refactor
clojure-mode-expansions clojure-mode inf-lisp tramp tramp-compat
tramp-loaddefs setup-shell shell-command shell adv-utils adv-regexes
regex-dsl unsafep elisp-slime-nav etags oppdrag-mode my-defuns
hardcore-mode server setup-mu4e mu4e mu4e-speedbar speedbar sb-image
ezimage dframe mu4e-main mu4e-view epa epg epg-config browse-url
longlines mu4e-headers mu4e-compose mu4e-actions org-capture org-mks
setup-org org-mode-expansions org ob-emacs-lisp ob-tangle ob-ref ob-lob
ob-table org-footnote org-src ob-comint ob-keys ob ob-eval org-pcomplete
pcomplete org-list org-faces org-compat org-entities org-macs noutline
outline cal-menu calendar cal-loaddefs rfc2368 smtpmail auth-source
gnus-util password-cache sendmail mu4e-mark mu4e-message html2text
mu4e-proc mu4e-utils doc-view jka-compr image-mode setup-dired
dired-details dired mu4e-about mu4e-vars message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
mu4e-meta diminish mac my-misc appearance zoom-frm frame-cmds frame-fns
avoid paren hl-line key-bindings windmove smex setup-ido ido-ubiquitous
ido browse-kill-ring fill-column-indicator multifiles change-inner
smart-forward wgrep setup-rgrep grep compile comint ansi-color eproject
esh-var esh-io esh-cmd esh-ext esh-proc esh-arg eldoc esh-groups eshell
esh-module esh-mode esh-util ace-jump-mode jump-char multiple-cursors
mc-insert-numbers rectangular-region-mode mc-mark-more thingatpt
mc-cycle-cursors mc-edit-lines multiple-cursors-core rect
inline-string-rectangle mark-more-like-this mark-multiple expand-region
text-mode-expansions expand-region-custom expand-region-core file-defuns
imenu mode-mappings setup-paredit s dash regexp-opt paredit
setup-html-mode setup-ffip find-file-in-project setup-perspective
perspective setup-yasnippet buster-snippets buster-snippet-helpers
yasnippet dropdown-list derived help-mode view assoc setup-hippie
exec-path-from-shell sane-defaults uniquify undo-tree edmacro kmacro
diff cl smooth-scrolling warnings advice help-fns advice-preload subword
winner ring recentf tree-widget wid-edit easymenu delsel easy-mmode
autorevert setup-package elisp-slime-nav-autoloads es-lib-autoloads
exec-path-from-shell-autoloads gist-autoloads gh-autoloads eieio
byte-opt bytecomp byte-compile cconv macroexp git-commit-mode-autoloads
gitconfig-mode-autoloads gitignore-mode-autoloads
goto-last-change-autoloads hardcore-mode-autoloads htmlize-autoloads
logito-autoloads magit-autoloads move-text-autoloads nrepl-autoloads
clojure-mode-autoloads paredit-autoloads pcache-autoloads finder-inf
popwin-autoloads slime-js-autoloads slime-repl-autoloads slime-autoloads
package tabulated-list saveplace time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 18:42 bug#13599: 24.2; (max-char) is too low (and hard to change) Magnar Sveen
@ 2013-01-31 19:08 ` Eli Zaretskii
  2013-01-31 19:44   ` Magnar Sveen
  2013-01-31 21:22   ` Josh
  0 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2013-01-31 19:08 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 13599

> From: Magnar Sveen <magnars@gmail.com>
> Date: Thu, 31 Jan 2013 19:42:27 +0100
> 
> Due to my weird norwegian keyboard, I'm trying to map my s-8 to [.
> 
> Doing a M-: (read-char) s-8 gives me the key value of 8388664.

Which is 800038 in hex.  Rings any bells?  (Hint: 38 hex is the digit
8.)

> Following that up with (keyboard-translate 8388664 ?\[) does not work,
> since it fails the (characterp) test. Turns out that (max-char) is a C
> function that returns the highest allowed keycode. On my Emacs, that
> is 4194303.
> 
> Since (max-char) is a function and not a variable, and a C function at
> that (not advisable when called from another C function (characterp)) -
> I am left without options to rectify it. Or maybe I could use a hex
> editor. :-)

Your s-8 is a character with a modifier.  max-char returns the max
value of a character, excluding any modifiers.  So that value has
nothing to do with your difficulties in binding s-8 to insert [.
Something entirely different is at work here, probably some problem in
the code that you used to do the key binding.  But since you didn't
show that code, it's hard to help you.

> So, is this a bug?

No.

> Is it weird that max-char is a function? In C?

That's precisely so people will be unable to change the value.  It's
immutable.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 19:08 ` Eli Zaretskii
@ 2013-01-31 19:44   ` Magnar Sveen
  2013-01-31 20:20     ` Eli Zaretskii
  2013-01-31 21:22   ` Josh
  1 sibling, 1 reply; 12+ messages in thread
From: Magnar Sveen @ 2013-01-31 19:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13599

Thanks for the quick response!

Eli Zaretskii writes:

>> Doing a M-: (read-char) s-8 gives me the key value of 8388664.
>
> Which is 800038 in hex.  Rings any bells?  (Hint: 38 hex is the digit
> 8.)

That makes sense, thanks.

> Your s-8 is a character with a modifier.  max-char returns the max
> value of a character, excluding any modifiers.  So that value has
> nothing to do with your difficulties in binding s-8 to insert [.
> Something entirely different is at work here, probably some problem in
> the code that you used to do the key binding.  But since you didn't
> show that code, it's hard to help you.

I did show the code:

    (keyboard-translate 8388664 ?\[)

I also tried

    (keyboard-translate ?\s-8 ?\[)

which of course is the same thing. They both fail at (characterp).

In my flailing, I also tried

    (keyboard-translate (kbd "s-8") ?\[)

No success with that one. Checking that I was not totally off, I tried

    (keyboard-translate ?\C-h ?\[)

which did work, while

    (keyboard-translate ?\C-8 ?\[)

did not. Not a character again. So it's not only super.

>> So, is this a bug?

> No.

Fair enough.

Any tips on how to actually translate keys where read-char returns a
value including the modifier then?

- Magnar





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 19:44   ` Magnar Sveen
@ 2013-01-31 20:20     ` Eli Zaretskii
  2013-02-01  6:13       ` Magnar Sveen
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2013-01-31 20:20 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 13599

> From: Magnar Sveen <magnars@gmail.com>
> Cc: 13599@debbugs.gnu.org
> Date: Thu, 31 Jan 2013 20:44:58 +0100
> 
>     (keyboard-translate ?\C-h ?\[)
> 
> which did work, while
> 
>     (keyboard-translate ?\C-8 ?\[)
> 
> did not. Not a character again. So it's not only super.

keyboard-translate doesn't support keys with modifiers.  Use
global-set-key instead, after defining a function that inserts the [
character.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 19:08 ` Eli Zaretskii
  2013-01-31 19:44   ` Magnar Sveen
@ 2013-01-31 21:22   ` Josh
  2013-02-01  7:43     ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Josh @ 2013-01-31 21:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Magnar Sveen, 13599

On Thu, Jan 31, 2013 at 11:08 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Magnar Sveen <magnars@gmail.com>
[...]
>> Doing a M-: (read-char) s-8 gives me the key value of 8388664.
>
> Which is 800038 in hex.  Rings any bells?  (Hint: 38 hex is the digit
> 8.)
>
>> Following that up with (keyboard-translate 8388664 ?\[) does not work,
>> since it fails the (characterp) test. Turns out that (max-char) is a C
[...]
>> So, is this a bug?
>
> No.

At a minimum the fact that (characterp (read-char)) can ever return
nil indicates disagreement between the two functions about exactly
what a "character" is.  It would be good to reconcile this
disagreement in their documentation if nothing else.

Given the existence of read-key, is it necessary for read-char to be
able to return values greater than MAX_CHAR?  If it's indeed
necessary, would it be reasonable to add an optional parameter to
read-char for callers such as quoted-insert to specify that read-char
should return only values <= MAX_CHAR?

Josh

On Thu, Jan 31, 2013 at 11:08 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Magnar Sveen <magnars@gmail.com>
>> Date: Thu, 31 Jan 2013 19:42:27 +0100
>>
>> Due to my weird norwegian keyboard, I'm trying to map my s-8 to [.
>>
>> Doing a M-: (read-char) s-8 gives me the key value of 8388664.
>
> Which is 800038 in hex.  Rings any bells?  (Hint: 38 hex is the digit
> 8.)
>
>> Following that up with (keyboard-translate 8388664 ?\[) does not work,
>> since it fails the (characterp) test. Turns out that (max-char) is a C
>> function that returns the highest allowed keycode. On my Emacs, that
>> is 4194303.
>>
>> Since (max-char) is a function and not a variable, and a C function at
>> that (not advisable when called from another C function (characterp)) -
>> I am left without options to rectify it. Or maybe I could use a hex
>> editor. :-)
>
> Your s-8 is a character with a modifier.  max-char returns the max
> value of a character, excluding any modifiers.  So that value has
> nothing to do with your difficulties in binding s-8 to insert [.
> Something entirely different is at work here, probably some problem in
> the code that you used to do the key binding.  But since you didn't
> show that code, it's hard to help you.
>
>> So, is this a bug?
>
> No.
>
>> Is it weird that max-char is a function? In C?
>
> That's precisely so people will be unable to change the value.  It's
> immutable.
>
>
>





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 20:20     ` Eli Zaretskii
@ 2013-02-01  6:13       ` Magnar Sveen
  2013-02-01  7:41         ` Eli Zaretskii
  2013-02-01 14:24         ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Magnar Sveen @ 2013-02-01  6:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13599

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

On Thu, Jan 31, 2013 at 9:20 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> keyboard-translate doesn't support keys with modifiers.  Use
> global-set-key instead, after defining a function that inserts the [
> character.
>

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.

- Magnar

[-- Attachment #2: Type: text/html, Size: 1143 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-02-01  6:13       ` Magnar Sveen
@ 2013-02-01  7:41         ` Eli Zaretskii
  2013-02-01  8:10           ` Magnar Sveen
  2013-02-01 14:27           ` Stefan Monnier
  2013-02-01 14:24         ` Stefan Monnier
  1 sibling, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2013-02-01  7:41 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 13599

> From: Magnar Sveen <magnars@gmail.com>
> Date: Fri, 1 Feb 2013 07:13:50 +0100
> Cc: 13599@debbugs.gnu.org
> 
> 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.

Why do you care about read-char?  What functions are broken after the
above?  And why do you use key-translation-map and not global-map (or
global-set-key)?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-01-31 21:22   ` Josh
@ 2013-02-01  7:43     ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2013-02-01  7:43 UTC (permalink / raw)
  To: Josh; +Cc: magnars, 13599

> From: Josh <josh@foxtail.org>
> Date: Thu, 31 Jan 2013 13:22:20 -0800
> Cc: Magnar Sveen <magnars@gmail.com>, 13599@debbugs.gnu.org
> 
> At a minimum the fact that (characterp (read-char)) can ever return
> nil indicates disagreement between the two functions about exactly
> what a "character" is.

Yes, "character" is an overloaded term.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-02-01  7:41         ` Eli Zaretskii
@ 2013-02-01  8:10           ` Magnar Sveen
  2013-02-01 14:27           ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Magnar Sveen @ 2013-02-01  8:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13599

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

Eli Zaretskii writes:

>> From: Magnar Sveen <magnars@gmail.com>
>>
>>     (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.
>
> Why do you care about read-char?

Because it is widely used in commands, and now is broken.

> What functions are broken after the above?

Off the top of my head, (paredit-backslash) and (quoted-insert).

> And why do you use key-translation-map and not global-map (or
global-set-key)?

I had a hope that it was lower level than global-set-key.

- Magnar

[-- Attachment #2: Type: text/html, Size: 1024 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-02-01  6:13       ` Magnar Sveen
  2013-02-01  7:41         ` Eli Zaretskii
@ 2013-02-01 14:24         ` Stefan Monnier
  2013-02-01 17:38           ` Magnar Sveen
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2013-02-01 14:24 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 13599

> 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))))))
           (unwind-protect
               (let ((event (read-key prompt)))
                 (if (numberp event)
                     event
                   (setq unread-command-events
                         (nconc (mapcar 'identity (this-single-command-raw-keys))
                                unread-command-events))
                   (error "Non-character input-event")))
             (when timer (cancel-timer timer)))))))

-- Stefan





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-02-01  7:41         ` Eli Zaretskii
  2013-02-01  8:10           ` Magnar Sveen
@ 2013-02-01 14:27           ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2013-02-01 14:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Magnar Sveen, 13599

>> (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.
> Why do you care about read-char?

Because he wants to be able to type [ (which isn't on his keyboard so
he wants to use s-8 for that) even in response to a read-char.

> What functions are broken after the above?

None are broken, but some don't pay attention to key-translation-map
(e.g. all those that use read-char).

> And why do you use key-translation-map and not global-map (or
> global-set-key)?

Probably so that he can use bindings such as C-x [


        Stefan





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#13599: 24.2; (max-char) is too low (and hard to change)
  2013-02-01 14:24         ` Stefan Monnier
@ 2013-02-01 17:38           ` Magnar Sveen
  0 siblings, 0 replies; 12+ messages in thread
From: Magnar Sveen @ 2013-02-01 17:38 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13599


Stefan Monnier writes:

> 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):
>
> <snip>

Thank you, Stefan, that did help.

Since quoted-insert calls read-char from C code, that one still won't
work with the redefined read-char - but my paredit-backslash woes are
over, so that is a definite step forward. Thanks!

- Magnar





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-02-01 17:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-31 18:42 bug#13599: 24.2; (max-char) is too low (and hard to change) Magnar Sveen
2013-01-31 19:08 ` Eli Zaretskii
2013-01-31 19:44   ` Magnar Sveen
2013-01-31 20:20     ` Eli Zaretskii
2013-02-01  6:13       ` Magnar Sveen
2013-02-01  7:41         ` Eli Zaretskii
2013-02-01  8:10           ` Magnar Sveen
2013-02-01 14:27           ` Stefan Monnier
2013-02-01 14:24         ` Stefan Monnier
2013-02-01 17:38           ` Magnar Sveen
2013-01-31 21:22   ` Josh
2013-02-01  7:43     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).