unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
@ 2021-10-27 20:42 Mark Bestley
  2021-10-27 21:48 ` Gregory Heytings
  2021-10-28  7:12 ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Bestley @ 2021-10-27 20:42 UTC (permalink / raw)
  To: 51449

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

In emacs -Q just need something to get the Alt key bound
e.g.
(setq  mac-command-modifier 'alt)

The when you Type A-c you get ¢ and you cannot bind it yourself.

On a mac I want the key by space to be Alt as that is what is printed on
my PC keyboard. I suspect this is true with PCs

The issue is that (require 'iso-transl) is called before the user can alter its behaviour and that iso-transl.el then binds to various A-c and other keys.

This makes it impossible to use Alt as a modifier key

load-history shows

("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/subdirs.el <http://emacs.app/Contents/Resources/lisp/subdirs.el>")
("/Applications/MacPorts/Emacs.app/Contents/Resources/site-lisp/subdirs.el <http://emacs.app/Contents/Resources/site-lisp/subdirs.el>")
("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/leim/leim-list.el <http://emacs.app/Contents/Resources/lisp/leim/leim-list.el>")
("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/international/iso-transl.elc <http://emacs.app/Contents/Resources/lisp/international/iso-transl.elc>" iso-transl-dead-key-alist iso-transl-char-map iso-transl-language-alist iso-transl-ctl-x-8-map
  (defun . iso-transl-define-keys)
  (defun . iso-transl-set-language)
  (provide . iso-transl))
("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/tooltip.elc <http://emacs.app/Contents/Resources/lisp/tooltip.elc>"
  (require . syntax)
 
In emacs 27 iso-transl was not called that early and only seem to be
called by describe-bindings and so could be overridden as shown in Aquamacs

Ideally iso-transl should only bind the A- keys if explicitly asked to
do so. At least the user shoulkd be able to configure the behaviour - as
exising emacs uses this wrong behaviour the default can be this setting
of A- keys but the user should be able to set something to stop this.

See
https://emacs.stackexchange.com/questions/17508/how-can-i-prevent-override-key-translation-behavior-such-as-%C2%B5-translated-from
for other users finding this (and they are not Mac based)

In GNU Emacs 28.0.50 (build 1, aarch64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.6 (Build 20G165))
of 2021-10-17 built on mini20.local
Repository revision: ccb35fb8fb9de5f069fd0103f24e3048d716febc
Repository branch: HEAD
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.6

Configured using:
'configure --prefix=/opt/local --disable-silent-rules --without-dbus
--without-gconf --without-libotf --without-m17n-flt --with-libgmp
--with-gnutls --with-json --with-xml2 --with-modules --infodir
/opt/local/share/info/emacs --with-ns --with-lcms2 --without-harfbuzz
--without-imagemagick --without-xaw3d --with-native-compilation
--with-rsvg 'CFLAGS=-pipe -Os
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch
arm64' 'CPPFLAGS=-I/opt/local/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk'
'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie
-Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
-arch arm64''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM
ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Help

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra time-date
subr-x shortdoc text-property-search seq byte-opt gv bytecomp
byte-compile cconv help-fns radix-tree help-mode cl-loaddefs cl-lib
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 80691 8984)
(symbols 48 6822 0)
(strings 32 21275 2068)
(string-bytes 1 715988)
(vectors 16 15733)
(vector-slots 8 322442 18788)
(floats 8 72 30)
(intervals 56 355 0)
(buffers 992 12))

-- 
Mark Bestley

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

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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-27 20:42 bug#51449: 28.0.50; iso-transl overwrites alt key bindings Mark Bestley
@ 2021-10-27 21:48 ` Gregory Heytings
  2021-10-28  7:12 ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Gregory Heytings @ 2021-10-27 21:48 UTC (permalink / raw)
  To: Mark Bestley; +Cc: 51449

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


Your bug report is difficult to understand.

