Thursday, 15 July 2010

emacs - redefine C-x C-e to evaluate custom language expression -



emacs - redefine C-x C-e to evaluate custom language expression -

i've defined major mode language. i'm trying redefine c-x c-e when i'm in major mode, it'd evaluate look using "my" custom interpreter.

suppose interpreter command-line programme invoked this:

$my-interpreter <some expression>

i imagine, need do scheme call, passing look "before point" argument , print homecoming value in echo area. how hard be, right?

problem: have no thought start! hint?

thanks.

you can take @ shell-command , relatives, along thing-at-point. here's simple illustration uses "interpreter" (just shell echo command) echo word @ point:

(defun my-interpreter () (interactive) (let ((arg (thing-at-point 'word))) (when arg (shell-command (concat "echo " arg)))))

(edit in response comment.) if have defined keymap major mode, can bind c-x c-e in major mode phone call define-key. otherwise, can bind locally (local-set-key (kbd "c-x c-e") 'my-interpreter).

it occurred me might interested in building in interactive functionality repl. so, might consider comint-mode; see emacswiki , this post mastering emacs inspired.

emacs elisp

No comments:

Post a Comment