[buug] Quick Emacs Macro?
shiro at uclink4.berkeley.edu
Sun Jul 4 13:12:38 PDT 2004
Started this before I saw the other response. Oh well - now you have two options.
Here's a small function that will do what you want. Everything I know about emacs lisp has been found through trial and error, so there is almost certainly a more elegant way to doing it. None the less, it works, at least in GNU Emacs 21.3.2.
Also, in case it's useful, the most useful references I know about for emacs tinkering are (perhaps obviously):
the offical GNU intro and manual:
a chart of lisp expressions for people who know perl:
-------------- next part --------------
;Add this definition to .emacs, or stick it in a .el file and then invoke it with load-file or autoload. If you want to get fancy, you could play with hooks and modes to avoid loading it when you're not editing html.
;prompt for input and add an html name tag
;with spaces converted to underscores
(defun add-name-tag (tagin)
"make an html name tag from user input"
(interactive "Mtag text> ")
(replace-regexp-in-string " " "_" tagin)))
(concat "<a name=\"" tagout "\"><b>" tagin "</b></a>")
;add something like this to add a key binding. Here's it's ctrl+c, n. (I haven't checked for conflicts!)
(global-set-key "\C-cn" 'add-name-tag)
More information about the buug