From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rasmus Newsgroups: gmane.emacs.help Subject: Re: Question about string-match and match-string Date: Sun, 21 Jul 2013 00:25:53 +0200 Message-ID: <87d2qcuavi.fsf@gmx.us> References: <20130717081704.GB16899@kuru.dyndns-at-home.com> <20130717083511.GC16899@kuru.dyndns-at-home.com> <87sizdbmo2.fsf@gmx.us> <874nbsb8lw.fsf@free.fr> <87ppug469b.fsf@gmx.us> <874nbp8d6u.fsf@free.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1374359182 28852 80.91.229.3 (20 Jul 2013 22:26:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Jul 2013 22:26:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 21 00:26:23 2013 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 1V0fbZ-00008D-PP for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Jul 2013 00:26:21 +0200 Original-Received: from localhost ([::1]:51213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0fbZ-0003gU-CP for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Jul 2013 18:26:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0fbO-0003gN-C1 for help-gnu-emacs@gnu.org; Sat, 20 Jul 2013 18:26:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0fbM-00085Q-7W for help-gnu-emacs@gnu.org; Sat, 20 Jul 2013 18:26:10 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:38372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0fbM-00085I-0y for help-gnu-emacs@gnu.org; Sat, 20 Jul 2013 18:26:08 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V0fbI-0008RV-DG for help-gnu-emacs@gnu.org; Sun, 21 Jul 2013 00:26:04 +0200 Original-Received: from g225142123.adsl.alicedsl.de ([92.225.142.123]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Jul 2013 00:26:04 +0200 Original-Received: from rasmus by g225142123.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Jul 2013 00:26:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 81 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g225142123.adsl.alicedsl.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAAAAAByaaZbAAAAAmJLR0QA/4ePzL8AAAAJcEhZ cwAAAEgAAABIAEbJaz4AAAFiSURBVEjHnZbBkYAwCEUZ+qEZOqEVuqGK3xCHPUQNie4OWW6OeUrg 8xOi48glMJ4BIDMzY3v/DcBERA1dwIWZmVmiB8S1nlmiBSg/oR0AMgGJBuBcAMcZwN74Q5ymtOwB nSrZBKzXOJ3rewBsZGXoainDzTx+ER+WiPmcAODbeyI+jF/m4YmREsIdf+1hBWAqzKLRBfRRVg+w 0vgOUKViHWCROxqAngJ2CtSUtAOADzd9XNaETpvqdTpNzqSxiS8QM+AUSzhFBCJwrfrvPMBNx0ju IzrsP0wtMOfh8nfFbQKjKLcJXGUSvwEvdQblLLyOskqxHSJ6zg9m1i8j0+KcSUSo6oq3VcaupbqA 7W3Gr3nYgd3u9RR4zQPqJ3xLCV/z4HXB+1CsGXgSFfmy+Nex6+UHo3E3IT4aF9vBfjdKcUsDriJi Ma8OKiLz6hAmIuoo84CIcRvZLyegTCRwvc7zy88POjTfO2tyoxoAAAAASUVORK5CYII= Cancel-Lock: sha1:KxRvUAoeokwkB+1rO7IL8qDkrCk= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:92281 Archived-At: Julien Cubizolles writes: > Rasmus writes: > >> (with-eval-after-load 'ox >> (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 'odt) >> (string-match "\\`.*ignoreheading.*\n" >> (downcase headline))) >> (replace-match "" nil nil headline))) >> >> (add-to-list 'org-export-filter-headline-functions >> 'rasmus/org-latex-ignore-heading)) > > It's working, thanks, but it's ignored if you use tags:nil option (which > is pretty common I guess). Well. . . If you never want tags perhaps the correct way is to never have tag export e.g. via a filter or a derived backend. > If however you use > > #+TITLE: Titre > #+OPTIONS: tags:nil > > * First Heading :tag: > blablabla > * Second Heading :ignoreheading: > blablabla > > Both the first and second heading are displayed (not what I want). Try this then. . . It's ugly. Also, you can't easily do this with html due to divs and tab of contents, manually numbering etc. So you'd need a derived backend. I don't know about odt. It's an ugly hack. (defun rasmus/org-latex-ignore-heading (headline backend info) "Strip headline from HEADLINE if it has tag ignoreheading." (let* ((tags (org-element-property :tags (plist-get (text-properties-at (- (string-match "\n" headline) 2) headline) :parent)))) (when (and (member-ignore-case "ignoreheading" tags) (org-export-derived-backend-p backend 'latex 'ascii)) (string-match "\\`.*\n.*\n" headline) (replace-match "" nil nil headline)))) Alternatively, you can add hook removing lines before parsing which would give nice results in all backend, but then this won't work: * h1 :noexport: * h2 :ignoreheading: my protected section If you never have such constructions this is a better solution. (defun rasmus/remove-ignored-headlines-before-parse (backend) "Remove headlines with tag \"ignoreheading\" before parsing" (dolist (x (org-element-map (org-element-parse-buffer 'headlines) 'headline (lambda (h) (cons (org-element-property :tags h) (org-element-property :begin h))))) (save-excursion (when (member-ignore-case "ignoreheading" (car x)) (goto-char (cdr x)) (delete-region (line-beginning-position) (line-end-position)))))) (add-hook 'org-export-before-parsing-hook 'rasmus/remove-ignored-headlines-before-parse) > Finally, something weird with the title: if you don't define it with de > #+TITLE, it's set to name_of_thefile$_{\text{ignoreheading}}$... I can't reproduce. –Rasmus -- A page of history is worth a volume of logic