1

The following function is meant to call an arbitrary function at each of the immediate children of an org heading:

(defun org-map-shallow-tree (funcarg)
  ""
  (save-excursion
    (org-back-to-heading)    
    (let* ((cur-level (car (org-heading-components))))
      (org-map-tree (lambda () (when (equal (+ 1 cur-level) (car (org-heading-components)))
                                     (funcall 'funcarg)))))))

The problem is that when I call it, as in:

(defun lol () (message "lol"))
(org-map-shallow-tree 'lol)

I get the following error:

Debugger entered--Lisp error: (void-function funcarg)
1

1 Answer 1

3

You have a stray quote in your code:

(defun org-map-shallow-tree (funcarg)
  ""
  (save-excursion
    (org-back-to-heading)    
    (let* ((cur-level (car (org-heading-components))))
      (org-map-tree (lambda () (when (equal (+ 1 cur-level) (car (org-heading-components)))
                                     (funcall funcarg))))))) ; <= Don't quote funcarg

You passed a function symbol via funcarg, and you want funcall to call that function, i.e., the content of funcarg, not the funcarg symbol itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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