emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-insert-heading-respect-content inserts at the wrong level if target heading is invisible [7.9.2 (release_7.9.2-883-g6fb36e.dirty @ /home/dlm/share/org-mode.git/lisp/)]
@ 2013-01-25  4:46 James Harkins
  2013-02-11 17:30 ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: James Harkins @ 2013-01-25  4:46 UTC (permalink / raw)
  To: emacs-orgmode

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------

I'm resending the issue that I reported the other day, now with a MCE.

SHORT DESCRIPTION:

Recent versions of MobileOrg for Android allow the user to create new headings under specific nodes. This creates an "addheading" edit, which is processed by finding the target parent node and then calling org-insert-heading-respect-content to make a new heading at the same level as the given parent. (Then that heading is demoted, and the content is inserted.)

If the target heading is invisible at this time, org-insert-heading-respect-content looks upward to the target heading's parents, finding the closest one that is visible. Then it inserts the new heading at this level.

That is, given a tree like this:

* I
** A
*** 1
** B
* II

If we try to insert a new heading "2" under "A," we should get this (expected behavior):

* I
** A
*** 1
*** 2
** B
* II

Instead, we get:

* I
** A
*** 1
** B
** 2
* II

If the user doesn't discover the mistake, the subtree structure is corrupted and it may be hard to untangle.

Note: Several MobileOrg users have seen the same problem. This issue is not specific to my configuration.


STEPS TO REPRODUCE:

1. Create a file "test.org" with the following content:

* I
** A
*** 1
** B
* II


2. Cycle global visibility so that all top level headings are folded. You should see this in the buffer.

* I...
* II


3. From the scratch buffer, execute the following. The second expression extracts the bare minimum function calls from org-mobile-apply and org-mobile-edit to illustrate the issue. (I spent a lot of time with edebug, and I'm certain this is the actual sequence of events.)

(require 'org-mobile)

(org-with-point-at (org-mobile-locate-entry "olp:test.org:I/A")
  (progn
    (end-of-line 1)
    (org-insert-heading-respect-content)
    (org-demote)
    (insert "2. This should be a third-level heading, but it isn't")
  )
)

4. Go back to test.org and expand all headings.

* I
** A
*** 1
** B
** 2. This should be a third-level heading, but it isn't
* II


FURTHER DETAILS:

With edebug, I found that the problem within org-insert-heading is the use of org-end-of-subtree here:

          (when (featurep 'org-inlinetask)
        (while (and (not (eobp))
                (looking-at "\\(\\*+\\)[ \t]+")
                (>= (length (match-string 1))
                org-inlinetask-min-level))
          (org-end-of-subtree nil t)))

I tried changing this to (org-end-of-subtree t t) -- using the invisible-ok option -- but it didn't make a difference in the result.

Alternately, the problem might be:

	 (t
	  ;; somewhere in the line
          (save-excursion
	    (setq previous-pos (point-at-bol))
            (end-of-line)
            (setq hide-previous (outline-invisible-p)))
	  (and org-insert-heading-respect-content (org-show-subtree))

... where org-show-subtree does not actually show the desired parent node. I think org-end-of-subtree expects the proper parent to be visible at that point, but for some reason, that isn't actually happening.


Emacs  : GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-22 on batsu, modified by Debian
Package: Org-mode version 7.9.2 (release_7.9.2-883-g6fb36e.dirty @ /home/dlm/share/org-mode.git/lisp/)

current state:
==============
(setq
 org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
 org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
 org-agenda-files '("~/Documents/mobileorg/semester.org" "~/Documents/mobileorg/agenda_main.org"
		    "~/Documents/mobileorg/usconcert.org")
 org-agenda-window-setup 'current-window
 org-hide-leading-stars t
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-mobile-files '(org-agenda-files "~/Documents/mobileorg/test.org")
 org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id
 org-export-latex-format-toc-function 'org-export-latex-format-toc-default
 org-mobile-inbox-for-pull "~/Documents/mobileorg/from-mobile.org"
 org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe
		      org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-export-first-hook '(org-beamer-initialize-open-trackers)
 org-todo-keywords '((sequence "TODO" "MAYBE" "INPROG" "MTG" "|" "POSTPONED" "DONE"))
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-directory "~/Documents/mobileorg"
 org-blank-before-new-entry '((heading) (plain-list-item))
 org-url-hexify-p nil
 org-babel-pre-tangle-hook '(save-buffer)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
		  org-cycle-hide-inline-tasks org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers)
 org-timeline-show-empty-dates nil
 org-mode-hook '((lambda nil
		  (org-add-hook (quote change-major-mode-hook) (quote org-show-block-all)
		   (quote append) (quote local))
		  )
		 (lambda nil
		  (org-add-hook (quote change-major-mode-hook) (quote org-babel-show-result-all)
		   (quote append) (quote local))
		  )
		 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-cycle-include-plain-lists 'integrate
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp "\\<James Harkins\\>"
 org-mobile-directory "/var/www/mobileorg/web"
 org-mobile-post-push-hook '((lambda nil (shell-command "chmod 664 /var/www/mobileorg/web/*")))
 org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code)
 org-agenda-cmp-user-defined 'bh/agenda-sort-by-heading-date
 org-modules '(org-bbdb org-bibtex org-docview org-gnus org-id org-info org-jsinfo org-irc org-mew
	       org-mhe org-rmail org-vm org-wl org-w3m)
 org-columns-default-format "%42ITEM %PRIORITY %14TIMESTAMP %14DEADLINE %TAGS"
 org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc
			       org-beamer-auto-fragile-frames
			       org-beamer-place-default-actions-for-lists)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 )
--

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-10 23:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25  4:46 Bug: org-insert-heading-respect-content inserts at the wrong level if target heading is invisible [7.9.2 (release_7.9.2-883-g6fb36e.dirty @ /home/dlm/share/org-mode.git/lisp/)] James Harkins
2013-02-11 17:30 ` Bastien
2013-02-12  3:50   ` James Harkins
2013-02-12 10:34     ` Bastien
2013-02-14  9:09     ` Bastien
     [not found]       ` <CAFniQ7XpJnqOW8DqdGLJ1RbtPtrnKQz=zXBH-O0M1ZFPBa5ucw@mail.gmail.com>
     [not found]         ` <87mwujdp87.fsf@bzg.ath.cx>
2013-03-13  9:03           ` James Harkins
2013-04-10 23:06             ` Bastien

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).