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: Rasmus
Subject: Re: Question about string-match and match-string
Date: Wed, 17 Jul 2013 10:44:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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?

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)


–Rasmus

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?




reply via email to

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