skip to Main Content

I want to type a single keystroke to insert unicode brackets #xab and #xbb.

This works (for a different unicode bracket):
(global-set-key (kbd "C-c [") "⟨")

But this doesn’t work:
(global-set-key (kbd "C-c [") "«")

How do I coax emacs into inserting "«" with a single keystroke?

(I happen to be on MacOS, but intend to use ubuntu in Parallels)

2

Answers


  1. I`m not sure what is expected, double ⟨ or one «, but hope this can help

    check function and loop

    (defun my-insert () 
      "test something"
      (interactive)
      (dotimes (i 2)
      (insert "⟨"))
    )
    
    (defun my-insert2 () 
      "test something"
      (interactive)
      (insert "«")
    )
     (global-set-key (kbd "C-c [") 'my-insert)
     (global-set-key (kbd "C-c ]") 'my-insert2)
    
    
    Login or Signup to reply.
  2. There is a more general solution which works everywhere, making it more convenient (as you may not want to open an emacs instance each time you need a particular character), which is the compose key. Compose key is specific to Linux, but there is a way to install an equivalent solution on MacOS, and you can even convert existing Compose Key bindings, which is useful because there are a lot of predefined sequences out there in the wild, for instance the default ones.

    E.g. on Ubuntu you probably just need to enable it in the settings, and then with the default configuration typing Compose < < will produce «.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search