GNU bug report logs - #60568
[FR] 30.0.50; Help buffers and function bodies for generated functions

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Thu, 5 Jan 2023 07:56:02 UTC

Severity: normal

Full log


Message #41 received at 60568 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: yantar92 <at> posteo.net, 60568 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
Subject: Re: bug#60568: [FR] 30.0.50; Help buffers and function bodies for
 generated functions
Date: Thu, 05 Jan 2023 17:10:20 +0200
> Date: Thu, 05 Jan 2023 14:27:41 +0000
> From: Gregory Heytings <gregory <at> heytings.org>
> cc: mardani29 <at> yahoo.es, yantar92 <at> posteo.net, 60568 <at> debbugs.gnu.org
> 
> 
> >> What is missing in the five-line patch that does this?  With the 
> >> recipe, the file in which org-babel-execute:sh was defined 
> >> (ob-shell.el) is opened, and the function definition is displayed.  I 
> >> don't think we can do much better (e.g. reliably find the place where 
> >> the function was defined).
> >
> > Why not?  A function definition usually has some specific keywords in 
> > it.  It is true that someone could have obfuscated the code which 
> > generates a function to the degree that it would be infeasible to 
> > recognize, but we don't need to support such arbitrary measures, we only 
> > need to support what's really being used.  IOW, "reliably" doesn't need 
> > to mean with 110% reliability.
> 
> Hmmm, you mean try to find heuristically where e.g. in the ob-shell.el 
> file the org-babel-execute:sh function was defined?

Yes.

> The function body is this:
> 
> (lambda
>    (body params)
>    "Execute a block of sh commands with Babel."
>    (let
>        ((shell-file-name "sh")
>         (org-babel-prompt-command
>  	(or
>  	 (alist-get "sh" org-babel-shell-set-prompt-commands)
>  	 (alist-get t org-babel-shell-set-prompt-commands))))
>      (org-babel-execute:shell body params)))
> 
> and it has been created here:
> 
> (defun org-babel-shell-initialize ()
>    "Define execution functions associated to shell names.
> This function has to be called whenever `org-babel-shell-names'
> is modified outside the Customize interface."
>    (interactive)
>    (dolist (name org-babel-shell-names)
>      (eval `(defun ,(intern (concat "org-babel-execute:" name))
>  	       (body params)
>  	     ,(format "Execute a block of %s commands with Babel." name)
>  	     (let ((shell-file-name ,name)
>                     (org-babel-prompt-command
>                      (or (alist-get ,name org-babel-shell-set-prompt-commands)
>                          (alist-get t org-babel-shell-set-prompt-commands))))
>  	       (org-babel-execute:shell body params))))
>      (eval `(defalias ',(intern (concat "org-babel-variable-assignments:" name))
>  	     'org-babel-variable-assignments:shell
>  	     ,(format "Return list of %s statements assigning to the block's \
> variables."
>  		      name)))
>      (eval `(defvar ,(intern (concat "org-babel-default-header-args:" name)) '()))))
> 
> Do you think there is a way to find that place?

Well, searching for the regexp "defun .*org-babel-execute:" would have
done that, right?




This bug report was last modified 2 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.