all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Brendan Halpin <brendan.halpin@ul.ie>
Subject: Re: How to increase a number under cursor?
Date: 20 May 2003 13:58:46 +0100	[thread overview]
Message-ID: <m3znlhpyex.fsf@wivenhoe.staff8.ul.ie> (raw)
In-Reply-To: phwugm3tfv.fsf@wangyin.com

Wang Yin <wang-y01@mails.tsinghua.edu.cn> 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 "\x03a" '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

  reply	other threads:[~2003-05-20 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-20  8:37 How to increase a number under cursor? Wang Yin
2003-05-20 12:58 ` Brendan Halpin [this message]
2003-05-21  8:10   ` Wang Yin
2003-05-20 13:34 ` Oliver Scholz
2003-05-20 14:17   ` David Kastrup
2003-05-21 12:27 ` Eric Ludlam
2003-05-21 16:13 ` Sandip Chitale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3znlhpyex.fsf@wivenhoe.staff8.ul.ie \
    --to=brendan.halpin@ul.ie \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.