emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo <sdl.web@gmail.com>
To: David Maus <maus.david@gmail.com>,
	Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: patch from master branch attached (was: C-RET errs)
Date: Wed, 03 Mar 2010 16:41:54 +0000	[thread overview]
Message-ID: <m1hboxcq7h.fsf_-_@cam.ac.uk> (raw)
In-Reply-To: <m1lje9cr01.fsf@cam.ac.uk> (Leo's message of "Wed, 03 Mar 2010 16:24:46 +0000")

> Only if debian fixed this bug.
>
> I can reproduce this bug on Gnu/Linux with these steps.
>
> 1. git clone --depth 1 git://repo.or.cz/org-mode.git
> 2. go into the lisp dir and start emacs like this: emacs -q -L .
> 3. goto the scratch buffer and 'M-x org-mode' and then 'C-RET'

The following patch from the master branch should fix this bug. Carsten,
would you be able to fix it in Emacs upstream? Many thanks. Leo.

--- a/org.el    2010-03-03 16:36:22.000000000 +0000
+++ b/org.el	2010-03-03 16:37:09.000000000 +0000
@@ -5965,21 +5965,26 @@
 	 (save-match-data
 	   (looking-at "[ \t]*$")))))
 
-(defun org-insert-heading (&optional force-heading)
+(defun org-insert-heading (&optional force-heading invisible-ok)
   "Insert a new heading or item with same depth at point.
 If point is in a plain list and FORCE-HEADING is nil, create a new list item.
 If point is at the beginning of a headline, insert a sibling before the
 current headline.  If point is not at the beginning, do not split the line,
-but create the new headline after the current line."
-  (interactive "P")
-  (if (= (buffer-size) 0)
+but create the new headline after the current line.
+When INVISIBLE-OK is set, stop at invisible headlines when going back.
+This is important for non-interactive uses of the command."
+  (interactive "P")
+  (if (or (= (buffer-size) 0)
+	  (and (not (save-excursion (and (ignore-errors (org-back-to-heading invisible-ok))
+					 (org-on-heading-p))))
+	       (not (org-in-item-p))))
       (insert "\n* ")
     (when (or force-heading (not (org-insert-item)))
       (let* ((empty-line-p nil)
 	     (head (save-excursion
 		     (condition-case nil
 			 (progn
-			   (org-back-to-heading)
+			   (org-back-to-heading invisible-ok)
 			   (setq empty-line-p (org-previous-line-empty-p))
 			   (match-string 0))
 		       (error "*"))))

Diff finished.  Wed Mar  3 16:37:49 2010

-- 
H A P P Y  H O L I D A Y S!

  reply	other threads:[~2010-03-03 16:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01 15:09 C-RET errs Leo
2010-03-01 21:10 ` David Maus
2010-03-03 16:24   ` Leo
2010-03-03 16:41     ` Leo [this message]
2010-03-03 17:29       ` patch from master branch attached (was: C-RET errs) Carsten Dominik
2010-03-03 16:49     ` C-RET errs Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1hboxcq7h.fsf_-_@cam.ac.uk \
    --to=sdl.web@gmail.com \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maus.david@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).