all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ken <gebser@mousecar.com>
To: PJ Weisberg <pj@irregularexpressions.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: error in replace-match: "args out of range"
Date: Mon, 04 Apr 2011 12:13:15 -0400	[thread overview]
Message-ID: <4D99EE1B.8050306@mousecar.com> (raw)
In-Reply-To: <BANLkTimV_A2o+vG3hgEMZXHm45KWdq1xBg@mail.gmail.com>

On 04/03/2011 07:19 PM PJ Weisberg wrote:
> On 4/3/11, ken <gebser@mousecar.com> wrote:
>> On 03/28/2011 04:32 PM Stefan Monnier wrote:
>>> I'm just saying that
>>>
>>> M-: (some-regexp-search) RET
>>> M-: (replace-match ...) RET
>>>
>>> won't always do what you want, because a whole lot of code will run
>>> between the two.
>>>
>>>
>>>         Stefan
>> Hmm.  I'm hearing "this is faith-based functionality."  Does it have to
>> do with the fact that all processes running from one emacs session have
>> the one and the same PID?  I recall reading a discussion on this list
>> (which was largely outside my capacity) multiple years ago about some
>> problem which 'would be resolved when threading is implemented.'  Is
>> this an issue of that sort?
> 
> It sounds more like the sort of issue that would be *created* when
> threading was implemented.

Probably this discussion won't solve anything, so let's leave it for
another time.


> 
> Based on what Stefan said, a more helpful question might be: what
> happens between the call to match-string and the call to
> replace-match?  Are they in the same function, and close together?
> What can match-string tell you about the string you're trying to
> replace?
> 
> -PJ
> 

Here's the relevant code fragment:

    (if (re-search-forward aname-re-str head-text-end-pt t)
	(progn	
	  (setq aname-str (match-string 2))
	  (setq head-text-nested (match-string 4))
	  (if (equal head-text-nested "")
	      (progn
		(setq head-text-nested (create-heading-text))
		(if (equal aname-str "")
		    (progn
		      (setq aname-str (create-aname head-text-nested))
		      (replace-match head-text-nested t nil nil 4)
		      (replace-match aname-str t nil nil 2))
		  (replace-match head-text-nested t t nil 4))) ;ERROR:

The top line above is the search.  The last line is the replace-match
which fails.  The couple replace-match lines above it might also fail...
haven't tested those yet.

create-aname is nothing but a set of setq's and a read-from-minibuffer.
 create-heading-text is just a read-from-minibuffer.

So, yes, the search and replace-match are in the same function.  Are
they "close together"?  I'd say yes, but that's a judgment call really.
 The string I want to replace in this particular instance is a null string.



  reply	other threads:[~2011-04-04 16:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3.1301227401.14102.help-gnu-emacs@gnu.org>
2011-03-28 15:38 ` error in replace-match: "args out of range" Stefan Monnier
2011-03-28 18:50   ` ken
2011-03-28 20:32     ` Stefan Monnier
2011-04-03 22:02       ` ken
2011-04-03 23:19         ` PJ Weisberg
2011-04-04 16:13           ` ken [this message]
     [not found]           ` <mailman.1.1301933608.12491.help-gnu-emacs@gnu.org>
2011-04-04 22:21             ` Tim X
2011-04-07 16:29               ` ken
     [not found]               ` <mailman.0.1302193756.25199.help-gnu-emacs@gnu.org>
2011-04-07 23:25                 ` Tim X
2011-04-09  4:56                   ` ken
2011-04-09  6:44                     ` PJ Weisberg
2011-04-09 12:35                       ` ken
     [not found]                       ` <mailman.2.1302352549.29796.help-gnu-emacs@gnu.org>
2011-04-09 12:57                         ` David Kastrup
2011-04-09 20:04                           ` PJ Weisberg
2011-04-09 21:25                             ` Perry Smith
2011-04-05  1:56             ` Stefan Monnier
2011-04-06  3:39               ` error in replace-match: "args out of range" [SOLVED] ken
2011-04-07 14:00                 ` ken
2011-04-07 19:09                   ` PJ Weisberg
     [not found]                   ` <mailman.14.1302203359.27822.help-gnu-emacs@gnu.org>
2011-04-24  1:20                     ` David Combs
2011-04-24  5:21                       ` Stefan Monnier
2011-05-09  1:32                         ` David Combs
     [not found]                 ` <mailman.9.1302184849.3726.help-gnu-emacs@gnu.org>
2011-04-10  2:25                   ` Stefan Monnier
2011-03-27 12:02 error in replace-match: "args out of range" ken
2011-03-27 18:25 ` ken
     [not found] ` <mailman.3.1301250397.12231.help-gnu-emacs@gnu.org>
2011-03-27 19:07   ` Alan Mackenzie
2011-03-27 20:12     ` ken

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=4D99EE1B.8050306@mousecar.com \
    --to=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pj@irregularexpressions.net \
    /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.