Friday, March 5, 2010

Sometimes you do need elisp

Getting annoyed at incrementing a sid each time I wrote a snort rule. I realized I had forgotten almost all the elisp I knew.

(defun cmg:increment-number-at-point ()
(interactive)
(save-excursion
(let ((num (number-at-point))
(increment 1))
(re-search-backward "\\s-")
(forward-char 1)
(kill-word 1)
(insert (format "%d" (+ num increment))))))

No comments:

Post a Comment