Subject: 24.0.95; (org) outline-style cycling + outline-mode

From: Jambunathan K <[email-masked]>
Date: Tue, 03 Apr 2012 11:21:00 +0530

1. Install the following hook

     (add-hook 'outline-mode-hook
       (lambda ()
         (define-key outline-mode-map [(tab)] 'org-cycle)
         (define-key outline-mode-map [(shift tab)] 'org-global-cycle)))

2. (setq debug-on-error t)
3. Visit NEWS file with C-h n
4. Place the cursor at the end of the line as shown below.

,---- ^^^^^ is where the cursor is.
|      ---^^^^^^
|      ** Emacs can be compiled with SELinux support.^^^^^^
|      This happens by default if a suitably recent version of the library is
|      found at build time.  To prevent this, use the configure option^^^^^^^^
|      `--without-selinux'.  See below for SELinux features.
| 
|    
`----

5. Press S-TAB. The following error is reported.  I would expect some
   sort of cycling to happen.
       let: Wrong type argument: stringp, nil

6. This doesn't happen if I am in the middle of a paragraph/line.

7. Here is the sequence of calls.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
  (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
  (and (looking-at "[ 	]*$") (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))) (string= (match-string 3) ""))
  org-point-at-end-of-empty-headline()
  (if (org-point-at-end-of-empty-headline) (progn (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) do (org-do-promote)))) t))
  (let ((org-adapt-indentation nil)) (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  org-cycle-level()
  (or (org-cycle-level) (org-cycle-item-indentation))
  (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation)))
  (or (run-hook-with-args-until-success (quote org-tab-first-hook)) (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation))))
  org-cycle((4))
  (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4)))))
  (let ((org-cycle-include-plain-lists (if (eq major-mode (quote org-mode)) org-cycle-include-plain-lists nil))) (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4))))))
  org-global-cycle(nil)
  call-interactively(org-global-cycle nil nil)
  recursive-edit()
  debug(error (wrong-type-argument stringp nil))
  looking-at(nil)
  (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
  (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
  (and (looking-at "[ 	]*$") (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))) (string= (match-string 3) ""))
  org-point-at-end-of-empty-headline()
  (if (org-point-at-end-of-empty-headline) (progn (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) do (org-do-promote)))) t))
  (let ((org-adapt-indentation nil)) (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  org-cycle-level()
  (or (org-cycle-level) (org-cycle-item-indentation))
  (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation)))
  (or (run-hook-with-args-until-success (quote org-tab-first-hook)) (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation))))
  org-cycle((4))
  (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4)))))
  (let ((org-cycle-include-plain-lists (if (eq major-mode (quote org-mode)) org-cycle-include-plain-lists nil))) (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4))))))
  org-global-cycle(nil)
  call-interactively(org-global-cycle nil nil)
  recursive-edit()
  debug(error (wrong-type-argument stringp nil))
  looking-at(nil)
  (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
  (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
  (and (looking-at "[ 	]*$") (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))) (string= (match-string 3) ""))
  org-point-at-end-of-empty-headline()
  (if (org-point-at-end-of-empty-headline) (progn (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) do (org-do-promote)))) t))
  (let ((org-adapt-indentation nil)) (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  org-cycle-level()
  (or (org-cycle-level) (org-cycle-item-indentation))
  (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation)))
  (or (run-hook-with-args-until-success (quote org-tab-first-hook)) (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation))))
  org-cycle((4))
  (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4)))))
  (let ((org-cycle-include-plain-lists (if (eq major-mode (quote org-mode)) org-cycle-include-plain-lists nil))) (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4))))))
  org-global-cycle(nil)
  call-interactively(org-global-cycle nil nil)
  recursive-edit()
  debug(error (wrong-type-argument stringp nil))
  looking-at(nil)
  (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
  (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
  (and (looking-at "[ 	]*$") (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) (looking-at org-todo-line-regexp))) (string= (match-string 3) ""))
  org-point-at-end-of-empty-headline()
  (if (org-point-at-end-of-empty-headline) (progn (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ (- cur-level prev-level) (org-level-increment))) do (org-do-promote)))) t))
  (let ((org-adapt-indentation nil)) (when (org-point-at-end-of-empty-headline) (setq this-command (quote org-cycle-level)) (let ((cur-level (org-current-level)) (prev-level (org-get-previous-line-level))) (cond ((= prev-level 0) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= prev-level cur-level) (org-do-demote)) ((= prev-level 1) (loop repeat (/ (- cur-level 1) (org-level-increment)) do (org-do-promote))) ((= cur-level 1) (loop repeat (/ (- prev-level 1) (org-level-increment)) do (org-do-demote))) ((< cur-level prev-level) (org-do-promote)) ((> cur-level prev-level) (loop repeat (+ 1 (/ ... ...)) do (org-do-promote)))) t)))
  org-cycle-level()
  (or (org-cycle-level) (org-cycle-item-indentation))
  (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation)))
  (or (run-hook-with-args-until-success (quote org-tab-first-hook)) (and org-cycle-level-after-item/entry-creation (or (org-cycle-level) (org-cycle-item-indentation))))
  org-cycle((4))
  (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4)))))
  (let ((org-cycle-include-plain-lists (if (eq major-mode (quote org-mode)) org-cycle-include-plain-lists nil))) (cond ((integerp arg) (show-all) (hide-sublevels arg) (setq org-cycle-global-status (quote contents))) ((equal arg (quote (4))) (org-set-startup-visibility) (message "Startup visibility, plus VISIBILITY properties.")) (t (org-cycle (quote (4))))))
  org-global-cycle(nil)
  call-interactively(org-global-cycle nil nil)

In GNU Emacs 24.0.95.1 (i386-mingw-nt5.1.2600)
 of 2012-04-03 on MARVIN
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.6) --no-opt --enable-checking --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include'