From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Udyant Wig Newsgroups: gmane.emacs.help Subject: Re: Regex replace for numbers Date: Fri, 03 Oct 2014 17:13:59 +0530 Organization: A noiseless patient Spider Message-ID: <87zjdd9y4g.fsf@panda.goosenet.in> References: <87zjdexa89.fsf@robertthorpeconsulting.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1412336727 26803 80.91.229.3 (3 Oct 2014 11:45:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Oct 2014 11:45:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 03 13:45:21 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xa1IW-0002Ic-9y for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Oct 2014 13:45:20 +0200 Original-Received: from localhost ([::1]:38928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xa1IV-0001ED-TF for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Oct 2014 07:45:19 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Injection-Info: mx05.eternal-september.org; posting-host="5f9ef57104bbdf403da557fd9697b224"; logging-data="28421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iWAoCc14RZ3TnxMWOxqoR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:zq5IAK72NJ5bEf+YW0K5/a+RG7g= sha1:LkPvmzLZkc5bn0i5kkcXWuVuzDw= Original-Xref: usenet.stanford.edu gnu.emacs.help:207969 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100244 Archived-At: Nicolas Richard writes: | Instead of solving it with a regexp, I suggest some lisp : | | (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)))))) | | (This might not work in modes other than emacs-lisp mode, due to how | number-at-point works.) 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? | -- Udyant Wig GitHub: https://github.com/udyant Poetry: http://www.writing.com/main/profile/biography/frosthrone