1

I work in emacs 27.1, Ubuntu 22, Terminal.

I need to comment out a block. I press Ctrl+XCtrl+;. However, the ; button is not accepted properly. It only makes an underlined e appear (only on screen, not the actual buffer).

enter image description here

Typing Ctrl+hkCtrl+XCtrl+; gives the following information:

enter image description here

Opening nano and typing Ctrl+; I get an underline e:

enter image description here

I removed the iBus key binding using ibus-setup as explained in Ctrl+Shift+e key conflict in Fedora

After selecting lines and pressing Ctrl+XCtrl+;, now I get a different message Comment column set to 0:

enter image description here

enter image description here

From the output of Ctrl+hkCtrl+XCtrl+; it appears that the third Ctrl is not picked up:

enter image description here

What is wrong?

Viesturs
  • 825
  • 8
  • 19

1 Answers1

2

When a keypress/key combo doesn't do what you expect, the first thing to check is if the keys you pressed are actually the keys that Emacs received.

To do this, try:

  • C-h k, to start searching help (C-h) for keys (k)
  • C-x C-; to find the help for this particular key combo.

What we expect to see is:

C-x C-; runs the command comment-line (found in global-map), which is an interactive native-compiled Lisp function in ‘newcomment.el’.

Things to check:

  • are the keys listed (C-x C-;) the ones you pressed? If not, something at the operating system level, or in your terminal program if you're running Emacs in terminal mode, is translating the key presses into something else, and you'll have to fix that outside of Emacs
  • is the listed command (comment-line) the command you expect? If not, there's a problem with your keybindings, or maybe you aren't in the major- or minor-mode you thought you were
  • is the command not doing what you thought it would? In that case, check the help for the command, or the package, to see if you misunderstood it, or if there's a bug.
Tyler
  • 22,234
  • 1
  • 54
  • 94
  • It seems that the second Ctrl is not picked up. See updated question. – Viesturs Jun 02 '23 at 13:04
  • 1
    I think this might be an issue with the terminal. C-; is not a recognized ASCII, which means the terminal only recognizes it as ;. This isn't an issue with GUI Emacs. I'm not sure if this can be fixed in Terminal, or how. – Tyler Jun 02 '23 at 13:27
  • 1
    https://unix.stackexchange.com/q/161719/6096 – Tyler Jun 02 '23 at 13:28
  • From unix.stackexchange.com/q/161719/6096 if understand that using C+; is hopeless. Can I assign another keybinding to commenting out a block? – Viesturs Jun 02 '23 at 14:06
  • https://www.masteringemacs.org/article/mastering-key-bindings-emacs – Tyler Jun 02 '23 at 14:32
  • skip to the "templates" section for examples, or read the whole page to learn all the options – Tyler Jun 02 '23 at 14:33
  • I added (global-set-key (kbd "C-x M-;") 'comment-line) to ~/.emacs which was successful in commenting out a region – Viesturs Jun 05 '23 at 12:13