views:

119

answers:

1

hi

How can I override emacs function with my own implementation for a specific mode? example/reference would be great

Thanks

+7  A: 

This seems like an odd thing to want to do, but you could do it by advising the function, I suppose. Example:

(defadvice * (around ultimate-answer activate)
  (if (and (eq major-mode 'html-mode) (equal (ad-get-args 0) '(6 9)))
      (setq ad-return-value 42)
    ad-do-it))

After evaluating this advice, the * function will return 42 if it is given the two arguments 6 and 9, but only in html-mode.

Sean