2 (defun wombat () "Load the wombat color theme."
4 (if (file-exists-p "~/.emacs.d/color-theme/themes/color-theme-wombat.el")
5 (load-file "~/.emacs.d/color-theme/themes/color-theme-wombat.el")))
7 (defun reload () "Reloads .emacs interactively"
9 (if (file-exists-p "~/.emacs")
10 (load-file "~/.emacs")))
12 (defun count-words-buffer ()
13 "Count the number of words in the current buffer;
14 print a message in the minibuffer with the result."
18 (goto-char (point-min))
19 (while (< (point) (point-max))
21 (setq count
(1+ count
)))
22 (message "buffer contains %d words." count
))))
24 ; NOTE: I attempted to emulate a solution I found here:
25 ;http://stackoverflow.com/questions/1037545/how-to-replace-forwardslashes-with-backslashes-in-a-string-in-lisp-for-emacs
26 ; but failed. Wound up using this which I got from running replace-regexp on a region and hitting C-x ESC ESC and pasted this into my func:
27 ; (replace-regexp "\\\\" "/" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
28 ; Currently examining this tutorial so I can figure out why the stackoverflow solution failed.
29 ;http://xahlee.org/emacs/lisp_regex_replace_func.html
30 (defun replace-backslashes () "Replace the backslashes with slashes."
33 (replace-regexp "\\\\" "/" nil
34 (if (and transient-mark-mode mark-active
) (region-beginning))
35 (if (and transient-mark-mode mark-active
) (region-end))))
37 ;;The following came from here:
38 ;http://lispy.wordpress.com/category/regular-expressions/
39 ;It's a good example of how you can set up text processing routines
40 ;Using defmacro instead of just a defun lets you defines the key binding at the same time that the replacement function is defined. This also has it's drawbacks, lispy gives this as his rationale:
41 ;I went with a macro because once I get my regular expression from re-builder, I wanted to be able to write the code for everything as quickly as possible. With “defreplacer”, all I needed was four arguments and I was good to go.
42 (defmacro defreplacer
(name description search-for replace-with chord
)
47 (query-replace-regexp ,search-for
50 (if (and transient-mark-mode mark-active
)
52 (if (and transient-mark-mode mark-active
)
54 (global-set-key (kbd ,chord
) ',name
)))
56 (defreplacer pull-text-from-semi-colons
57 "Remove text from between two semi-colon signs."
58 "[ ]*;\\([a-z]*\\);[ ]*" ; use double back slash to 'escape' in quotes
63 (defun remove-blank-lines (n)
64 "Removes blank lines from a buffer"
65 (interactive "p") ; n = value passed by the C-u “universal argument”
66 (query-replace-regexp "
70 (if (and transient-mark-mode mark-active
) (region-beginning))
71 (if (and transient-mark-mode mark-active
) (region-end))))