From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlos Noguera Subject: Re: Bug: clock in generates bad drawer [8.3.4 (8.3.4-47-gaf853d-elpa @ /home/carlos/.emacs.d/elpa/org-20160502/)] Date: Tue, 10 May 2016 12:42:42 +0000 Message-ID: References: <87eg9hosal.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11402e126deaa405327c43ea Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b070A-0002RM-4c for emacs-orgmode@gnu.org; Tue, 10 May 2016 08:43:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0703-0003ZG-Ej for emacs-orgmode@gnu.org; Tue, 10 May 2016 08:43:01 -0400 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:36449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0701-0003Ym-5N for emacs-orgmode@gnu.org; Tue, 10 May 2016 08:42:55 -0400 Received: by mail-lf0-x236.google.com with SMTP id u64so13303819lff.3 for ; Tue, 10 May 2016 05:42:53 -0700 (PDT) In-Reply-To: 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" To: emacs-orgmode@gnu.org --001a11402e126deaa405327c43ea Content-Type: text/plain; charset=UTF-8 Hello Nicolas, FYI, I just discovered that the behaviour happens if "Org Clock Into Drawer" option in "Org Clock group" is set to "When at least N clock entries: 3" and I go from two entries to 3. If I change it to "Into LOGBOOK drawer" I don't have the problem any more. For the moment, I'll keep in " Into LOGBOOK drawer" as a workaround. Hope this helps. Carlos On Tue, May 10, 2016 at 9:05 AM Carlos Noguera < carlos.francisco.noguera@gmail.com> wrote: > Hi Nicolas, > > > Here you have a trace with an uncompiled Org. Let me know if you need > something else. > > Carlos. > > Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil) > insert(":" nil ":\n") > (save-excursion (insert ":" drawer ":\n")) > (let ((end (point-marker))) (goto-char beg) (save-excursion (insert ":" > drawer ":\n")) (org-flag-drawer t) (org-indent-region (point) end) > (forward-line) (if org-log-states-order-reversed nil (goto-char end) > (beginning-of-line -1)) (set-marker end nil)) > (let ((beg (point))) (insert (mapconcat (function (lambda (p) > (save-excursion (goto-char p) (org-trim (delete-and-extract-region ... > ...))))) positions "\n") "\n:END:\n") (let ((end (point-marker))) > (goto-char beg) (save-excursion (insert ":" drawer ":\n")) (org-flag-drawer > t) (org-indent-region (point) end) (forward-line) (if > org-log-states-order-reversed nil (goto-char end) (beginning-of-line -1)) > (set-marker end nil))) > (cond ((null positions) (org-end-of-meta-data) (if (bolp) nil (insert > "\n")) (if (and org-clock-into-drawer (or (not (wholenump > org-clock-into-drawer)) (< org-clock-into-drawer 2))) (progn (let ((beg > (point))) (insert ":" drawer ":\n:END:\n") (org-indent-region beg (point)) > (goto-char beg) (org-flag-drawer t) (forward-line))))) ((or drawer (and > (wholenump org-clock-into-drawer) (>= (1+ count) org-clock-into-drawer))) > (org-end-of-meta-data) (let ((beg (point))) (insert (mapconcat (function > (lambda (p) (save-excursion ... ...))) positions "\n") "\n:END:\n") (let > ((end (point-marker))) (goto-char beg) (save-excursion (insert ":" drawer > ":\n")) (org-flag-drawer t) (org-indent-region (point) end) (forward-line) > (if org-log-states-order-reversed nil (goto-char end) (beginning-of-line > -1)) (set-marker end nil)))) (org-log-states-order-reversed (goto-char (car > (last positions)))) (t (goto-char (car positions)))) > (let ((clock-re (concat "^[ ]*" org-clock-string)) (count 0) positions > first) (save-excursion (while (re-search-forward clock-re end t) (let > ((element (org-element-at-point))) (if (eq (org-element-type element) > (quote clock)) (progn (setq positions (cons ... positions) count (1+ > count))))))) (cond ((null positions) (org-end-of-meta-data) (if (bolp) nil > (insert "\n")) (if (and org-clock-into-drawer (or (not (wholenump > org-clock-into-drawer)) (< org-clock-into-drawer 2))) (progn (let ((beg > ...)) (insert ":" drawer ":\n:END:\n") (org-indent-region beg (point)) > (goto-char beg) (org-flag-drawer t) (forward-line))))) ((or drawer (and > (wholenump org-clock-into-drawer) (>= (1+ count) org-clock-into-drawer))) > (org-end-of-meta-data) (let ((beg (point))) (insert (mapconcat (function > (lambda ... ...)) positions "\n") "\n:END:\n") (let ((end (point-marker))) > (goto-char beg) (save-excursion (insert ":" drawer ":\n")) (org-flag-drawer > t) (org-indent-region (point) end) (forward-line) (if > org-log-states-order-reversed nil (goto-char end) (beginning-of-line -1)) > (set-marker end nil)))) (org-log-states-order-reversed (goto-char (car > (last positions)))) (t (goto-char (car positions))))) > (let* ((beg (line-beginning-position)) (end (save-excursion > (outline-next-heading) (point))) (org-clock-into-drawer > (org-clock-into-drawer)) (drawer (org-clock-drawer-name))) (if > find-unclosed (progn (let ((open-clock-re (concat "^[ ]*" org-clock-string > " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+ > +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (while (re-search-forward > open-clock-re end t) (let ((element ...)) (if (and ... ...) (progn ... > ...))))))) (if drawer (progn (goto-char beg) (let ((drawer-re (concat "^[ > ]*:" (regexp-quote drawer) ":[ ]*quot;))) (while (re-search-forward > drawer-re end t) (let ((element ...)) (if (eq ... ...) (progn ...))))))) > (goto-char beg) (let ((clock-re (concat "^[ ]*" org-clock-string)) (count > 0) positions first) (save-excursion (while (re-search-forward clock-re end > t) (let ((element (org-element-at-point))) (if (eq (org-element-type > element) (quote clock)) (progn (setq positions ... count ...)))))) (cond > ((null positions) (org-end-of-meta-data) (if (bolp) nil (insert "\n")) (if > (and org-clock-into-drawer (or (not ...) (< org-clock-into-drawer 2))) > (progn (let (...) (insert ":" drawer ":\n:END:\n") (org-indent-region beg > ...) (goto-char beg) (org-flag-drawer t) (forward-line))))) ((or drawer > (and (wholenump org-clock-into-drawer) (>= (1+ count) > org-clock-into-drawer))) (org-end-of-meta-data) (let ((beg (point))) > (insert (mapconcat (function ...) positions "\n") "\n:END:\n") (let ((end > ...)) (goto-char beg) (save-excursion (insert ":" drawer ":\n")) > (org-flag-drawer t) (org-indent-region (point) end) (forward-line) (if > org-log-states-order-reversed nil (goto-char end) (beginning-of-line -1)) > (set-marker end nil)))) (org-log-states-order-reversed (goto-char (car > (last positions)))) (t (goto-char (car positions)))))) > (catch (quote exit) (let* ((beg (line-beginning-position)) (end > (save-excursion (outline-next-heading) (point))) (org-clock-into-drawer > (org-clock-into-drawer)) (drawer (org-clock-drawer-name))) (if > find-unclosed (progn (let ((open-clock-re (concat "^[ ]*" org-clock-string > " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+ > +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (while (re-search-forward > open-clock-re end t) (let (...) (if ... ...)))))) (if drawer (progn > (goto-char beg) (let ((drawer-re (concat "^[ ]*:" ... ":[ ]*quot;))) > (while (re-search-forward drawer-re end t) (let (...) (if ... ...)))))) > (goto-char beg) (let ((clock-re (concat "^[ ]*" org-clock-string)) (count > 0) positions first) (save-excursion (while (re-search-forward clock-re end > t) (let ((element ...)) (if (eq ... ...) (progn ...))))) (cond ((null > positions) (org-end-of-meta-data) (if (bolp) nil (insert "\n")) (if (and > org-clock-into-drawer (or ... ...)) (progn (let ... ... ... ... ... ...)))) > ((or drawer (and (wholenump org-clock-into-drawer) (>= ... > org-clock-into-drawer))) (org-end-of-meta-data) (let ((beg ...)) (insert > (mapconcat ... positions "\n") "\n:END:\n") (let (...) (goto-char beg) > (save-excursion ...) (org-flag-drawer t) (org-indent-region ... end) > (forward-line) (if org-log-states-order-reversed nil ... ...) (set-marker > end nil)))) (org-log-states-order-reversed (goto-char (car (last > positions)))) (t (goto-char (car positions))))))) > org-clock-find-position(nil) > (save-restriction (widen) (goto-char target-pos) (org-back-to-heading t) > (or interrupting (move-marker org-clock-interrupted-task nil)) (run-hooks > (quote org-clock-in-prepare-hook)) (org-clock-history-push) (setq > org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp > org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let > ((newstate (funcall org-clock-in-switch-to-state (match-string 2)))) (if > newstate (org-todo newstate)))) ((and org-clock-in-switch-to-state (not > (looking-at (concat org-outline-regexp "[ ]*" org-clock-in-switch-to-state > "\\>")))) (org-todo org-clock-in-switch-to-state))) (setq org-clock-heading > (cond ((and org-clock-heading-function (functionp > org-clock-heading-function)) (funcall org-clock-heading-function)) ((nth 4 > (org-heading-components)) (replace-regexp-in-string > "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" (match-string-no-properties 4))) (t > "???"))) (org-clock-find-position org-clock-in-resume) (cond ((and > org-clock-in-resume (looking-at (concat "^[ ]*" org-clock-string " > \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+.? > +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (message "Matched %s" > (match-string 1)) (setq ts (concat "[" (match-string 1) "]")) (goto-char > (match-end 1)) (setq org-clock-start-time (apply (quote encode-time) > (org-parse-time-string (match-string 1)))) (setq org-clock-effort > (org-entry-get (point) org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item (org-clock-get-sum-start)))) ((eq > org-clock-in-resume (quote auto-restart)) (message "Cannot restart clock > because task does not contain unfinished clock") (ding) (sit-for 2) (throw > (quote abort) nil)) (t (insert-before-markers "\n") (backward-char 1) > (org-indent-line) (if (and (save-excursion (end-of-line 0) > (org-in-item-p))) (progn (beginning-of-line 1) (org-indent-line-to (- > (org-get-indentation) 2)))) (insert org-clock-string " ") (setq > org-clock-effort (org-entry-get (point) org-effort-property)) (setq > org-clock-total-time (org-clock-sum-current-item > (org-clock-get-sum-start))) (setq org-clock-start-time (or (and > org-clock-continuously org-clock-out-time) (and leftover (y-or-n-p (format > "You stopped another clock %d mins ago; start this one from then? " ...)) > leftover) start-time (org-current-time org-clock-rounding-minutes t))) > (setq ts (org-insert-time-stamp org-clock-start-time (quote with-hm) (quote > inactive))))) (move-marker org-clock-marker (point) (buffer-base-buffer)) > (move-marker org-clock-hd-marker (save-excursion (org-back-to-heading t) > (point)) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq > org-clock-clocked-in-display (quote mode-line)) (eq > org-clock-clocked-in-display (quote both))) (progn (or global-mode-string > (setq global-mode-string (quote ("")))) (or (memq (quote > org-mode-line-string) global-mode-string) (setq global-mode-string (append > global-mode-string (quote (org-mode-line-string))))))) (if (or (eq > org-clock-clocked-in-display (quote frame-title)) (eq > org-clock-clocked-in-display (quote both))) (progn (setq frame-title-format > org-clock-frame-title-format))) (org-clock-update-mode-line) (if > org-clock-mode-line-timer (progn (cancel-timer org-clock-mode-line-timer) > (setq org-clock-mode-line-timer nil))) (if org-clock-clocked-in-display > (progn (setq org-clock-mode-line-timer (run-with-timer > org-clock-update-period org-clock-update-period (quote > org-clock-update-mode-line))))) (if org-clock-idle-timer (progn > (cancel-timer org-clock-idle-timer) (setq org-clock-idle-timer nil))) (setq > org-clock-idle-timer (run-with-timer 60 60 (quote > org-resolve-clocks-if-idle))) (message "Clock starts at %s - %s" ts > org--msg-extra) (run-hooks (quote org-clock-in-hook))) > (save-excursion (save-restriction (widen) (goto-char target-pos) > (org-back-to-heading t) (or interrupting (move-marker > org-clock-interrupted-task nil)) (run-hooks (quote > org-clock-in-prepare-hook)) (org-clock-history-push) (setq > org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp > org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let > ((newstate (funcall org-clock-in-switch-to-state ...))) (if newstate > (org-todo newstate)))) ((and org-clock-in-switch-to-state (not (looking-at > (concat org-outline-regexp "[ ]*" org-clock-in-switch-to-state "\\>")))) > (org-todo org-clock-in-switch-to-state))) (setq org-clock-heading (cond > ((and org-clock-heading-function (functionp org-clock-heading-function)) > (funcall org-clock-heading-function)) ((nth 4 (org-heading-components)) > (replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" > (match-string-no-properties 4))) (t "???"))) (org-clock-find-position > org-clock-in-resume) (cond ((and org-clock-in-resume (looking-at (concat > "^[ ]*" org-clock-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " > *\\sw+.? +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (message "Matched %s" > (match-string 1)) (setq ts (concat "[" (match-string 1) "]")) (goto-char > (match-end 1)) (setq org-clock-start-time (apply (quote encode-time) > (org-parse-time-string (match-string 1)))) (setq org-clock-effort > (org-entry-get (point) org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item (org-clock-get-sum-start)))) ((eq > org-clock-in-resume (quote auto-restart)) (message "Cannot restart clock > because task does not contain unfinished clock") (ding) (sit-for 2) (throw > (quote abort) nil)) (t (insert-before-markers "\n") (backward-char 1) > (org-indent-line) (if (and (save-excursion (end-of-line 0) > (org-in-item-p))) (progn (beginning-of-line 1) (org-indent-line-to (- ... > 2)))) (insert org-clock-string " ") (setq org-clock-effort (org-entry-get > (point) org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item (org-clock-get-sum-start))) (setq > org-clock-start-time (or (and org-clock-continuously org-clock-out-time) > (and leftover (y-or-n-p ...) leftover) start-time (org-current-time > org-clock-rounding-minutes t))) (setq ts (org-insert-time-stamp > org-clock-start-time (quote with-hm) (quote inactive))))) (move-marker > org-clock-marker (point) (buffer-base-buffer)) (move-marker > org-clock-hd-marker (save-excursion (org-back-to-heading t) (point)) > (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq > org-clock-clocked-in-display (quote mode-line)) (eq > org-clock-clocked-in-display (quote both))) (progn (or global-mode-string > (setq global-mode-string (quote ("")))) (or (memq (quote > org-mode-line-string) global-mode-string) (setq global-mode-string (append > global-mode-string (quote ...)))))) (if (or (eq > org-clock-clocked-in-display (quote frame-title)) (eq > org-clock-clocked-in-display (quote both))) (progn (setq frame-title-format > org-clock-frame-title-format))) (org-clock-update-mode-line) (if > org-clock-mode-line-timer (progn (cancel-timer org-clock-mode-line-timer) > (setq org-clock-mode-line-timer nil))) (if org-clock-clocked-in-display > (progn (setq org-clock-mode-line-timer (run-with-timer > org-clock-update-period org-clock-update-period (quote > org-clock-update-mode-line))))) (if org-clock-idle-timer (progn > (cancel-timer org-clock-idle-timer) (setq org-clock-idle-timer nil))) (setq > org-clock-idle-timer (run-with-timer 60 60 (quote > org-resolve-clocks-if-idle))) (message "Clock starts at %s - %s" ts > org--msg-extra) (run-hooks (quote org-clock-in-hook)))) > (save-excursion (if (and selected-task (marker-buffer selected-task)) > (progn (set-buffer (org-base-buffer (marker-buffer selected-task))) (setq > target-pos (marker-position selected-task)) (move-marker selected-task > nil))) (save-excursion (save-restriction (widen) (goto-char target-pos) > (org-back-to-heading t) (or interrupting (move-marker > org-clock-interrupted-task nil)) (run-hooks (quote > org-clock-in-prepare-hook)) (org-clock-history-push) (setq > org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp > org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let > ((newstate ...)) (if newstate (org-todo newstate)))) ((and > org-clock-in-switch-to-state (not (looking-at ...))) (org-todo > org-clock-in-switch-to-state))) (setq org-clock-heading (cond ((and > org-clock-heading-function (functionp org-clock-heading-function)) (funcall > org-clock-heading-function)) ((nth 4 (org-heading-components)) > (replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" > (match-string-no-properties 4))) (t "???"))) (org-clock-find-position > org-clock-in-resume) (cond ((and org-clock-in-resume (looking-at (concat > "^[ ]*" org-clock-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " > *\\sw+.? +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (message "Matched %s" > (match-string 1)) (setq ts (concat "[" (match-string 1) "]")) (goto-char > (match-end 1)) (setq org-clock-start-time (apply (quote encode-time) > (org-parse-time-string ...))) (setq org-clock-effort (org-entry-get (point) > org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item (org-clock-get-sum-start)))) ((eq > org-clock-in-resume (quote auto-restart)) (message "Cannot restart clock > because task does not contain unfinished clock") (ding) (sit-for 2) (throw > (quote abort) nil)) (t (insert-before-markers "\n") (backward-char 1) > (org-indent-line) (if (and (save-excursion ... ...)) (progn > (beginning-of-line 1) (org-indent-line-to ...))) (insert org-clock-string " > ") (setq org-clock-effort (org-entry-get (point) org-effort-property)) > (setq org-clock-total-time (org-clock-sum-current-item > (org-clock-get-sum-start))) (setq org-clock-start-time (or (and > org-clock-continuously org-clock-out-time) (and leftover ... leftover) > start-time (org-current-time org-clock-rounding-minutes t))) (setq ts > (org-insert-time-stamp org-clock-start-time (quote with-hm) (quote > inactive))))) (move-marker org-clock-marker (point) (buffer-base-buffer)) > (move-marker org-clock-hd-marker (save-excursion (org-back-to-heading t) > (point)) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq > org-clock-clocked-in-display (quote mode-line)) (eq > org-clock-clocked-in-display (quote both))) (progn (or global-mode-string > (setq global-mode-string (quote ...))) (or (memq (quote > org-mode-line-string) global-mode-string) (setq global-mode-string (append > global-mode-string ...))))) (if (or (eq org-clock-clocked-in-display (quote > frame-title)) (eq org-clock-clocked-in-display (quote both))) (progn (setq > frame-title-format org-clock-frame-title-format))) > (org-clock-update-mode-line) (if org-clock-mode-line-timer (progn > (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer > nil))) (if org-clock-clocked-in-display (progn (setq > org-clock-mode-line-timer (run-with-timer org-clock-update-period > org-clock-update-period (quote org-clock-update-mode-line))))) (if > org-clock-idle-timer (progn (cancel-timer org-clock-idle-timer) (setq > org-clock-idle-timer nil))) (setq org-clock-idle-timer (run-with-timer 60 > 60 (quote org-resolve-clocks-if-idle))) (message "Clock starts at %s - %s" > ts org--msg-extra) (run-hooks (quote org-clock-in-hook))))) > (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) > (org-clocking-p))) ts selected-task target-pos (org--msg-extra "") > (leftover (and (not org-clock-resolving-clocks) org-clock-leftover-time))) > (if (and org-clock-auto-clock-resolution (or (not interrupting) (eq t > org-clock-auto-clock-resolution)) (not org-clock-clocking-in) (not > org-clock-resolving-clocks)) (progn (setq org-clock-leftover-time nil) (let > ((org-clock-clocking-in t)) (org-resolve-clocks)))) (if (equal select > (quote (64))) (progn (let ((org-clock-continuously t)) (org-clock-in nil > org-clock-out-time)))) (if (equal select (quote (4))) (progn (setq > selected-task (org-clock-select-task "Clock-in on task: ")) (if > selected-task (setq selected-task (copy-marker selected-task)) (error > "Abort")))) (if (equal select (quote (16))) (progn > (org-clock-mark-default-task))) (if interrupting (progn (if (save-excursion > (if selected-task nil (org-back-to-heading t)) (and (equal (marker-buffer > org-clock-hd-marker) (if selected-task ... ...)) (= (marker-position > org-clock-hd-marker) (if selected-task ... ...)) (equal > org-clock-current-task (nth 4 ...)))) (progn (message "Clock continues in > \"%s\"" org-clock-heading) (throw (quote abort) nil))) (move-marker > org-clock-interrupted-task (marker-position org-clock-marker) > (marker-buffer org-clock-marker)) (let ((org-clock-clocking-in t)) > (org-clock-out nil t)))) (setq target-pos (if (and (eobp) (not > (org-at-heading-p))) (point-at-bol 0) (point))) (save-excursion (if (and > selected-task (marker-buffer selected-task)) (progn (set-buffer > (org-base-buffer (marker-buffer selected-task))) (setq target-pos > (marker-position selected-task)) (move-marker selected-task nil))) > (save-excursion (save-restriction (widen) (goto-char target-pos) > (org-back-to-heading t) (or interrupting (move-marker > org-clock-interrupted-task nil)) (run-hooks (quote > org-clock-in-prepare-hook)) (org-clock-history-push) (setq > org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp > org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let > (...) (if newstate ...))) ((and org-clock-in-switch-to-state (not ...)) > (org-todo org-clock-in-switch-to-state))) (setq org-clock-heading (cond > ((and org-clock-heading-function ...) (funcall org-clock-heading-function)) > ((nth 4 ...) (replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" > "\\1" ...)) (t "???"))) (org-clock-find-position org-clock-in-resume) (cond > ((and org-clock-in-resume (looking-at ...)) (message "Matched %s" > (match-string 1)) (setq ts (concat "[" ... "]")) (goto-char (match-end 1)) > (setq org-clock-start-time (apply ... ...)) (setq org-clock-effort > (org-entry-get ... org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item ...))) ((eq org-clock-in-resume (quote > auto-restart)) (message "Cannot restart clock because task does not contain > unfinished clock") (ding) (sit-for 2) (throw (quote abort) nil)) (t > (insert-before-markers "\n") (backward-char 1) (org-indent-line) (if (and > ...) (progn ... ...)) (insert org-clock-string " ") (setq org-clock-effort > (org-entry-get ... org-effort-property)) (setq org-clock-total-time > (org-clock-sum-current-item ...)) (setq org-clock-start-time (or ... ... > start-time ...)) (setq ts (org-insert-time-stamp org-clock-start-time ... > ...)))) (move-marker org-clock-marker (point) (buffer-base-buffer)) > (move-marker org-clock-hd-marker (save-excursion (org-back-to-heading t) > (point)) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq > org-clock-clocked-in-display (quote mode-line)) (eq > org-clock-clocked-in-display (quote both))) (progn (or global-mode-string > (setq global-mode-string ...)) (or (memq ... global-mode-string) (setq > global-mode-string ...)))) (if (or (eq org-clock-clocked-in-display (quote > frame-title)) (eq org-clock-clocked-in-display (quote both))) (progn (setq > frame-title-format org-clock-frame-title-format))) > (org-clock-update-mode-line) (if org-clock-mode-line-timer (progn > (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer > nil))) (if org-clock-clocked-in-display (progn (setq > org-clock-mode-line-timer (run-with-timer org-clock-update-period > org-clock-update-period ...)))) (if org-clock-idle-timer (progn > (cancel-timer org-clock-idle-timer) (setq org-clock-idle-timer nil))) (setq > org-clock-idle-timer (run-with-timer 60 60 (quote > org-resolve-clocks-if-idle))) (message "Clock starts at %s - %s" ts > org--msg-extra) (run-hooks (quote org-clock-in-hook)))))) > (catch (quote abort) (let ((interrupting (and (not > org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) ts > selected-task target-pos (org--msg-extra "") (leftover (and (not > org-clock-resolving-clocks) org-clock-leftover-time))) (if (and > org-clock-auto-clock-resolution (or (not interrupting) (eq t > org-clock-auto-clock-resolution)) (not org-clock-clocking-in) (not > org-clock-resolving-clocks)) (progn (setq org-clock-leftover-time nil) (let > ((org-clock-clocking-in t)) (org-resolve-clocks)))) (if (equal select > (quote (64))) (progn (let ((org-clock-continuously t)) (org-clock-in nil > org-clock-out-time)))) (if (equal select (quote (4))) (progn (setq > selected-task (org-clock-select-task "Clock-in on task: ")) (if > selected-task (setq selected-task (copy-marker selected-task)) (error > "Abort")))) (if (equal select (quote (16))) (progn > (org-clock-mark-default-task))) (if interrupting (progn (if (save-excursion > (if selected-task nil (org-back-to-heading t)) (and (equal ... ...) (= ... > ...) (equal org-clock-current-task ...))) (progn (message "Clock continues > in \"%s\"" org-clock-heading) (throw (quote abort) nil))) (move-marker > org-clock-interrupted-task (marker-position org-clock-marker) > (marker-buffer org-clock-marker)) (let ((org-clock-clocking-in t)) > (org-clock-out nil t)))) (setq target-pos (if (and (eobp) (not > (org-at-heading-p))) (point-at-bol 0) (point))) (save-excursion (if (and > selected-task (marker-buffer selected-task)) (progn (set-buffer > (org-base-buffer (marker-buffer selected-task))) (setq target-pos > (marker-position selected-task)) (move-marker selected-task nil))) > (save-excursion (save-restriction (widen) (goto-char target-pos) > (org-back-to-heading t) (or interrupting (move-marker > org-clock-interrupted-task nil)) (run-hooks (quote > org-clock-in-prepare-hook)) (org-clock-history-push) (setq > org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp > org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let > ... ...)) ((and org-clock-in-switch-to-state ...) (org-todo > org-clock-in-switch-to-state))) (setq org-clock-heading (cond (... ...) > (... ...) (t "???"))) (org-clock-find-position org-clock-in-resume) (cond > ((and org-clock-in-resume ...) (message "Matched %s" ...) (setq ts ...) > (goto-char ...) (setq org-clock-start-time ...) (setq org-clock-effort ...) > (setq org-clock-total-time ...)) ((eq org-clock-in-resume ...) (message > "Cannot restart clock because task does not contain unfinished clock") > (ding) (sit-for 2) (throw ... nil)) (t (insert-before-markers "\n") > (backward-char 1) (org-indent-line) (if ... ...) (insert org-clock-string " > ") (setq org-clock-effort ...) (setq org-clock-total-time ...) (setq > org-clock-start-time ...) (setq ts ...))) (move-marker org-clock-marker > (point) (buffer-base-buffer)) (move-marker org-clock-hd-marker > (save-excursion (org-back-to-heading t) (point)) (buffer-base-buffer)) > (setq org-clock-has-been-used t) (if (or (eq org-clock-clocked-in-display > ...) (eq org-clock-clocked-in-display ...)) (progn (or global-mode-string > ...) (or ... ...))) (if (or (eq org-clock-clocked-in-display ...) (eq > org-clock-clocked-in-display ...)) (progn (setq frame-title-format > org-clock-frame-title-format))) (org-clock-update-mode-line) (if > org-clock-mode-line-timer (progn (cancel-timer org-clock-mode-line-timer) > (setq org-clock-mode-line-timer nil))) (if org-clock-clocked-in-display > (progn (setq org-clock-mode-line-timer ...))) (if org-clock-idle-timer > (progn (cancel-timer org-clock-idle-timer) (setq org-clock-idle-timer > nil))) (setq org-clock-idle-timer (run-with-timer 60 60 (quote > org-resolve-clocks-if-idle))) (message "Clock starts at %s - %s" ts > org--msg-extra) (run-hooks (quote org-clock-in-hook))))))) > > org-clock-in(nil) > call-interactively(org-clock-in nil nil) > command-execute(org-clock-in) > > > > On Thu, May 5, 2016 at 9:52 AM Nicolas Goaziou > wrote: > >> Hello, >> >> Carlos Noguera writes: >> >> > When clocking in under a headline that already has clock entries, the >> > entries are not correclty bundled in a drawer, generating a: (I removed >> > the bytecode because gmail didn't like it) >> > >> > Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil) >> > byte-code("REMOVED" [beg end org-clock-into-drawer drawer >> find-unclosed >> > org-clock-string line-beginning-position outline-next-heading >> > org-clock-drawer-name "^[ ]*" " >> > \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+ >> > +[012][0-9]:[0-5][0-9]\\)\\][ ]*$" re-search-forward t >> org-element-at-point >> > org-element-type clock org-element-property :status running >> > beginning-of-line throw exit "^[ ]*:" regexp-quote ":[ ]*$" >> :contents-end >> > nil 0 org-end-of-meta-data "\n" wholenump 2 ":" ":\n:END:\n" >> > org-indent-region org-flag-drawer mapconcat #[(p) "\212 >> > b\210\302\212\303\304x\210\305\306!)\305\306!\" >> > \307\310\311\307\312\311 ##*\207" >> > [p s delete-and-extract-region " >> > \n" nil line-beginning-position 2 replace-regexp-in-string "\\`[ \n >> > ]+" "" "[ \n >> > ]+\\'"] 7] "\n:END:\n" point-marker ":\n" -1 last open-clock-re element >> > drawer-re cend org-log-states-order-reversed first ...] 4) >> > org-clock-find-position(nil) >> > byte-code("REMOVED" [org-clock-resolving-clocks-due-to-idleness >> > org-clock-resolving-clocks org-clock-leftover-time leftover >> org--msg-extra >> > target-pos org-clocking-p nil "" t org-resolve-clocks (64) org-clock-in >> (4) >> > org-clock-select-task "Clock-in on task: " copy-marker error "Abort" >> (16) >> > org-clock-mark-default-task org-back-to-heading marker-buffer >> > marker-position 4 org-heading-components message "Clock continues in >> > \"%s\"" throw abort org-clock-out org-at-heading-p point-at-bol 0 >> > org-base-buffer run-hooks org-clock-in-prepare-hook >> org-clock-history-push >> > functionp looking-at match-string 2 org-todo "[ ]*" "\\>" >> > replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" >> > match-string-no-properties "???" ...] 8) >> > org-clock-in(nil) >> > call-interactively(org-clock-in nil nil) >> > command-execute(org-clock-in) >> > >> > that prevents the clock in >> > I go from >> > >> > ** TODO a task >> > CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] => 1:29 >> > CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] => 0:00 >> > >> > C-c C-x C-i >> > >> > to >> > >> > ** TODO a task >> > :CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] => 0:00 >> > CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] => 1:29 >> > :END: >> >> I cannot reproduce it. In the example above, I get >> >> * NEXT a task >> :LOGBOOK: >> CLOCK: [2016-05-05 Thu 09:52] >> CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] => 0:00 >> CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] => 1:29 >> :END: >> >> > Any ideas? >> >> Not quite. Could you provide a backtrace with an uncompiled Org >> (org-reload with universal argument) ? >> >> Regards, >> >> -- >> Nicolas Goaziou >> > --001a11402e126deaa405327c43ea Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello Nicolas,


FYI, I ju= st discovered that the behaviour happens if =C2=A0"Org Clock Into Draw= er" option in "Org Clock group" is set to "When at leas= t N clock entries: 3" and I go from two entries to 3.
If I c= hange it to =C2=A0"Into LOGBOOK drawer" I don't have the prob= lem any more.

For the moment, I'll keep in &qu= ot;=C2=A0Into LOGBOOK drawer" as a workaround.

Hope this helps.

Carlos


=
On Tue, May 10, 2016 at 9:05 AM= Carlos Noguera <c= arlos.francisco.noguera@gmail.com> wrote:
Hi Nicolas,


Here you have a trace with an uncompiled Org. Let me know if you need som= ething else.

Carlos.
<= div>
Debugger entered--Lisp error: (wrong-type-argument char-or-st= ring-p nil)
insert(":" nil ":\n&= quot;)
(save-excursion (insert ":" drawer ":\n"))<= br> (let ((end (point-marker))) (goto-char beg) (save-excursion (insert &q= uot;:" drawer ":\n")) (org-flag-drawer t) (org-indent-region= (point) end) (forward-line) (if org-log-states-order-reversed nil (goto-ch= ar end) (beginning-of-line -1)) (set-marker end nil))
(let ((beg (poin= t))) (insert (mapconcat (function (lambda (p) (save-excursion (goto-char p)= (org-trim (delete-and-extract-region ... ...))))) positions "\n"= ) "\n:END:\n") (let ((end (point-marker))) (goto-char beg) (save-= excursion (insert ":" drawer ":\n")) (org-flag-drawer t= ) (org-indent-region (point) end) (forward-line) (if org-log-states-order-r= eversed nil (goto-char end) (beginning-of-line -1)) (set-marker end nil)))<= br> (cond ((null positions) (org-end-of-meta-data) (if (bolp) nil (insert = "\n")) (if (and org-clock-into-drawer (or (not (wholenump org-clo= ck-into-drawer)) (< org-clock-into-drawer 2))) (progn (let ((beg (point)= )) (insert ":" drawer ":\n:END:\n") (org-indent-region = beg (point)) (goto-char beg) (org-flag-drawer t) (forward-line))))) ((or dr= awer (and (wholenump org-clock-into-drawer) (>=3D (1+ count) org-clock-i= nto-drawer))) (org-end-of-meta-data) (let ((beg (point))) (insert (mapconca= t (function (lambda (p) (save-excursion ... ...))) positions "\n"= ) "\n:END:\n") (let ((end (point-marker))) (goto-char beg) (save-= excursion (insert ":" drawer ":\n")) (org-flag-drawer t= ) (org-indent-region (point) end) (forward-line) (if org-log-states-order-r= eversed nil (goto-char end) (beginning-of-line -1)) (set-marker end nil))))= (org-log-states-order-reversed (goto-char (car (last positions)))) (t (got= o-char (car positions))))
(let ((clock-re (concat "^[ ]*" or= g-clock-string)) (count 0) positions first) (save-excursion (while (re-sear= ch-forward clock-re end t) (let ((element (org-element-at-point))) (if (eq = (org-element-type element) (quote clock)) (progn (setq positions (cons ... = positions) count (1+ count))))))) (cond ((null positions) (org-end-of-meta-= data) (if (bolp) nil (insert "\n")) (if (and org-clock-into-drawe= r (or (not (wholenump org-clock-into-drawer)) (< org-clock-into-drawer 2= ))) (progn (let ((beg ...)) (insert ":" drawer ":\n:END:\n&q= uot;) (org-indent-region beg (point)) (goto-char beg) (org-flag-drawer t) (= forward-line))))) ((or drawer (and (wholenump org-clock-into-drawer) (>= =3D (1+ count) org-clock-into-drawer))) (org-end-of-meta-data) (let ((beg (= point))) (insert (mapconcat (function (lambda ... ...)) positions "\n&= quot;) "\n:END:\n") (let ((end (point-marker))) (goto-char beg) (= save-excursion (insert ":" drawer ":\n")) (org-flag-dra= wer t) (org-indent-region (point) end) (forward-line) (if org-log-states-or= der-reversed nil (goto-char end) (beginning-of-line -1)) (set-marker end ni= l)))) (org-log-states-order-reversed (goto-char (car (last positions)))) (t= (goto-char (car positions)))))
(let* ((beg (line-beginning-position))= (end (save-excursion (outline-next-heading) (point))) (org-clock-into-draw= er (org-clock-into-drawer)) (drawer (org-clock-drawer-name))) (if find-uncl= osed (progn (let ((open-clock-re (concat "^[ ]*" org-clock-string= " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+ +[= 012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (while (re-search-forwa= rd open-clock-re end t) (let ((element ...)) (if (and ... ...) (progn ... .= ..))))))) (if drawer (progn (goto-char beg) (let ((drawer-re (concat "= ^[ ]*:" (regexp-quote drawer) ":[ ]*quot;))) (while = (re-search-forward drawer-re end t) (let ((element ...)) (if (eq ... ...) (= progn ...))))))) (goto-char beg) (let ((clock-re (concat "^[ ]*" = org-clock-string)) (count 0) positions first) (save-excursion (while (re-se= arch-forward clock-re end t) (let ((element (org-element-at-point))) (if (e= q (org-element-type element) (quote clock)) (progn (setq positions ... coun= t ...)))))) (cond ((null positions) (org-end-of-meta-data) (if (bolp) nil (= insert "\n")) (if (and org-clock-into-drawer (or (not ...) (< = org-clock-into-drawer 2))) (progn (let (...) (insert ":" drawer &= quot;:\n:END:\n") (org-indent-region beg ...) (goto-char beg) (org-fla= g-drawer t) (forward-line))))) ((or drawer (and (wholenump org-clock-into-d= rawer) (>=3D (1+ count) org-clock-into-drawer))) (org-end-of-meta-data) = (let ((beg (point))) (insert (mapconcat (function ...) positions "\n&q= uot;) "\n:END:\n") (let ((end ...)) (goto-char beg) (save-excursi= on (insert ":" drawer ":\n")) (org-flag-drawer t) (org-= indent-region (point) end) (forward-line) (if org-log-states-order-reversed= nil (goto-char end) (beginning-of-line -1)) (set-marker end nil)))) (org-l= og-states-order-reversed (goto-char (car (last positions)))) (t (goto-char = (car positions))))))
(catch (quote exit) (let* ((beg (line-beginning-p= osition)) (end (save-excursion (outline-next-heading) (point))) (org-clock-= into-drawer (org-clock-into-drawer)) (drawer (org-clock-drawer-name))) (if = find-unclosed (progn (let ((open-clock-re (concat "^[ ]*" org-clo= ck-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " = *\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (while (re-sea= rch-forward open-clock-re end t) (let (...) (if ... ...)))))) (if drawer (p= rogn (goto-char beg) (let ((drawer-re (concat "^[ ]*:" ... "= :[ ]*quot;))) (while (re-search-forward drawer-re end t) (let = (...) (if ... ...)))))) (goto-char beg) (let ((clock-re (concat "^[ ]*= " org-clock-string)) (count 0) positions first) (save-excursion (while= (re-search-forward clock-re end t) (let ((element ...)) (if (eq ... ...) (= progn ...))))) (cond ((null positions) (org-end-of-meta-data) (if (bolp) ni= l (insert "\n")) (if (and org-clock-into-drawer (or ... ...)) (pr= ogn (let ... ... ... ... ... ...)))) ((or drawer (and (wholenump org-clock-= into-drawer) (>=3D ... org-clock-into-drawer))) (org-end-of-meta-data) (= let ((beg ...)) (insert (mapconcat ... positions "\n") "\n:E= ND:\n") (let (...) (goto-char beg) (save-excursion ...) (org-flag-draw= er t) (org-indent-region ... end) (forward-line) (if org-log-states-order-r= eversed nil ... ...) (set-marker end nil)))) (org-log-states-order-reversed= (goto-char (car (last positions)))) (t (goto-char (car positions))))))) org-clock-find-position(nil)
(save-restriction (widen) (goto-char t= arget-pos) (org-back-to-heading t) (or interrupting (move-marker org-clock-= interrupted-task nil)) (run-hooks (quote org-clock-in-prepare-hook)) (org-c= lock-history-push) (setq org-clock-current-task (nth 4 (org-heading-compone= nts))) (cond ((functionp org-clock-in-switch-to-state) (looking-at org-comp= lex-heading-regexp) (let ((newstate (funcall org-clock-in-switch-to-state (= match-string 2)))) (if newstate (org-todo newstate)))) ((and org-clock-in-s= witch-to-state (not (looking-at (concat org-outline-regexp "[ ]*"= org-clock-in-switch-to-state "\\>")))) (org-todo org-clock-in= -switch-to-state))) (setq org-clock-heading (cond ((and org-clock-heading-f= unction (functionp org-clock-heading-function)) (funcall org-clock-heading-= function)) ((nth 4 (org-heading-components)) (replace-regexp-in-string &quo= t;\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" (match-string-no-pro= perties 4))) (t "???"))) (org-clock-find-position org-clock-in-re= sume) (cond ((and org-clock-in-resume (looking-at (concat "^[ ]*"= org-clock-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"= " *\\sw+.? +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (mes= sage "Matched %s" (match-string 1)) (setq ts (concat "["= ; (match-string 1) "]")) (goto-char (match-end 1)) (setq org-cloc= k-start-time (apply (quote encode-time) (org-parse-time-string (match-strin= g 1)))) (setq org-clock-effort (org-entry-get (point) org-effort-property))= (setq org-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-= start)))) ((eq org-clock-in-resume (quote auto-restart)) (message "Can= not restart clock because task does not contain unfinished clock") (di= ng) (sit-for 2) (throw (quote abort) nil)) (t (insert-before-markers "= \n") (backward-char 1) (org-indent-line) (if (and (save-excursion (end= -of-line 0) (org-in-item-p))) (progn (beginning-of-line 1) (org-indent-line= -to (- (org-get-indentation) 2)))) (insert org-clock-string " ") = (setq org-clock-effort (org-entry-get (point) org-effort-property)) (setq o= rg-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-start)))= (setq org-clock-start-time (or (and org-clock-continuously org-clock-out-t= ime) (and leftover (y-or-n-p (format "You stopped another clock %d min= s ago; start this one from then? " ...)) leftover) start-time (org-cur= rent-time org-clock-rounding-minutes t))) (setq ts (org-insert-time-stamp o= rg-clock-start-time (quote with-hm) (quote inactive))))) (move-marker org-c= lock-marker (point) (buffer-base-buffer)) (move-marker org-clock-hd-marker = (save-excursion (org-back-to-heading t) (point)) (buffer-base-buffer)) (set= q org-clock-has-been-used t) (if (or (eq org-clock-clocked-in-display (quot= e mode-line)) (eq org-clock-clocked-in-display (quote both))) (progn (or gl= obal-mode-string (setq global-mode-string (quote ("")))) (or (mem= q (quote org-mode-line-string) global-mode-string) (setq global-mode-string= (append global-mode-string (quote (org-mode-line-string))))))) (if (or (eq= org-clock-clocked-in-display (quote frame-title)) (eq org-clock-clocked-in= -display (quote both))) (progn (setq frame-title-format org-clock-frame-tit= le-format))) (org-clock-update-mode-line) (if org-clock-mode-line-timer (pr= ogn (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-time= r nil))) (if org-clock-clocked-in-display (progn (setq org-clock-mode-line-= timer (run-with-timer org-clock-update-period org-clock-update-period (quot= e org-clock-update-mode-line))))) (if org-clock-idle-timer (progn (cancel-t= imer org-clock-idle-timer) (setq org-clock-idle-timer nil))) (setq org-cloc= k-idle-timer (run-with-timer 60 60 (quote org-resolve-clocks-if-idle))) (me= ssage "Clock starts at %s - %s" ts org--msg-extra) (run-hooks (qu= ote org-clock-in-hook)))
(save-excursion (save-restriction (widen) (go= to-char target-pos) (org-back-to-heading t) (or interrupting (move-marker o= rg-clock-interrupted-task nil)) (run-hooks (quote org-clock-in-prepare-hook= )) (org-clock-history-push) (setq org-clock-current-task (nth 4 (org-headin= g-components))) (cond ((functionp org-clock-in-switch-to-state) (looking-at= org-complex-heading-regexp) (let ((newstate (funcall org-clock-in-switch-t= o-state ...))) (if newstate (org-todo newstate)))) ((and org-clock-in-switc= h-to-state (not (looking-at (concat org-outline-regexp "[ ]*" org= -clock-in-switch-to-state "\\>")))) (org-todo org-clock-in-swi= tch-to-state))) (setq org-clock-heading (cond ((and org-clock-heading-funct= ion (functionp org-clock-heading-function)) (funcall org-clock-heading-func= tion)) ((nth 4 (org-heading-components)) (replace-regexp-in-string "\\= [\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" (match-string-no-propert= ies 4))) (t "???"))) (org-clock-find-position org-clock-in-resume= ) (cond ((and org-clock-in-resume (looking-at (concat "^[ ]*" org= -clock-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" &qu= ot; *\\sw+.? +[012][0-9]:[0-5][0-9]\\)\\][ ]*quot;))) (message= "Matched %s" (match-string 1)) (setq ts (concat "[" (m= atch-string 1) "]")) (goto-char (match-end 1)) (setq org-clock-st= art-time (apply (quote encode-time) (org-parse-time-string (match-string 1)= ))) (setq org-clock-effort (org-entry-get (point) org-effort-property)) (se= tq org-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-star= t)))) ((eq org-clock-in-resume (quote auto-restart)) (message "Cannot = restart clock because task does not contain unfinished clock") (ding) = (sit-for 2) (throw (quote abort) nil)) (t (insert-before-markers "\n&q= uot;) (backward-char 1) (org-indent-line) (if (and (save-excursion (end-of-= line 0) (org-in-item-p))) (progn (beginning-of-line 1) (org-indent-line-to = (- ... 2)))) (insert org-clock-string " ") (setq org-clock-effort= (org-entry-get (point) org-effort-property)) (setq org-clock-total-time (o= rg-clock-sum-current-item (org-clock-get-sum-start))) (setq org-clock-start= -time (or (and org-clock-continuously org-clock-out-time) (and leftover (y-= or-n-p ...) leftover) start-time (org-current-time org-clock-rounding-minut= es t))) (setq ts (org-insert-time-stamp org-clock-start-time (quote with-hm= ) (quote inactive))))) (move-marker org-clock-marker (point) (buffer-base-b= uffer)) (move-marker org-clock-hd-marker (save-excursion (org-back-to-headi= ng t) (point)) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (= or (eq org-clock-clocked-in-display (quote mode-line)) (eq org-clock-clocke= d-in-display (quote both))) (progn (or global-mode-string (setq global-mode= -string (quote ("")))) (or (memq (quote org-mode-line-string) glo= bal-mode-string) (setq global-mode-string (append global-mode-string (quote= ...)))))) (if (or (eq org-clock-clocked-in-display (quote frame-title)) (e= q org-clock-clocked-in-display (quote both))) (progn (setq frame-title-form= at org-clock-frame-title-format))) (org-clock-update-mode-line) (if org-clo= ck-mode-line-timer (progn (cancel-timer org-clock-mode-line-timer) (setq or= g-clock-mode-line-timer nil))) (if org-clock-clocked-in-display (progn (set= q org-clock-mode-line-timer (run-with-timer org-clock-update-period org-clo= ck-update-period (quote org-clock-update-mode-line))))) (if org-clock-idle-= timer (progn (cancel-timer org-clock-idle-timer) (setq org-clock-idle-timer= nil))) (setq org-clock-idle-timer (run-with-timer 60 60 (quote org-resolve= -clocks-if-idle))) (message "Clock starts at %s - %s" ts org--msg= -extra) (run-hooks (quote org-clock-in-hook))))
(save-excursion (if (a= nd selected-task (marker-buffer selected-task)) (progn (set-buffer (org-bas= e-buffer (marker-buffer selected-task))) (setq target-pos (marker-position = selected-task)) (move-marker selected-task nil))) (save-excursion (save-res= triction (widen) (goto-char target-pos) (org-back-to-heading t) (or interru= pting (move-marker org-clock-interrupted-task nil)) (run-hooks (quote org-c= lock-in-prepare-hook)) (org-clock-history-push) (setq org-clock-current-tas= k (nth 4 (org-heading-components))) (cond ((functionp org-clock-in-switch-t= o-state) (looking-at org-complex-heading-regexp) (let ((newstate ...)) (if = newstate (org-todo newstate)))) ((and org-clock-in-switch-to-state (not (lo= oking-at ...))) (org-todo org-clock-in-switch-to-state))) (setq org-clock-h= eading (cond ((and org-clock-heading-function (functionp org-clock-heading-= function)) (funcall org-clock-heading-function)) ((nth 4 (org-heading-compo= nents)) (replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]"= ; "\\1" (match-string-no-properties 4))) (t "???"))) (o= rg-clock-find-position org-clock-in-resume) (cond ((and org-clock-in-resume= (looking-at (concat "^[ ]*" org-clock-string " \\[\\([0-9]\= \{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+.? +[012][0-9]:[0-5][0-= 9]\\)\\][ ]*quot;))) (message "Matched %s" (match-st= ring 1)) (setq ts (concat "[" (match-string 1) "]")) (g= oto-char (match-end 1)) (setq org-clock-start-time (apply (quote encode-tim= e) (org-parse-time-string ...))) (setq org-clock-effort (org-entry-get (poi= nt) org-effort-property)) (setq org-clock-total-time (org-clock-sum-current= -item (org-clock-get-sum-start)))) ((eq org-clock-in-resume (quote auto-res= tart)) (message "Cannot restart clock because task does not contain un= finished clock") (ding) (sit-for 2) (throw (quote abort) nil)) (t (ins= ert-before-markers "\n") (backward-char 1) (org-indent-line) (if = (and (save-excursion ... ...)) (progn (beginning-of-line 1) (org-indent-lin= e-to ...))) (insert org-clock-string " ") (setq org-clock-effort = (org-entry-get (point) org-effort-property)) (setq org-clock-total-time (or= g-clock-sum-current-item (org-clock-get-sum-start))) (setq org-clock-start-= time (or (and org-clock-continuously org-clock-out-time) (and leftover ... = leftover) start-time (org-current-time org-clock-rounding-minutes t))) (set= q ts (org-insert-time-stamp org-clock-start-time (quote with-hm) (quote ina= ctive))))) (move-marker org-clock-marker (point) (buffer-base-buffer)) (mov= e-marker org-clock-hd-marker (save-excursion (org-back-to-heading t) (point= )) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq org-c= lock-clocked-in-display (quote mode-line)) (eq org-clock-clocked-in-display= (quote both))) (progn (or global-mode-string (setq global-mode-string (quo= te ...))) (or (memq (quote org-mode-line-string) global-mode-string) (setq = global-mode-string (append global-mode-string ...))))) (if (or (eq org-cloc= k-clocked-in-display (quote frame-title)) (eq org-clock-clocked-in-display = (quote both))) (progn (setq frame-title-format org-clock-frame-title-format= ))) (org-clock-update-mode-line) (if org-clock-mode-line-timer (progn (canc= el-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer nil))) = (if org-clock-clocked-in-display (progn (setq org-clock-mode-line-timer (ru= n-with-timer org-clock-update-period org-clock-update-period (quote org-clo= ck-update-mode-line))))) (if org-clock-idle-timer (progn (cancel-timer org-= clock-idle-timer) (setq org-clock-idle-timer nil))) (setq org-clock-idle-ti= mer (run-with-timer 60 60 (quote org-resolve-clocks-if-idle))) (message &qu= ot;Clock starts at %s - %s" ts org--msg-extra) (run-hooks (quote org-c= lock-in-hook)))))
(let ((interrupting (and (not org-clock-resolving-cl= ocks-due-to-idleness) (org-clocking-p))) ts selected-task target-pos (org--= msg-extra "") (leftover (and (not org-clock-resolving-clocks) org= -clock-leftover-time))) (if (and org-clock-auto-clock-resolution (or (not i= nterrupting) (eq t org-clock-auto-clock-resolution)) (not org-clock-clockin= g-in) (not org-clock-resolving-clocks)) (progn (setq org-clock-leftover-tim= e nil) (let ((org-clock-clocking-in t)) (org-resolve-clocks)))) (if (equal = select (quote (64))) (progn (let ((org-clock-continuously t)) (org-clock-in= nil org-clock-out-time)))) (if (equal select (quote (4))) (progn (setq sel= ected-task (org-clock-select-task "Clock-in on task: ")) (if sele= cted-task (setq selected-task (copy-marker selected-task)) (error "Abo= rt")))) (if (equal select (quote (16))) (progn (org-clock-mark-default= -task))) (if interrupting (progn (if (save-excursion (if selected-task nil = (org-back-to-heading t)) (and (equal (marker-buffer org-clock-hd-marker) (i= f selected-task ... ...)) (=3D (marker-position org-clock-hd-marker) (if se= lected-task ... ...)) (equal org-clock-current-task (nth 4 ...)))) (progn (= message "Clock continues in \"%s\"" org-clock-heading) = (throw (quote abort) nil))) (move-marker org-clock-interrupted-task (marker= -position org-clock-marker) (marker-buffer org-clock-marker)) (let ((org-cl= ock-clocking-in t)) (org-clock-out nil t)))) (setq target-pos (if (and (eob= p) (not (org-at-heading-p))) (point-at-bol 0) (point))) (save-excursion (if= (and selected-task (marker-buffer selected-task)) (progn (set-buffer (org-= base-buffer (marker-buffer selected-task))) (setq target-pos (marker-positi= on selected-task)) (move-marker selected-task nil))) (save-excursion (save-= restriction (widen) (goto-char target-pos) (org-back-to-heading t) (or inte= rrupting (move-marker org-clock-interrupted-task nil)) (run-hooks (quote or= g-clock-in-prepare-hook)) (org-clock-history-push) (setq org-clock-current-= task (nth 4 (org-heading-components))) (cond ((functionp org-clock-in-switc= h-to-state) (looking-at org-complex-heading-regexp) (let (...) (if newstate= ...))) ((and org-clock-in-switch-to-state (not ...)) (org-todo org-clock-i= n-switch-to-state))) (setq org-clock-heading (cond ((and org-clock-heading-= function ...) (funcall org-clock-heading-function)) ((nth 4 ...) (replace-r= egexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" = ...)) (t "???"))) (org-clock-find-position org-clock-in-resume) (= cond ((and org-clock-in-resume (looking-at ...)) (message "Matched %s&= quot; (match-string 1)) (setq ts (concat "[" ... "]")) = (goto-char (match-end 1)) (setq org-clock-start-time (apply ... ...)) (setq= org-clock-effort (org-entry-get ... org-effort-property)) (setq org-clock-= total-time (org-clock-sum-current-item ...))) ((eq org-clock-in-resume (quo= te auto-restart)) (message "Cannot restart clock because task does not= contain unfinished clock") (ding) (sit-for 2) (throw (quote abort) ni= l)) (t (insert-before-markers "\n") (backward-char 1) (org-indent= -line) (if (and ...) (progn ... ...)) (insert org-clock-string " "= ;) (setq org-clock-effort (org-entry-get ... org-effort-property)) (setq or= g-clock-total-time (org-clock-sum-current-item ...)) (setq org-clock-start-= time (or ... ... start-time ...)) (setq ts (org-insert-time-stamp org-clock= -start-time ... ...)))) (move-marker org-clock-marker (point) (buffer-base-= buffer)) (move-marker org-clock-hd-marker (save-excursion (org-back-to-head= ing t) (point)) (buffer-base-buffer)) (setq org-clock-has-been-used t) (if = (or (eq org-clock-clocked-in-display (quote mode-line)) (eq org-clock-clock= ed-in-display (quote both))) (progn (or global-mode-string (setq global-mod= e-string ...)) (or (memq ... global-mode-string) (setq global-mode-string .= ..)))) (if (or (eq org-clock-clocked-in-display (quote frame-title)) (eq or= g-clock-clocked-in-display (quote both))) (progn (setq frame-title-format o= rg-clock-frame-title-format))) (org-clock-update-mode-line) (if org-clock-m= ode-line-timer (progn (cancel-timer org-clock-mode-line-timer) (setq org-cl= ock-mode-line-timer nil))) (if org-clock-clocked-in-display (progn (setq or= g-clock-mode-line-timer (run-with-timer org-clock-update-period org-clock-u= pdate-period ...)))) (if org-clock-idle-timer (progn (cancel-timer org-cloc= k-idle-timer) (setq org-clock-idle-timer nil))) (setq org-clock-idle-timer = (run-with-timer 60 60 (quote org-resolve-clocks-if-idle))) (message "C= lock starts at %s - %s" ts org--msg-extra) (run-hooks (quote org-clock= -in-hook))))))
(catch (quote abort) (let ((interrupting (and (not org-= clock-resolving-clocks-due-to-idleness) (org-clocking-p))) ts selected-task= target-pos (org--msg-extra "") (leftover (and (not org-clock-res= olving-clocks) org-clock-leftover-time))) (if (and org-clock-auto-clock-res= olution (or (not interrupting) (eq t org-clock-auto-clock-resolution)) (not= org-clock-clocking-in) (not org-clock-resolving-clocks)) (progn (setq org-= clock-leftover-time nil) (let ((org-clock-clocking-in t)) (org-resolve-cloc= ks)))) (if (equal select (quote (64))) (progn (let ((org-clock-continuously= t)) (org-clock-in nil org-clock-out-time)))) (if (equal select (quote (4))= ) (progn (setq selected-task (org-clock-select-task "Clock-in on task:= ")) (if selected-task (setq selected-task (copy-marker selected-task)= ) (error "Abort")))) (if (equal select (quote (16))) (progn (org-= clock-mark-default-task))) (if interrupting (progn (if (save-excursion (if = selected-task nil (org-back-to-heading t)) (and (equal ... ...) (=3D ... ..= .) (equal org-clock-current-task ...))) (progn (message "Clock continu= es in \"%s\"" org-clock-heading) (throw (quote abort) nil)))= (move-marker org-clock-interrupted-task (marker-position org-clock-marker)= (marker-buffer org-clock-marker)) (let ((org-clock-clocking-in t)) (org-cl= ock-out nil t)))) (setq target-pos (if (and (eobp) (not (org-at-heading-p))= ) (point-at-bol 0) (point))) (save-excursion (if (and selected-task (marker= -buffer selected-task)) (progn (set-buffer (org-base-buffer (marker-buffer = selected-task))) (setq target-pos (marker-position selected-task)) (move-ma= rker selected-task nil))) (save-excursion (save-restriction (widen) (goto-c= har target-pos) (org-back-to-heading t) (or interrupting (move-marker org-c= lock-interrupted-task nil)) (run-hooks (quote org-clock-in-prepare-hook)) (= org-clock-history-push) (setq org-clock-current-task (nth 4 (org-heading-co= mponents))) (cond ((functionp org-clock-in-switch-to-state) (looking-at org= -complex-heading-regexp) (let ... ...)) ((and org-clock-in-switch-to-state = ...) (org-todo org-clock-in-switch-to-state))) (setq org-clock-heading (con= d (... ...) (... ...) (t "???"))) (org-clock-find-position org-cl= ock-in-resume) (cond ((and org-clock-in-resume ...) (message "Matched = %s" ...) (setq ts ...) (goto-char ...) (setq org-clock-start-time ...)= (setq org-clock-effort ...) (setq org-clock-total-time ...)) ((eq org-cloc= k-in-resume ...) (message "Cannot restart clock because task does not = contain unfinished clock") (ding) (sit-for 2) (throw ... nil)) (t (ins= ert-before-markers "\n") (backward-char 1) (org-indent-line) (if = ... ...) (insert org-clock-string " ") (setq org-clock-effort ...= ) (setq org-clock-total-time ...) (setq org-clock-start-time ...) (setq ts = ...))) (move-marker org-clock-marker (point) (buffer-base-buffer)) (move-ma= rker org-clock-hd-marker (save-excursion (org-back-to-heading t) (point)) (= buffer-base-buffer)) (setq org-clock-has-been-used t) (if (or (eq org-clock= -clocked-in-display ...) (eq org-clock-clocked-in-display ...)) (progn (or = global-mode-string ...) (or ... ...))) (if (or (eq org-clock-clocked-in-dis= play ...) (eq org-clock-clocked-in-display ...)) (progn (setq frame-title-f= ormat org-clock-frame-title-format))) (org-clock-update-mode-line) (if org-= clock-mode-line-timer (progn (cancel-timer org-clock-mode-line-timer) (setq= org-clock-mode-line-timer nil))) (if org-clock-clocked-in-display (progn (= setq org-clock-mode-line-timer ...))) (if org-clock-idle-timer (progn (canc= el-timer org-clock-idle-timer) (setq org-clock-idle-timer nil))) (setq org-= clock-idle-timer (run-with-timer 60 60 (quote org-resolve-clocks-if-idle)))= (message "Clock starts at %s - %s" ts org--msg-extra) (run-hooks= (quote org-clock-in-hook)))))))

org-clock-in(n= il)
call-interactively(org-clock-in nil nil)
command-execute(org-= clock-in)



On Thu, May 5, 2016 at 9:52 AM Nicolas Goaziou <mail@nicolasgoazi= ou.fr> wrote:
Hello,

Carlos Noguera <carlos.francisco.noguera@gmail.com> writes:

> When clocking in under a headline that already has clock entries, the<= br> > entries are not correclty bundled in a drawer, generating a: (I remove= d
> the bytecode because gmail didn't like it)
>
> Debugger entered--Lisp error: (wrong-type-argument char-or-string-p ni= l)
>=C2=A0 =C2=A0byte-code("REMOVED" [beg end org-clock-into-draw= er drawer find-unclosed
> org-clock-string line-beginning-position outline-next-heading
> org-clock-drawer-name "^[ ]*" "
> \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" " *\\sw+
> +[012][0-9]:[0-5][0-9]\\)\\][ ]*$" re-search-forward t org-elemen= t-at-point
> org-element-type clock org-element-property :status running
> beginning-of-line throw exit "^[ ]*:" regexp-quote ":[ = ]*$" :contents-end
> nil 0 org-end-of-meta-data "\n" wholenump 2 ":" &q= uot;:\n:END:\n"
> org-indent-region org-flag-drawer mapconcat #[(p) "\212
> b\210\302\212\303\304x\210\305\306!)\305\306!\"
> \307\310\311\307\312\311 ##*\207"
> [p s delete-and-extract-region "
> \n" nil line-beginning-position 2 replace-regexp-in-string "= \\`[ \n
> ]+" "" "[ \n
> ]+\\'"] 7] "\n:END:\n" point-marker ":\n"= -1 last open-clock-re element
> drawer-re cend org-log-states-order-reversed first ...] 4)
>=C2=A0 =C2=A0org-clock-find-position(nil)
>=C2=A0 =C2=A0byte-code("REMOVED" [org-clock-resolving-clocks-= due-to-idleness
> org-clock-resolving-clocks org-clock-leftover-time leftover org--msg-e= xtra
> target-pos org-clocking-p nil "" t org-resolve-clocks (64) o= rg-clock-in (4)
> org-clock-select-task "Clock-in on task: " copy-marker error= "Abort" (16)
> org-clock-mark-default-task org-back-to-heading marker-buffer
> marker-position 4 org-heading-components message "Clock continues= in
> \"%s\"" throw abort org-clock-out org-at-heading-p poin= t-at-bol 0
> org-base-buffer run-hooks org-clock-in-prepare-hook org-clock-history-= push
> functionp looking-at match-string 2 org-todo "[ ]*" "\\= >"
> replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" &q= uot;\\1"
> match-string-no-properties "???" ...] 8)
>=C2=A0 =C2=A0org-clock-in(nil)
>=C2=A0 =C2=A0call-interactively(org-clock-in nil nil)
>=C2=A0 =C2=A0command-execute(org-clock-in)
>
> that prevents the clock in
> I go from
>
> ** TODO a task
> CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] =3D>=C2=A0 1:= 29
> CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] =3D>=C2=A0 0:= 00
>
> C-c C-x C-i
>
> to
>
> ** TODO a task
> :CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] =3D>=C2=A0 0= :00
> CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] =3D>=C2=A0 1:= 29
> :END:

I cannot reproduce it. In the example above, I get

=C2=A0 * NEXT a task
=C2=A0 :LOGBOOK:
=C2=A0 CLOCK: [2016-05-05 Thu 09:52]
=C2=A0 CLOCK: [2016-05-04 Wed 12:44]--[2016-05-04 Wed 12:44] =3D>=C2=A0 = 0:00
=C2=A0 CLOCK: [2016-04-29 Fri 13:14]--[2016-04-29 Fri 14:43] =3D>=C2=A0 = 1:29
=C2=A0 :END:

> Any ideas?

Not quite. Could you provide a backtrace with an uncompiled Org
(org-reload with universal argument) ?

Regards,

--
Nicolas Goaziou
--001a11402e126deaa405327c43ea--