help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about string-match and match-string


From: Suvayu Ali
Subject: Re: Question about string-match and match-string
Date: Wed, 17 Jul 2013 10:55:02 +0200
User-agent: Mutt/1.5.21 (2012-12-30)

Hi Rasmus,

On Wed, Jul 17, 2013 at 10:44:45AM +0200, Rasmus wrote:
> Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> 
> > On Wed, Jul 17, 2013 at 10:17:04AM +0200, Suvayu Ali wrote:
> >> 
> >> Debugger entered--Lisp error: (args-out-of-range -1 -1)
> >>   replace-match("" t nil "{" 1)
> >
> > I forgot to mention, the string above, "{", keeps changing with every
> > subsequent evaluation!  I tried to extract the sub-expressions with
> > match-string with no luck.  I get nil!
> >
> > (let ((test "\\section{Heading{ignoreheading}}\nText\n"))
> >   (string-match "\\(\\\\\\\\section{.+{ignoreheading}}\\\\n\\)\\(.+\\)" 
> > test)
> >   (match-string 1 test)
> >   )
> 
> Are you just trying to implement an ignoreheading filter?
> 

Yes I am!  :)

> This is what I use.  I think Nicolas provided it in a post at some
> point but I'm not sure.
> 
>   (defun rasmus/org-latex-ignore-heading (headline backend info)
>      "Strip headline from HEADLINE if it has tag ignoreheading for
>      certain headlines.  `info' is Ignored"
>      (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii)
>                 (string-match "\\`.*ignoreheading.*\n"
>                               (downcase headline)))
>        (replace-match "" nil nil headline)))
> 
>   (add-to-list 'org-export-filter-headline-functions
>                'rasmus/org-latex-ignore-heading)

Thanks for the code, I will use it.  But I would still like to know what
I was doing wrong.

-- 
Suvayu

Open source is the future. It sets us free.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]