[comp.emacs] Enumerated types... what's the point?

evan@plx.UUCP (Evan Bigall) (03/24/90)

>In article <1990Mar22.053148.10351@ncsuvx.ncsu.edu>, dks@shumv1.uucp (D. K. Smith) writes:
>The point of enums is that they offer more flexability than using #define.
>For example, say you had a list of 100 symbols you wanted to use as constants.
>Of course, order is important.  So, you type out 100 #defines.  Ok, fine.
>Suddenly, you discover you need a new symbol, which should go between the
>third and forth symbols.  If you use defines, you are pretty much stuck
>retyping the values on 97 defines.

I hate to do this, but this is what emacs is all about.
The following function (probably poor):

(defun increment-string (inc)
  "Find the next number in the current buffer and increment it
   leaveing point at the beginning of the number"
 (interactive "p")
 (let (beg end)                        
   (skip-chars-forward "^[0-9]")
   (setq beg (point))
   (skip-chars-forward "[0-9]")
   (setq end (point))
   (insert (int-to-string 
    (+ inc (string-to-int (buffer-substring beg end)))))
   (goto-char beg)
   (delete-region beg end)))

Allows you to write keyboard macros that trivialize this sort of editing.

The ability to count and do relative numeric edits is my test to anybody that
trys to espouse any other editor.

Evan

-- 
Evan Bigall, Plexus Software, Santa Clara CA (408)982-4840  ...!sun!plx!evan
"I barely have the authority to speak for myself, certainly not anybody else"