>
> In emacs -Q just need something to get the Alt key bound
> e.g.
> (setq  mac-command-modifier 'alt)
>
> The when you Type A-c you get ¢ and you cannot bind it yourself.
>

If you do this, A-c should display "A-c is undefined", which is indeed the 
case, it's not bound to any command (in emacs -Q).

>
> On a mac I want the key by space to be Alt as that is what is printed on 
> my PC keyboard. I suspect this is true with PCs
>

If you want the key on the left of the space bar to be the Meta key in 
Emacs (which is what the Alt key usually does), you should do: (setq 
mac-command-modifier 'meta).

>
> The issue is that (require 'iso-transl) is called before the user can 
> alter its behaviour and that iso-transl.el then binds to various A-c and 
> other keys.
>

The use of the Alt modifier is indeed hardcoded in iso-transl.  If you 
want to use it, you can chose another modifier key on your keyboard, for 
example: (setq mac-right-command-modifier 'alt).  In that case the key on 
the left of your space bar will be Meta, and the key on the right of your 
space bar will be Alt.

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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-27 20:42 bug#51449: 28.0.50; iso-transl overwrites alt key bindings Mark Bestley
  2021-10-27 21:48 ` Gregory Heytings
@ 2021-10-28  7:12 ` Eli Zaretskii
  2021-10-28  8:12   ` Mark Bestley
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2021-10-28  7:12 UTC (permalink / raw)
  To: Mark Bestley; +Cc: 51449

> Date: Wed, 27 Oct 2021 21:42:19 +0100
> From: "Mark Bestley" <gnu@bestley.co.uk>
> 
> In emacs -Q just need something to get the Alt key bound
> e.g.
> (setq  mac-command-modifier 'alt)
> 
> The when you Type A-c you get ¢ and you cannot bind it yourself.
> 
> On a mac I want the key by space to be Alt as that is what is printed on
> my PC keyboard. I suspect this is true with PCs
> 
> The issue is that (require 'iso-transl) is called before the user can alter its behaviour and that iso-transl.el
> then binds to various A-c and other keys.
> 
> This makes it impossible to use Alt as a modifier key
> 
> load-history shows
> 
> ("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/subdirs.el")
> ("/Applications/MacPorts/Emacs.app/Contents/Resources/site-lisp/subdirs.el")
> ("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/leim/leim-list.el")
> ("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/international/iso-transl.elc"
> iso-transl-dead-key-alist iso-transl-char-map iso-transl-language-alist iso-transl-ctl-x-8-map
>   (defun . iso-transl-define-keys)
>   (defun . iso-transl-set-language)
>   (provide . iso-transl))
> ("/Applications/MacPorts/Emacs.app/Contents/Resources/lisp/tooltip.elc"
>   (require . syntax)
>  
> In emacs 27 iso-transl was not called that early and only seem to be
> called by describe-bindings and so could be overridden as shown in Aquamacs

iso-transl is preloaded now.  But I don't think I understand why it
gets in your way: can't you unbind the bindings that iso-transl does,
if you have no use for them, or rebind them after changing Alt to be a
modifier key if you do have use for iso-transl?

(Caveat: I don't use a Mac, so I may be missing some Mac-specific
issue here.)





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  7:12 ` Eli Zaretskii
@ 2021-10-28  8:12   ` Mark Bestley
  2021-10-28  8:40     ` Gregory Heytings
  2021-10-28  9:41     ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Bestley @ 2021-10-28  8:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 51449

On Thu, 28 Oct 2021, at 08:12, Eli Zaretskii wrote:

>
> iso-transl is preloaded now.  But I don't think I understand why it
> gets in your way: can't you unbind the bindings that iso-transl does,
> if you have no use for them, or rebind them after changing Alt to be a
> modifier key if you do have use for iso-transl?
>
> (Caveat: I don't use a Mac, so I may be missing some Mac-specific
> issue here.)

In scratch buffer on emacs - Q


(setq  mac-command-modifier 'alt)

(global-set-key (kbd "A-c")  'info)
(global-set-key (kbd "A-z")  'info)

Then A-z runs info but A-c just inserts ¢

-- 
Mark





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  8:12   ` Mark Bestley
@ 2021-10-28  8:40     ` Gregory Heytings
  2021-10-28  8:51       ` Mark Bestley
  2021-10-28  9:41     ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Gregory Heytings @ 2021-10-28  8:40 UTC (permalink / raw)
  To: Mark Bestley; +Cc: 51449

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


>
> (setq mac-command-modifier 'alt)
>
> (global-set-key (kbd "A-c")  'info)
> (global-set-key (kbd "A-z")  'info)
>
> Then A-z runs info but A-c just inserts ¢
>

That's because iso-transl uses key-translation-map, which happens before 
the key is searched in the global-map.

But what do you want to do exactly?  As I said earlier,

(setq mac-command-modifier 'meta)
(setq mac-right-command-modifier 'alt)

should I think give you what you want: a meta key on the left of the space 
bar, an alt key on the right of the space bar.

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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  8:40     ` Gregory Heytings
@ 2021-10-28  8:51       ` Mark Bestley
  2021-10-28  8:57         ` Gregory Heytings
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Bestley @ 2021-10-28  8:51 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 51449



On Thu, 28 Oct 2021, at 09:40, Gregory Heytings wrote:
>>
>> (setq mac-command-modifier 'alt)
>>
>> (global-set-key (kbd "A-c")  'info)
>> (global-set-key (kbd "A-z")  'info)
>>
>> Then A-z runs info but A-c just inserts ¢
>>
>
> That's because iso-transl uses key-translation-map, which happens before 
> the key is searched in the global-map.
>

Yes I now remember debugging this a few years ago.

> But what do you want to do exactly?  As I said earlier,
>
> (setq mac-command-modifier 'meta)
> (setq mac-right-command-modifier 'alt)
>
> should I think give you what you want: a meta key on the left of the space 
> bar, an alt key on the right of the space bar.

What I want is to make A-c run the command I want - ie be able to bind it.

The issue is that the code I use Mac-key-mode <https://www.emacswiki.org/emacs/MacKeyMode> (and also Aquamacs) uses A-c as copy to match other MacOS programs.

I would say the bigger issue is that as Eli Zaretskii  said I should be able to rebind A-c 
Another way but I think not as good would be to make the A- bindings by iso-trans only occur if I ask for them.

From Eli's email saying I can unbind the keys - how do I do that?

In earlier emacs iso-transl was not loaded early (I think was only used in describe-bindings) so that we could work around this.

-- 
Mark





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  8:51       ` Mark Bestley
@ 2021-10-28  8:57         ` Gregory Heytings
  0 siblings, 0 replies; 10+ messages in thread
From: Gregory Heytings @ 2021-10-28  8:57 UTC (permalink / raw)
  To: Mark Bestley; +Cc: 51449


>
> What I want is to make A-c run the command I want - ie be able to bind 
> it.
>

Then what you need is to unbind it in key-translation-map:

(define-key key-translation-map (kbd "A-c") nil)





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  8:12   ` Mark Bestley
  2021-10-28  8:40     ` Gregory Heytings
@ 2021-10-28  9:41     ` Eli Zaretskii
  2021-10-28 10:53       ` Mark Bestley
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2021-10-28  9:41 UTC (permalink / raw)
  To: Mark Bestley; +Cc: 51449

> Date: Thu, 28 Oct 2021 09:12:54 +0100
> From: "Mark Bestley" <gnu@bestley.co.uk>
> Cc: 51449@debbugs.gnu.org
> 
> On Thu, 28 Oct 2021, at 08:12, Eli Zaretskii wrote:
> 
> >
> > iso-transl is preloaded now.  But I don't think I understand why it
> > gets in your way: can't you unbind the bindings that iso-transl does,
> > if you have no use for them, or rebind them after changing Alt to be a
> > modifier key if you do have use for iso-transl?
> >
> > (Caveat: I don't use a Mac, so I may be missing some Mac-specific
> > issue here.)
> 
> In scratch buffer on emacs - Q
> 
> 
> (setq  mac-command-modifier 'alt)
> 
> (global-set-key (kbd "A-c")  'info)
> (global-set-key (kbd "A-z")  'info)
> 
> Then A-z runs info but A-c just inserts ¢

I'm not arguing against facts, I asked why you cannot undo what
iso-transl does.  For example, disable key-translation-map, or
redefine its entries as you see fit.





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28  9:41     ` Eli Zaretskii
@ 2021-10-28 10:53       ` Mark Bestley
  2022-09-19 20:15         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Bestley @ 2021-10-28 10:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 51449



On Thu, 28 Oct 2021, at 10:41, Eli Zaretskii wrote:
>> Date: Thu, 28 Oct 2021 09:12:54 +0100
>> From: "Mark Bestley" <gnu@bestley.co.uk>
>> Cc: 51449@debbugs.gnu.org
>> 
>> On Thu, 28 Oct 2021, at 08:12, Eli Zaretskii wrote:
>> 
>> >
>> > iso-transl is preloaded now.  But I don't think I understand why it
>> > gets in your way: can't you unbind the bindings that iso-transl does,
>> > if you have no use for them, or rebind them after changing Alt to be a
>> > modifier key if you do have use for iso-transl?
>> >
>> > (Caveat: I don't use a Mac, so I may be missing some Mac-specific
>> > issue here.)
>> 
>> In scratch buffer on emacs - Q
>> 
>> 
>> (setq  mac-command-modifier 'alt)
>> 
>> (global-set-key (kbd "A-c")  'info)
>> (global-set-key (kbd "A-z")  'info)
>> 
>> Then A-z runs info but A-c just inserts ¢
>
> I'm not arguing against facts, I asked why you cannot undo what
> iso-transl does.  For example, disable key-translation-map, or
> redefine its entries as you see fit.


Mainly because I did not know the depths of emacs and what to do with key-translation-map and getting annoyed with something happening without me asking for it and being totally surprised by the change in bindings especially as I thought users had complete control of A- bindings, only C-x were reserved for emacs use. (Ie I had not require iso-trans myself)

I have now undone the iso-trans changes as Gregory suggested 

(dolist (transl-char iso-transl-char-map)
      (let ((vec (vconcat (car transl-char))))
        (aset vec 0 (logior (aref vec 0) ?\A-\^@))
        (define-key key-translation-map vec nil)))))



-- 
Mark





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

* bug#51449: 28.0.50; iso-transl overwrites alt key bindings
  2021-10-28 10:53       ` Mark Bestley
@ 2022-09-19 20:15         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-19 20:15 UTC (permalink / raw)
  To: Mark Bestley; +Cc: Eli Zaretskii, 51449

"Mark Bestley" <gnu@bestley.co.uk> writes:

> I have now undone the iso-trans changes as Gregory suggested 
>
> (dolist (transl-char iso-transl-char-map)
>       (let ((vec (vconcat (car transl-char))))
>         (aset vec 0 (logior (aref vec 0) ?\A-\^@))
>         (define-key key-translation-map vec nil)))))

Skimming this bug report, it looks like the conclusion here was that we
didn't want to do anything here on the Emacs side, so I'm closing this
bug report.





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

end of thread, other threads:[~2022-09-19 20:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 20:42 bug#51449: 28.0.50; iso-transl overwrites alt key bindings Mark Bestley
2021-10-27 21:48 ` Gregory Heytings
2021-10-28  7:12 ` Eli Zaretskii
2021-10-28  8:12   ` Mark Bestley
2021-10-28  8:40     ` Gregory Heytings
2021-10-28  8:51       ` Mark Bestley
2021-10-28  8:57         ` Gregory Heytings
2021-10-28  9:41     ` Eli Zaretskii
2021-10-28 10:53       ` Mark Bestley
2022-09-19 20:15         ` Lars Ingebrigtsen

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).