emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Peter Salazar <cycleofsong@gmail.com>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: error in orgstruct-mode
Date: Sat, 20 Oct 2012 19:11:52 -0400	[thread overview]
Message-ID: <12148.1350774712@alphaville> (raw)
In-Reply-To: Message from Peter Salazar <cycleofsong@gmail.com> of "Sat\, 20 Oct 2012 17\:27\:10 EDT." <CAE+_6TzgpkZbjrxuB6gcRjmoLSDLxdjfEh_xL-Mwcev76xEO2A@mail.gmail.com>

Peter Salazar <cycleofsong@gmail.com> wrote:

> OK, I was able to successfully install org-mode 7.9.2. But there's something still wrong with the
> way org-mode and orgstruct-mode are handling numbered lists. 
> 
> In org-mode itself, when I enter "1. " and then hit OPTION-RETURN, it generates the next line "2. "
> but my cursor stays on the first line "1. "
> 

It does that for me too if I leave the item empty, but if I say

1. foo

and press META-RET it generates the 2. line and goes to it.

> In markdown-mode with orgstruct-mode on, I get the following error:
> 

I don't have markdown mode, but in fundamental mode, turning on
orgstruct-mode and adding a numbered list behaves properly for me.
Can you try that? Is markdown mode a necessary prerequisite for the
bug to occur? If so, where does one get markdown mode?

I looked at the code a bit, but it's not obvious to me what's wrong.
The relevant code (in org-list.el:org-list-struct-apply-struct) is

,----
|       ;; 3. Shift each slice in buffer, provided delta isn't 0, from
|       ;;    end to beginning.  Take a special action when beginning is
|       ;;    at item bullet.
|       (mapc (lambda (e)
| 	      (unless (zerop (nth 2 e)) (apply shift-body-ind e))
| 	      (let* ((beg (nth 1 e))
| 		     (cell (assq beg struct)))
| 		(unless (or (not cell) (equal cell (assq beg old-struct)))
| 		  (funcall modify-item beg))))
| 	    sliced-struct))
`----

in the (funcall modify-item beg) line. The modify-item function does

,----
|	       (looking-at org-list-full-item-re)
| 	       ;; a.  Replace bullet
| 	       (unless (equal old-bul new-bul)
| 		 (replace-match new-bul nil nil nil 1))
`----

which is where it blows up. It uses match data from the previous search,
the call to looking-at, but what happens if looking-at returned nil?
Does it set the match data or is it then the case that the replace-match
is trying to use match data from some previous unrelated search?

Nick

> Debugger entered--Lisp error: (args-out-of-range -1 2)
>   replace-match("- " nil nil nil 1)
>   (if (equal old-bul new-bul) nil (replace-match new-bul nil nil nil 1))
>   (unless (equal old-bul new-bul) (replace-match new-bul nil nil nil 1))
>   (let* ((new-ind ...) (old-ind ...) (new-bul ...) (old-bul ...) (new-box ...)) (looking-at
> org-list-full-item-re) (unless (equal old-bul new-bul) (replace-match new-bul nil nil nil 1)) (cond
> (...) (... ...) (... ... ...) (t ...)) (unless (= new-ind old-ind) (delete-region ... ...)
> (indent-to new-ind)))
>   (lambda (item) (goto-char item) (let* (... ... ... ... ...) (looking-at org-list-full-item-re)
> (unless ... ...) (cond ... ... ... ...) (unless ... ... ...)))(399)
>   funcall((lambda (item) (goto-char item) (let* (... ... ... ... ...) (looking-at
> org-list-full-item-re) (unless ... ...) (cond ... ... ... ...) (unless ... ... ...))) 399)
>   (if (or (not cell) (equal cell ...)) nil (funcall modify-item beg))
>   (unless (or (not cell) (equal cell ...)) (funcall modify-item beg))
>   (let* ((beg ...) (cell ...)) (unless (or ... ...) (funcall modify-item beg)))
>   (lambda (e) (unless (zerop ...) (apply shift-body-ind e)) (let* (... ...) (unless ... ...)))((404
> 399 0))
>   mapc((lambda (e) (unless (zerop ...) (apply shift-body-ind e)) (let* (... ...) (unless ... ...)))
> ((408 404 0) (404 399 0) (399 379 0) (379 300 0) (300 231 0) (231 147 0)))
>   (let (end-list acc-end itm-shift all-ends sliced-struct) (mapc (lambda ... ...) old-struct) (setq
> all-ends (sort ... ...)) (while (cdr all-ends) (let* ... ...)) (mapc (lambda ... ... ...)
> sliced-struct))
> ...

      reply	other threads:[~2012-10-20 23:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18 16:52 error in orgstruct-mode Peter Salazar
2012-10-19 22:31 ` Peter Salazar
2012-10-19 22:54   ` Nick Dokos
2012-10-20  0:21     ` Peter Salazar
2012-10-20  1:13       ` Nick Dokos
2012-10-20 21:27         ` Peter Salazar
2012-10-20 23:11           ` Nick Dokos [this message]

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=12148.1350774712@alphaville \
    --to=nicholas.dokos@hp.com \
    --cc=cycleofsong@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).