From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Harkins Subject: 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/)] Date: Fri, 25 Jan 2013 12:46:01 +0800 Message-ID: <874ni598fq.wl%jamshark70@dewdrop-world.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TybBF-0005VT-1k for emacs-orgmode@gnu.org; Thu, 24 Jan 2013 23:46:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TybB9-0008AY-IY for emacs-orgmode@gnu.org; Thu, 24 Jan 2013 23:46:20 -0500 Received: from mail-pb0-f54.google.com ([209.85.160.54]:45230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TybB9-0008AA-9o for emacs-orgmode@gnu.org; Thu, 24 Jan 2013 23:46:15 -0500 Received: by mail-pb0-f54.google.com with SMTP id rr4so4052537pbb.41 for ; Thu, 24 Jan 2013 20:46:13 -0800 (PST) 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 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 "\\" 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) ) --