Ronald Snew
Ronald Snew

Reputation: 95

Emacs keybind in mode

I am trying to make keybind only in the HTML mode.

(defun mf-stylesheet ()                                                         
    (interactive)                                                                 
     ;; Insert CSS stylesheet link
    (insert "<link href=\" \" rel=\"stylesheet\" type=\"text/css\">")             
    ;; Go to href=" "
    (backward-char 36)
    )                                                                             

(eval-after-load "html"
    '(define-key html-mode-map (kbd "C-c s") 'mf-stylesheet))

No messages are shown when I run emacs but C-c s is not bound.

Upvotes: 1

Views: 105

Answers (1)

alex vasi
alex vasi

Reputation: 5344

This should work:

(add-hook 'html-mode-hook
  (lambda ()
    (define-key html-mode-map (kbd "C-c s") 'mf-stylesheet)))

Also, consider using Yasnippet

Upvotes: 1

Related Questions