Czipperz
Czipperz

Reputation: 3336

Emacs bindings documentation

I am writing some bindings to lambdas in my ~/.emacs and would like to have a description of what the function does appear when I do (for example) C-c ?. I tried to put a string immediately after lambda () but that still does nothing. How do I get something relevant to appear in the binding column?

Example that still functionally works but documentation doesn't:

(global-set-key (kbd "M-p") (lambda ()
                  "Moves the current line up by one"
                  (interactive)
                  (let ((col (current-column)))
                (transpose-lines 1)
                (forward-line -2)
                (forward-char col))))

Upvotes: 0

Views: 34

Answers (1)

Gerstmann
Gerstmann

Reputation: 5518

You should use defun to define your interactive function and bind to that.

(defun my-func ()
  "Moves the current line up by one"
  (interactive)
  (let ((col (current-column)))
    (transpose-lines 1)
    (forward-line -2)
    (forward-char col)))

(global-set-key (kbd "M-p") 'my-func)

Upvotes: 1

Related Questions