From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Lexical binding bug in org-list.el? Date: Fri, 6 Nov 2015 14:43:50 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zumw6-0004iZ-3K for emacs-orgmode@gnu.org; Fri, 06 Nov 2015 14:44:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zumw3-0007C5-Hl for emacs-orgmode@gnu.org; Fri, 06 Nov 2015 14:44:34 -0500 Received: from mail-ob0-x229.google.com ([2607:f8b0:4003:c01::229]:34838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zumw3-0007Bn-B7 for emacs-orgmode@gnu.org; Fri, 06 Nov 2015 14:44:31 -0500 Received: by obctp1 with SMTP id tp1so100496296obc.2 for ; Fri, 06 Nov 2015 11:44:30 -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-org list Hi, Here the required info: Org-mode version 8.3.2 (release_8.3.2-287-gcce317 @ /home/kmodi/usr_local/apps/6/emacs/master/share/emacs/site-lisp/org/) The bug is very easy to recreate. (1) In any buffer, M-x org-mode (2) Type * heading 1 (3) Do M-RET Now you have * heading 1 * (4) Do C-c - Now you have * heading 1 - (5) Do C-c * Boom! The depth var is not bound to anything in that lexical scope. ===== BACKTRACE Debugger entered--Lisp error: (void-variable depth) (funcall get-stars depth) eval((funcall get-stars depth)) (concat (eval istart) "%s") (cond ((eq type (quote descriptive)) (concat (let ((s (eval istart))) (or (and (string-match "[ \n ]+\\'" s) (replace-match "" t t s)) istart)) "%s" (eval ddend))) ((and counter (eq type (quote ordered))) (concat (eval icount) "%s")) (t (concat (eval istart) "%s"))) (concat (cond ((eq type (quote descriptive)) (concat (let ((s (eval istart))) (or (and (string-match "[ \n ]+\\'" s) (replace-match "" t t s)) istart)) "%s" (eval ddend))) ((and counter (eq type (quote ordered))) (concat (eval icount) "%s")) (t (concat (eval istart) "%s"))) (eval iend)) (let* ((counter (car-safe (prog1 item (setq item (cdr item))))) (fmt (concat (cond ((eq type (quote descriptive)) (concat (let ... ...) "%s" (eval ddend))) ((and counter (eq type ...)) (concat (eval icount) "%s")) (t (concat (eval istart) "%s"))) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* ((complete (string-match "^\\(.*\\)[ ]+::[ ]*" first)) (term (if complete (let ... ...) "???")) (desc (if complete (substring first ...) first))) (setq first (concat (eval dtstart) term (eval dtend) (eval ddstart) desc))))) (setcar item first) (format fmt (mapconcat (function (lambda (e) (if (stringp e) e (funcall export-sublist e (1+ depth))))) item (or (eval csep) "")))) (closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item (setq item (cdr item))))) (fmt (concat (cond ((eq type ...) (concat ... "%s" ...)) ((and counter ...) (concat ... "%s")) (t (concat ... "%s"))) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* ((complete (string-match "^\\(.*\\)[ ]+::[ ]*" first)) (term (if complete ... "???")) (desc (if complete ... first))) (setq first (concat (eval dtstart) term (eval dtend) (eval ddstart) desc))))) (setcar item first) (format fmt (mapconcat (function (lambda (e) (if (stringp e) e (funcall export-sublist e ...)))) item (or (eval csep) "")))))((nil "") unordered 0) funcall((closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item (setq item (cdr item))))) (fmt (concat (cond ((eq type ...) (concat ... "%s" ...)) ((and counter ...) (concat ... "%s")) (t (concat ... "%s"))) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* ((complete (string-match "^\\(.*\\)[ ]+::[ ]*" first)) (term (if complete ... "???")) (desc (if complete ... first))) (setq first (concat (eval dtstart) term (eval dtend) (eval ddstart) desc))))) (setcar item first) (format fmt (mapconcat (function (lambda (e) (if (stringp e) e (funcall export-sublist e ...)))) item (or (eval csep) ""))))) (nil "") unordered 0) (closure ((fmt . "%s") (items (nil "")) (type . unordered) (depth . 0) (sub unordered (nil "")) (export-item closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item ...))) (fmt (concat (cond ... ... ...) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* (... ... ...) (setq first ...)))) (setcar item first) (format fmt (mapconcat (function (lambda ... ...)) item (or (eval csep) ""))))) (export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (e) (funcall export-item e type depth))((nil "")) mapconcat((closure ((fmt . "%s") (items (nil "")) (type . unordered) (depth . 0) (sub unordered (nil "")) (export-item closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item ...))) (fmt (concat (cond ... ... ...) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* (... ... ...) (setq first ...)))) (setcar item first) (format fmt (mapconcat (function (lambda ... ...)) item (or (eval csep) ""))))) (export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (e) (funcall export-item e type depth)) ((nil "")) "\n") (format fmt (mapconcat (function (lambda (e) (funcall export-item e type depth))) items (or (eval isep) ""))) (let* ((type (car sub)) (items (cdr sub)) (fmt (concat (cond (splicep "%s") ((eq type (quote ordered)) (concat (eval ostart) "%s" (eval oend))) ((eq type (quote descriptive)) (concat (eval dstart) "%s" (eval dend))) (t (concat (eval ustart) "%s" (eval uend)))) (eval lsep)))) (format fmt (mapconcat (function (lambda (e) (funcall export-item e type depth))) items (or (eval isep) "")))) (closure ((export-item closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item ...))) (fmt (concat (cond ... ... ...) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* (... ... ...) (setq first ...)))) (setcar item first) (format fmt (mapconcat (function (lambda ... ...)) item (or (eval csep) ""))))) (export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (sub depth) (let* ((type (car sub)) (items (cdr sub)) (fmt (concat (cond (splicep "%s") ((eq type ...) (concat ... "%s" ...)) ((eq type ...) (concat ... "%s" ...)) (t (concat ... "%s" ...))) (eval lsep)))) (format fmt (mapconcat (function (lambda (e) (funcall export-item e type depth))) items (or (eval isep) "")))))((unordered (nil "")) 0) funcall((closure ((export-item closure ((export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (item type depth) (let* ((counter (car-safe (prog1 item ...))) (fmt (concat (cond ... ... ...) (eval iend))) (first (car item))) (cond ((string-match "\\[CBON\\]" first) (setq first (replace-match cbon t t first))) ((string-match "\\[CBOFF\\]" first) (setq first (replace-match cboff t t first))) ((string-match "\\[CBTRANS\\]" first) (setq first (replace-match cbtrans t t first)))) (if nobr (progn (setq first (org-list-item-trim-br first)))) (if (eq type (quote descriptive)) (progn (let* (... ... ...) (setq first ...)))) (setcar item first) (format fmt (mapconcat (function (lambda ... ...)) item (or (eval csep) ""))))) (export-sublist) (nobr) (cbtrans . "TODO") (cboff . "TODO") (cbon . "DONE") (csep if org--blankp "\n\n" "\n") (lsep) (isep if org--blankp "\n\n" "\n") (iend) (icount funcall get-stars depth) (istart funcall get-stars depth) (ddend) (ddstart) (dtend . " ") (dtstart . " ") (dend) (dstart) (uend) (ustart) (oend) (ostart) (splicep . t) (p :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (params :splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO") (list unordered (nil "")) org-tab-ind-state t) (sub depth) (let* ((type (car sub)) (items (cdr sub)) (fmt (concat (cond (splicep "%s") ((eq type ...) (concat ... "%s" ...)) ((eq type ...) (concat ... "%s" ...)) (t (concat ... "%s" ...))) (eval lsep)))) (format fmt (mapconcat (function (lambda (e) (funcall export-item e type depth))) items (or (eval isep) ""))))) (unordered (nil "")) 0) (concat (funcall export-sublist list 0) "\n") (let* ((p params) (splicep (plist-get p :splice)) (ostart (plist-get p :ostart)) (oend (plist-get p :oend)) (ustart (plist-get p :ustart)) (uend (plist-get p :uend)) (dstart (plist-get p :dstart)) (dend (plist-get p :dend)) (dtstart (plist-get p :dtstart)) (dtend (plist-get p :dtend)) (ddstart (plist-get p :ddstart)) (ddend (plist-get p :ddend)) (istart (plist-get p :istart)) (icount (plist-get p :icount)) (iend (plist-get p :iend)) (isep (plist-get p :isep)) (lsep (plist-get p :lsep)) (csep (plist-get p :csep)) (cbon (plist-get p :cbon)) (cboff (plist-get p :cboff)) (cbtrans (plist-get p :cbtrans)) (nobr (plist-get p :nobr)) export-sublist (export-item (function (lambda (item type depth) (let* ((counter ...) (fmt ...) (first ...)) (cond (... ...) (... ...) (... ...)) (if nobr (progn ...)) (if (eq type ...) (progn ...)) (setcar item first) (format fmt (mapconcat ... item ...)))))) (export-sublist (function (lambda (sub depth) (let* ((type ...) (items ...) (fmt ...)) (format fmt (mapconcat ... items ...))))))) (concat (funcall export-sublist list 0) "\n")) org-list-to-generic((unordered (nil "")) (:splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO")) (let* ((rule (cdr (assq (quote heading) org-blank-before-new-entry))) (level (org-reduced-level (or (org-current-level) 0))) (org--blankp (or (eq rule t) (and (eq rule (quote auto)) (save-excursion (outline-previous-heading) (org-previous-line-empty-p))))) (get-stars (function (lambda (d) (let ((oddeven-level ...)) (concat (make-string ... 42) " ")))))) (org-list-to-generic list (org-combine-plists (quote (:splice t :dtstart " " :dtend " " :istart (funcall get-stars depth) :icount (funcall get-stars depth) :isep (if org--blankp "\n\n" "\n") :csep (if org--blankp "\n\n" "\n") :cbon "DONE" :cboff "TODO" :cbtrans "TODO")) params))) org-list-to-subtree((unordered (nil ""))) org-toggle-heading(nil) funcall-interactively(org-toggle-heading nil) call-interactively(org-toggle-heading) org-ctrl-c-star() funcall-interactively(org-ctrl-c-star) call-interactively(org-ctrl-c-star nil nil) command-execute(org-ctrl-c-star) -- Kaushal Modi