супер ключ или гипер ключ в iterm2

1156
Mahmoud Abdelkader

Что говорит заголовок: я хочу перейти на использование модели emacs-server / emacs-client вместо использования GUI для Mac OS X. Я использую iTerm2. Я хотел бы отобразить функциональную клавишу (Fn) на супер или гипер.

Я пытался использовать KeyRemap4MacBook - но не повезло.

Обновить:

Похоже, я могу использовать event-apply-super-modifierили event-apply-hyper-modifier, определяется function-key-map.

Я, вероятно, могу заставить клавишу Fn KeyCode::F18выдавать использованный код клавиши, например, и сделать так, чтобы iTerm2 преобразовал его в некоторые escape-символы, например:

Esc+[+J или что-то типа того.

ОБНОВЛЕНИЕ (13 апреля 2015 г.):

Я думаю, что это https://apple.stackexchange.com/questions/144481/sending-controlalt-char-to-terminal-in-iterm2 очень интересно. Может быть способ настроить iterm2 для отправки соответствующих управляющих клавиш, аналогично ответу @ toolbear74.

2
Рассмотрим [этот порт] (https://github.com/railwaycat/emacs-mac-port), который имеет встроенную поддержку клавиши Fn; если вы соберете emacsclient и из этого порта, вы сможете воспользоваться графическим клиентом для демона Emacs без необходимости запуска X-сервера и с довольно широкой поддержкой Aqua. (Во всяком случае, для меня это сработало очень хорошо.) Aaron Miller 10 лет назад 1
С чем ты в конечном итоге пошел? lipsum123483 9 лет назад 0
@Tricon не смог понять это, и я был главным препятствием на пути к непосредственному переходу на Emacs на базе терминала. Дай мне знать, если найдешь что-нибудь. Mahmoud Abdelkader 9 лет назад 0

1 ответ на вопрос

1
toolbear74

Unsatisfactory Workaround

The sequence C-x @ s-… is equivalent to s-…, e.g. C-x @ s-t is equivalent to s-t. Combined with iTerm2 shortcuts:

  1. Create a global or profile shortcut for ⌘… set to Send hex code, e.g. ⌘t => Send hex code
  2. Specify hex code of the form: 0x18 0x40 MOD KEY where MOD is either 0x68 or 0x73 for h and s respectively and KEY is the key you want modified with hyper or super. E.g. mapping ⌘t to s-t:

    ⌘t => 0x18 0x40 0x73 0x74 
  3. Repeat for every shortcut you want…meh…

Failed Experiment #1

In iTerm:

  1. Globally configure Left & Right Option keys as Left Option
  2. Globally configure Left & Right Command keys as Right Option
  3. In a profile, configure Left Option as +ESC and Right Option as Meta

Remapping this way effectively disables all iTerm keyboard shortcuts…meh…

In Emacs:

Using Right Option (R⌥) results in characters with 8th bit set, which as I understand it, is the old way of representing the META key press (back when keyboards had an actual META key).

However, I've failed to get Emacs to do something useful with this distinction. Given that META-t => t with its 8th bit on => octal 364 I've tried:

(global-set-key (kbd "[R⌥-t]") (lambda () (interactive) (message "woot #1"))) (global-set-key (kbd "\364") (lambda () (interactive) (message "woot #2"))) 

Where [R⌥-t] is the individual character that shows up in my buffer when I press that key sequence, represented graphically as \364 but behaving as a single character.

Worth noting that with our without the key binding, whenever I press R⌥-t nothing is displayed in emacs until I press another key upon which emacs displays the \364 character followed by interpreting the second keypress. For instance, R⌥-t a => \364a<point> and R⌥-t LEFT => <point>\364, but only after a or left arrow has been pressed.

You can experiment by only doing Step 3 above and using R⌥ directly.