[buug] Quick Emacs Macro?
Erik Shirokoff
shiro at uclink4.berkeley.edu
Sun Jul 4 13:12:38 PDT 2004
Hi Joseph,
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:
http://www.gnu.org/software/emacs/emacs-lisp-intro/
http://www.gnu.org/software/emacs/elisp-manual/
a chart of lisp expressions for people who know perl:
http://www.grin.net/~mirthles/devnotes/elisp-for-perl-programmers.html
take care,
Erik
-------------- 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> ")
(let
((tagout
(replace-regexp-in-string " " "_" tagin)))
(insert
(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
mailing list