help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to increase a number under cursor?


From: Brendan Halpin
Subject: Re: How to increase a number under cursor?
Date: 20 May 2003 13:58:46 +0100

Wang Yin <address@hidden> writes:

> The only problem I meet is how to increase the number under
> the cursor?


How about this?

(defun wy-incr-num-at-cursor ()
  (interactive)
  (let ((number (number-at-point)))
    (and number
         (let ((bounds (bounds-of-thing-at-point 'sexp)))
           (delete-region (car bounds) (cdr bounds))
           (insert (format "%d" (1+ number)))))))

(local-set-key "a" 'wy-incr-num-at-cursor)

For hex and octal, you'll need to look into where number-at-point
is defined, i.e. thingatpt.el, which comes with Emacs.

Brendan

PS This answers some of what you asked for, but there are probably
cleverer ways of achieving what you actually want to do.

-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-390476; Room F2-025 x 3147
mailto:address@hidden  http://www.ul.ie/sociology/brendan.halpin.html


reply via email to

[Prev in Thread] Current Thread [Next in Thread]