From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Brendan Halpin Newsgroups: gmane.emacs.help Subject: Re: How to increase a number under cursor? Date: 20 May 2003 13:58:46 +0100 Organization: University of Limerick Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1053436509 7611 80.91.224.249 (20 May 2003 13:15:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 20 May 2003 13:15:09 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Tue May 20 15:15:06 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19I6x6-0001we-00 for ; Tue, 20 May 2003 15:14:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19I6kF-0004E8-Hp for gnu-help-gnu-emacs@m.gmane.org; Tue, 20 May 2003 09:01:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.esat.net!feeder.news.heanet.ie!not-for-mail Original-Newsgroups: gnu.emacs.help Cache-Post-Path: newscache.ul.ie!unknown@wivenhoe.staff8.ul.ie X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) Original-Lines: 30 Original-NNTP-Posting-Date: 20 May 2003 12:57:46 GMT Original-NNTP-Posting-Host: newscache.ul.ie Original-X-Trace: 1053435466 reader.news.heanet.ie 178 [::ffff:136.201.1.36]:37508 Original-Xref: shelby.stanford.edu gnu.emacs.help:113427 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9922 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9922 Wang Yin 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:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html