4

Running emacs 25.2.2.

To add a property, when I C-c C-x p while on a headline in an org file, it creates an error (prior to C-c C-x p, I had done M-x toggle-debug-on-error to produce a detailed stack trace):

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  org-buffer-property-keys(nil t t)
  org-read-property-name()
  org-set-property(nil nil)
  funcall-interactively(org-set-property nil nil)
  call-interactively(org-set-property nil nil)
  command-execute(org-set-property)

After I M-x load-library RET org.el RET it produces the following stack trace:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  goto-char(nil)
  (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading))
  (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading)))
  (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading))))
  (let (rtn range cfmt s p) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x ...)) (if (member x rtn) rtn (setq rtn ...)))) (outline-next-heading)))) (if include-specials (progn (setq rtn (append org-special-properties rtn)))) (if include-defaults (progn (mapc (function (lambda (x) (if (member x rtn) rtn (setq rtn ...)))) org-default-properties) (if (member org-effort-property rtn) rtn (setq rtn (cons org-effort-property rtn))))) (if include-columns (progn (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward "^\\(#\\+COLUMNS:\\|[     ]*:COLUMNS:\\)[     ]*\\(.*\\)" nil t) (setq cfmt (match-string 2) s 0) (while (string-match "%[0-9]*\\([-[:alnum:]_]+\\)" cfmt s) (setq s ... p ...) (if ... nil ...))))))) (sort rtn (function (lambda (a b) (string< (upcase a) (upcase b))))))
  org-buffer-property-keys(nil t t)
  (let* ((completion-ignore-case t) (keys (org-buffer-property-keys nil t t)) (default-prop (or (save-excursion (let ((save-match-data-internal ...)) (unwind-protect (progn ... ...) (set-match-data save-match-data-internal ...)))) org-last-set-property)) (property (org-icompleting-read (concat "Property" (if default-prop (concat " [" default-prop "]") "") ": ") (mapcar (quote list) keys) nil nil nil nil default-prop))) (if (member property keys) property (or (cdr (assoc (downcase property) (mapcar (function (lambda ... ...)) keys))) property)))
  org-read-property-name()
  (or property (org-read-property-name))
  (let* ((property (or property (org-read-property-name))) (value (or value (org-read-property-value property))) (fn (cdr (assoc property org-properties-postprocess-alist)))) (setq org-last-set-property property) (setq org-last-set-property-value (concat property ": " value)) (if fn (progn (setq value (funcall fn value)))) (if (equal (org-entry-get nil property) value) nil (org-entry-put nil property value)))
  org-set-property(nil nil)
  funcall-interactively(org-set-property nil nil)
  call-interactively(org-set-property nil nil)
  command-execute(org-set-property)

What is happening here? How do I set things right?

  • 1
    M-x toggle-debug-on-error and then trigger the error again, and copy and paste the stack trace into your question. – phils May 2 '18 at 7:16
  • @phils Thanks. I have added the stack trace in the question. – deshmukh May 2 '18 at 7:53
  • 1
    We might need to make that more detailed. Can you repeat that after using M-x load-library RET org.el RET (to load the uncompiled version of the library). – phils May 2 '18 at 9:16
  • 1
    If you're able to replicate this using emacs -Q that's also useful information. And if you can show a sample file which causes the problem, even better. – phils May 2 '18 at 9:17
  • @phils Thanks. Added the stack trace after M-x load-library RET org.el RET – deshmukh May 2 '18 at 10:26
3

It looks like this could happen if your org file contained a malformed properties block, such that there is a start:

:PROPERTIES:

But no end:

:END:

That seems like a bug, although it might well be fixed already in newer versions.

  • Thanks a ton. This, exactly, seems to be the problem. Every time I archive a heading with C-c $ in the Agenda View, it gets archived to the datetree (I have #+ARCHIVE: ::datetree/ at the top of the file) but the archived entry contains :PROPERTIES: drawer inside the :LOGBOOK: drawer. If I delete the datetree, I can set properties. How do I solve this problem with archiving? Do we continue the conversation here or do I ask a new question? – deshmukh May 3 '18 at 6:42
  • I can't replicate that in Emacs 25.3 (org 8.2.10), and I see that in the newest version of org in GNU ELPA (9.1.12) it detects the issue and offers to repair the syntax. Which versions are you using? – phils May 3 '18 at 7:45
  • Its emacs 25.2.2. M-x list-packages shows org 9.1.12 as an available package in gnu archive. No org package is shown as installed. – deshmukh May 3 '18 at 11:07
  • 1
    OK. I tried isolating the problem by bisecting the org file. It was a large file so it took some time. But at last, I could identify a headline that did not have :END: followed by a :PROPERTY:. I am sorry not to have done that earlier. But I do not remember editing the file by hand. So, I thought such an error was unlikely. – deshmukh May 3 '18 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.