0

I am trying to create new keybindings for quickly italicizing and bold-facing the text in org-mode. By default, org-emphasize function is provided by org-mode for this. I'm leveraging that for my case.

For example, this is the keybinding for bold-facing the text:

(define-key org-mode-map (kbd "s-b") (
                      lambda () 
                      (interactive) 
                      (org-emphasize '*) 
                      ))

However, when I run the keybinding, it throws the error:

org-emphasize: Wrong type argument: characterp, *

What am I doing wrong?

Dan
  • 32,584
  • 6
  • 98
  • 168
shivams
  • 366
  • 3
  • 16

1 Answers1

1

Short version: you need to give org-emphasize a character, so change your function to read

(org-emphasize ?\*)

The docstring for org-emphasize says that:

(org-emphasize &optional CHAR)

Insert or change an emphasis, i.e. a font like bold or italic. If there is an active region, change that region to a new emphasis. If there is no region, just insert the marker characters and position the cursor between them. CHAR should be the marker character. If it is a space, it means to remove the emphasis of the selected region. If CHAR is not given (for example in an interactive call) it will be prompted for.

You have passed a symbol to org-emphasize rather than a character, which is what you need to pass to it.

Dan
  • 32,584
  • 6
  • 98
  • 168