0

Suppose I add a new word count function to my .emacs file to count words:

(defun word-count nil "Count words in buffer" (interactive) (shell-command-on-region (point-min) (point-max) "wc -w"))

I remember there being a way to run a function by typing the function name, but I don't remember how. What key sequence do I type before I type word-count, enter?

1 Answer 1

2

I figured it out. It's M-x. That's what I assumed it was, but it didn't work the first time because emacs doesn't recognize a new function in .emacs until you restart emacs.

3
  • 1
    In addition to restarting, you can also use M-x load-file to reread .emacs, or use M-x eval-region to evaluate an arbitrary piece of elisp (in this case your defun).
    – KeithB
    Commented Mar 17, 2010 at 20:39
  • You can accomplish the same by M-x load-file and then ` ~/.emacs` (or whatever the path to your .emacs is)
    – Nifle
    Commented Mar 17, 2010 at 20:39
  • And another alternative: place point (the cursor) at the closing paren for the new function and hit C-x C-e or run eval-last-sexp. Commented Mar 19, 2010 at 20:39

You must log in to answer this question.