Nafiz Islam <nafiz.islam1...@gmail.com> writes:

>> I've also updated the docstring for `org-capture-templates', filtered out
>> incorrect target, and updated `org-capture-expand-olp' to take file
>> argument.

I do not think that it does what you expect.
AFAIU, the idea was to pass the FILE and extra OLP arguments to the
custom function provided by the user. But it is not what your code does.

> +(defun org-capture-expand-function-or-symbol (input)
> +  "Expand functions and symbols. When INPUT is a
> +function, call it. When it is a variable, return
> +its value. In any other case, return `nil'."
> +  (let* ((output (cond ((functionp input) (funcall input))
> +                    ((and (symbolp input) (boundp input)) (symbol-value 
> input))
> +                       (t nil))))
> +    output))
> ...
> +(defun org-capture-expand-olp (file &rest olp)
> +  "Expand functions, symbols and outline paths for OLP.
> +When OLP is a function, call it. When it is a variable,
> +return its value. When it is a list of string, return it.
> +In any other case, return `nil'. The current buffer is
> +set to the FILE before executing OLP as a function."
> +  (with-current-buffer (find-file-noselect file)
> +    (let* ((final-olp (cond ((stringp (car olp)) olp)
> +                            ((not (cdr olp)) 
> (org-capture-expand-function-or-symbol (car olp)))
> +                            (t (error "Invalid outline path: %S" olp)))))
> +      final-olp)))

You are still calling `org-capture-expand-function-or-symbol' without
passing the rest of OLP there. Or was it the intention?

Also, is there any point calling `find-file-noselect' when the outline
path spec is _not_ a function?

Finally, you need to describe the calling convention and environment
when the function spec for OLP is called - that it is called with no (or
some?) arguments and that the current buffer is the FILE-visiting buffer.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to