Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to override functions in emacs lisp for specific mode?

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

Thanks

like image 257
Anycorn Avatar asked Feb 08 '10 16:02

Anycorn


1 Answers

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.

like image 152
Sean Avatar answered Oct 21 '22 10:10

Sean