From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: 60568@debbugs.gnu.org
Subject: bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated functions
Date: Fri, 06 Jan 2023 11:44:10 -0500 [thread overview]
Message-ID: <jwvsfgnmxev.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87fscpifdw.fsf@localhost> (Ihor Radchenko's message of "Thu, 05 Jan 2023 07:56:11 +0000")
> One of the discussed features was displaying function source code right
> in *Help* buffers. This feature usefulness have been objected at that
> time, on the grounds that showing function code may be too long and
> cause large *Help* buffers.
FWIW, I find myself regularly jumping to `M-x ielm` to look at the
`symbol-function`, so I would actually appreciate a button in the *Help*
buffer to display the actual value in the `symbol-function` slot.
This would also bring `describe-function` a bit closer to
`describe-variable`, which I think is good.
> 1. emacs -Q
> 2. M-: (require 'ob-shell)
> 3. <F1> f org-babel-execute:sh <RET>
> 4. Click on the source code link in *Help* buffer
> 5. Observe point jumping to (point-min) with no obvious way to find the
> function definition.
We have `definition-name` for that.
I.e. `org-babel-shell-initialize` should arguably do
(put 'org-babel-execute:sh 'definition-name 'org-babel-shell-initialize)
so that step 4 above jumps to `org-babel-shell-initialize`.
The patch below does that, along with saving some kittens.
Stefan
diff --git a/lisp/org/ob-shell.el b/lisp/org/ob-shell.el
index 4a60186cd5d..5f7373c3faa 100644
--- a/lisp/org/ob-shell.el
+++ b/lisp/org/ob-shell.el
@@ -74,20 +74,25 @@ org-babel-shell-initialize
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 \
+ (let ((fname (intern (concat "org-babel-execute:" name))))
+ (defalias fname
+ (lambda (body params)
+ (:documentation
+ (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))))
+ (put fname 'definition-name 'org-babel-shell-initialize))
+ (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)) '()))))
+ name))
+ (funcall (if (fboundp 'defvar-1) #'defvar-1 #'set) ;Emacs-29
+ (intern (concat "org-babel-default-header-args:" name))
+ '())))
(defcustom org-babel-shell-names
'("sh" "bash" "zsh" "fish" "csh" "ash" "dash" "ksh" "mksh" "posh")
next prev parent reply other threads:[~2023-01-06 16:44 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 7:56 bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated functions Ihor Radchenko
2023-01-05 8:09 ` Eli Zaretskii
2023-01-05 8:20 ` Ihor Radchenko
2023-01-05 8:32 ` Eli Zaretskii
2023-01-05 17:04 ` Jean Louis
2023-01-05 17:03 ` Jean Louis
2023-01-05 9:40 ` Gregory Heytings
2023-01-05 9:52 ` Gregory Heytings
2023-01-05 10:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-05 10:52 ` Ihor Radchenko
2023-01-05 11:20 ` Eli Zaretskii
2023-01-05 12:33 ` Gregory Heytings
2023-01-05 14:16 ` Eli Zaretskii
2023-01-05 14:27 ` Gregory Heytings
2023-01-05 15:10 ` Eli Zaretskii
2023-01-05 15:13 ` Gregory Heytings
2023-01-05 16:49 ` Eli Zaretskii
2023-01-05 20:44 ` Gregory Heytings
2023-01-06 6:35 ` Eli Zaretskii
2023-01-06 9:11 ` Gregory Heytings
2023-01-06 17:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-06 22:52 ` Gregory Heytings
2023-01-07 0:36 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-07 6:55 ` Eli Zaretskii
2023-01-07 9:42 ` Gregory Heytings
2023-01-07 13:38 ` Ihor Radchenko
2023-01-07 14:00 ` Eli Zaretskii
2023-01-07 14:04 ` Gregory Heytings
2023-01-07 15:07 ` Ihor Radchenko
2023-01-07 15:14 ` Eli Zaretskii
2023-01-07 15:19 ` Ihor Radchenko
2023-01-07 15:23 ` Eli Zaretskii
2023-01-07 17:59 ` Eli Zaretskii
2023-01-07 13:14 ` Ihor Radchenko
2023-01-07 13:55 ` Eli Zaretskii
2023-01-05 17:00 ` Jean Louis
2023-01-06 8:39 ` Ihor Radchenko
2023-01-06 16:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-01-07 11:32 ` Ihor Radchenko
2023-01-07 15:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-12 10:40 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvsfgnmxev.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=60568@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.