From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Bug: [patch] also tangle headlines that begin with lower case string "comment" [8.2.5h (release_8.2.5h-680-g12df70 @ /home/youngfrog/sources/org-mode/lisp/)] Date: Wed, 05 Mar 2014 16:44:12 +0100 Message-ID: <87zjl4wsz7.fsf@yahoo.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLDzF-0001gk-B9 for emacs-orgmode@gnu.org; Wed, 05 Mar 2014 10:44:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLDz9-00005p-D5 for emacs-orgmode@gnu.org; Wed, 05 Mar 2014 10:44:01 -0500 Received: from mxin.ulb.ac.be ([164.15.128.112]:45162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLDz9-00005g-7K for emacs-orgmode@gnu.org; Wed, 05 Mar 2014 10:43:55 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, Trying to tangle code blocks in a headline line like: #+begin_src org ,* Comment retrouver.... #+end_src I struggled to understand what I was doing wrong because it didn't tangle anything. In fact, the french word "Comment" was mistakenly parsed as the org-comment-string, and so the headline was skipped. Let's avoid that (see patch below). I take the opportuinty to ask if we should try and make this function use org-element instead. My na=C3=AFve approach doesn't work: #+begin_src emacs-lisp (save-excursion (org-back-to-heading t) (let ((elt (org-element-at-point))) (while (and elt (not (org-element-property :commentedp elt))) (setq elt (org-element-property :parent elt))) elt)) #+end_src because an heading doesn't know what its parent heading is (the property is nil). This can be fixed by doing: #+begin_src emacs-lisp (defun org-babel-under-commented-heading-p () "Return t if currently under a commented heading." (unless (org-before-first-heading-p) (save-excursion (org-back-to-heading t) (let ((elt (org-element-at-point))) (while (and elt (not (org-element-property :commentedp elt))) (setq elt (and (org-up-heading-safe) (org-element-at-point)))) elt)))) #+end_src byt I'm not sure it is very pretty. Opinions ? Anyway, here's the quicker fix : From: Nicolas Richard Date: Wed, 5 Mar 2014 14:54:49 +0100 Subject: [PATCH] * ob-tangle.el (org-babel-under-commented-heading-p): Disa= ble case folding to avoid matching "Comment" at beg of headline. --- lisp/ob-tangle.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 0096ac9..9f0ea0d 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -361,7 +361,8 @@ that the appropriate major-mode is set. SPEC has the f= orm: "Return t if currently under a commented heading." (unless (org-before-first-heading-p) (if (let ((hd (nth 4 (org-heading-components)))) - (and hd (string-match (concat "^" org-comment-string) hd))) + (and hd (let (case-fold-search) + (string-match (concat "^" org-comment-string) hd)))) t (save-excursion (and (org-up-heading-safe) --=20 Nico.