unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Robert Thorpe <rt@robertthorpeconsulting.com>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: help-gnu-emacs@gnu.org, udyantw@gmail.com
Subject: Re: Regex replace for numbers
Date: Fri, 03 Oct 2014 20:22:35 +0100	[thread overview]
Message-ID: <87lhoxvtz8.fsf@robertthorpeconsulting.com> (raw)
In-Reply-To: <87wq8hgqt8.fsf@geodiff-mac3.ulb.ac.be> (message from Nicolas Richard on Fri, 03 Oct 2014 16:40:03 +0200)

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Udyant Wig <udyantw@gmail.com> writes:
>>  Is there a way to save the major-mode of the buffer before entering the
>>  above code, change to emacs-lisp-mode and then to enable the original
>>  major-mode again?
>
> You don't really need to do that. Simply using the syntax table should
> be sufficient in this case :
>
> (with-syntax-table emacs-lisp-mode-syntax-table
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward "[0-9]" nil t )
>       (let ((bounds (bounds-of-thing-at-point 'sexp))
>             (number (number-at-point)))
>         (when number
>           (delete-region (car bounds) (cdr bounds))
>           (insert (format "%s" number)))))))

Thanks everyone.  I'll try the elisp solution and the regexps solution.

BR,
Robert Thorpe



      reply	other threads:[~2014-10-03 19:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03  0:33 Regex replace for numbers Robert Thorpe
2014-10-03  1:07 ` Marcin Borkowski
2014-10-03  1:41   ` Robert Thorpe
2014-10-03  2:45     ` Yuri Khan
2014-10-03  5:25 ` Nicolas Richard
     [not found] ` <mailman.10347.1412313926.1147.help-gnu-emacs@gnu.org>
2014-10-03 11:43   ` Udyant Wig
2014-10-03 14:40     ` Nicolas Richard
2014-10-03 19:22       ` Robert Thorpe [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87lhoxvtz8.fsf@robertthorpeconsulting.com \
    --to=rt@robertthorpeconsulting.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=theonewiththeevillook@yahoo.fr \
    --cc=udyantw@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).