Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer
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 Mar 17 '10 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 Mar 17 '10 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. –  Joe Casadonte Mar 19 '10 at 20:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.