0

In my .emacs I have the following:

(progn ; 
  (defvar my-keys-minor-mode-map
    (let ((map (make-sparse-keymap)))
      ; other bindings ..
      (define-key map (kbd "C-c c"    ) 'column-marker-3)
      map)
    "my-keys-minor-mode keymap.")


  (define-minor-mode my-keys-minor-mode
    "A minor mode so that my key settings override annoying major modes."
    :init-value t
    :lighter " my-keys")

  (my-keys-minor-mode 1)
  )

Reading the ColumnMarker documentation I see that I have to use C-u C-u M-x column-marker-1 to erase all column highlighting. My question is, how do I define that as a binding in the format similar to the above. E.g. how can I make something like the following work?

(define-key map (kbd "C-c d"    ) '(C-u C-u M-x column-marker-1)) ; this obviously doesn't work
Drew
  • 75,699
  • 9
  • 109
  • 225
  • 1
    Possible duplicate of [How to apply \`call-interactively\` to an interactive command that accepts the universal argument?](https://emacs.stackexchange.com/questions/21626/how-to-apply-call-interactively-to-an-interactive-command-that-accepts-the-uni) – Drew Jan 27 '18 at 02:31

1 Answers1

1

To be as literal as possible, you could do:

(define-key map (kbd "C-c d") (kbd "C-u C-u M-x c o l u m n - m a r k e r - 1 RET"))

aka

(define-key map "\C-cd" "\C-u\C-u\M-xcolumn-marker-1\r"))

This basically defines C-c d as a keyboard macro. An alternative is to define it as a command:

(define-key map [?\C-c ?d]
            (lambda ()
              (interactive)
              (let ((current-prefix-arg '(16))) ;; The result of C-u C-u.
                (call-interactively 'column-marker-1))))
Stefan
  • 26,154
  • 3
  • 46
  • 84