From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: [patch] Re: problem with example block and headings Date: Mon, 12 Oct 2009 12:20:03 -0400 Message-ID: <871vl8r3d8.fsf_-_@stats.ox.ac.uk> References: <87vdikyjmr.wl%ucecesf@ucl.ac.uk> <688BFE44-6F6D-4EE7-8659-D7C3825B5A53@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MxNd6-0007Re-L1 for emacs-orgmode@gnu.org; Mon, 12 Oct 2009 12:20:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MxNd2-0007Hy-QL for emacs-orgmode@gnu.org; Mon, 12 Oct 2009 12:20:12 -0400 Received: from [199.232.76.173] (port=51493 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MxNd2-0007Hv-LC for emacs-orgmode@gnu.org; Mon, 12 Oct 2009 12:20:08 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:45525) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MxNd2-0008Ng-6q for emacs-orgmode@gnu.org; Mon, 12 Oct 2009 12:20:08 -0400 In-Reply-To: <688BFE44-6F6D-4EE7-8659-D7C3825B5A53@gmail.com> (Carsten Dominik's message of "Mon, 12 Oct 2009 15:09:31 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org Carsten Dominik writes: > Hi Eric, > > please move the cursor into the example block and press "C-c '" (that > is C-c followed by the single quote. This will get you into a special > editing buffer for this snippet. When you exit by pressing the same > keys again, you will see what Org does to quote such headlines. Hmm, and you also see that point jumps around by one character. Carsten, please consider merging branch ded-org-src at git://repo.or.cz/org-mode/babel.git Dan --8<---------------cut here---------------start------------->8--- commit 23b4026937572339a453922bb79a05d1e82597e7 Author: Dan Davison Date: Mon Oct 12 12:13:08 2009 -0400 org-src-mode: maintain relative location of point when lines are protected diff --git a/lisp/org-src.el b/lisp/org-src.el index 796e914..03e5b45 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -229,6 +229,7 @@ the edited version." (when org-mode-p (goto-char (point-min)) (while (re-search-forward "^," nil t) + (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent))) (replace-match ""))) (org-goto-line (1+ (- line begline))) (org-move-to-column @@ -463,7 +464,7 @@ the language, a switch telling if the content should be in a single line." (total-nindent (+ (or org-edit-src-block-indentation 0) org-edit-src-content-indentation)) (preserve-indentation org-src-preserve-indentation) - code line col indent) + (delta 0) code line col indent) (untabify (point-min) (point-max)) (save-excursion (goto-char (point-min)) @@ -490,6 +491,7 @@ the language, a switch telling if the content should be in a single line." (goto-char (point-min)) (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t) + (if (eq (org-current-line) line) (setq delta (1+ delta))) (replace-match ",\\1"))) (when (org-bound-and-true-p org-edit-src-picture) (setq preserve-indentation nil) @@ -514,7 +516,7 @@ the language, a switch telling if the content should be in a single line." (goto-char beg) (if single (just-one-space)) (org-goto-line (1- (+ (org-current-line) line))) - (org-move-to-column (if preserve-indentation col (+ col total-nindent))) + (org-move-to-column (if preserve-indentation col (+ col total-nindent delta))) (move-marker beg nil) (move-marker end nil))) --8<---------------cut here---------------end--------------->8--- > > Also, you might enjoy your example even better if you use > > #+begin_src org > > instead of > > #+begin_example > > HTH > > - Carsten > > On Oct 12, 2009, at 12:46 PM, Eric S Fraga wrote: > >> Hello, >> >> This is not a critical problem but I thought I would highlight it. >> >> If you have an example block which includes lines that look like >> org-mode headings, the show/collapse commands get confused. The two >> images attached show the erroneous behaviour for a file with these >> contents: >> >> --8<---------------cut here---------------start------------->8--- >> * example blocks >> The following is an example of the contents of a simple org-mode >> file: >> #+begin_example problem with org interpretation of contents >> This is an example of a simple org-mode file >> * The main heading >> ** A sub-heading >> ** another sub-heading >> - a list >> - second entry >> #+end_example >> That example shows the hierarchical structure and the use of >> lists. >> ** Further text here >> This is more text that is in a sub-section >> --8<---------------cut here---------------end--------------->8--- >> >> Although a contrived example, this arose from my use of org-babel-sh >> and having output generated that happened to have lines starting with >> '* '. >> >> Note also the indentation of the line immediately after the end of the >> example. >> >> thanks, >> eric >> >> < >> expanded >> .jpg>_______________________________________________ >> Emacs-orgmode mailing list >> Remember: use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > - Carsten > > > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode