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
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))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.