From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated functions Date: Fri, 06 Jan 2023 11:44:10 -0500 Message-ID: References: <87fscpifdw.fsf@localhost> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18941"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 60568@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 06 17:45:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDpqE-0004fL-Mz for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Jan 2023 17:45:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDpq4-0000Rn-7M; Fri, 06 Jan 2023 11:45:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDpq3-0000Ra-5W for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 11:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDpq2-0002jv-SU for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 11:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pDpq2-0002GI-BO for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 11:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Jan 2023 16:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60568 X-GNU-PR-Package: emacs Original-Received: via spool by 60568-submit@debbugs.gnu.org id=B60568.16730234618627 (code B ref 60568); Fri, 06 Jan 2023 16:45:02 +0000 Original-Received: (at 60568) by debbugs.gnu.org; 6 Jan 2023 16:44:21 +0000 Original-Received: from localhost ([127.0.0.1]:55702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDppM-0002F5-SD for submit@debbugs.gnu.org; Fri, 06 Jan 2023 11:44:21 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54059) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDppK-0002Eq-TA for 60568@debbugs.gnu.org; Fri, 06 Jan 2023 11:44:19 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 07B1F8001A; Fri, 6 Jan 2023 11:44:13 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 325E380172; Fri, 6 Jan 2023 11:44:11 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1673023451; bh=FB+qJneo6YtOVd3qfhUZwgMrPcq6cQbbHYwx9VxRhq0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UACM/+klAiMCSakiyMMHGeGhCLtCThQ6D7Df/mhDZ7SCchNOT5eaw+CzyM8dslRcD qLFu6Yl+/5FafneR5iABK7kmrQ8JuulvUeNdSqZkMYqmj/iUqOBJPnFbwIKfrbJZhQ F9xxaKC7gN+1AY4CMw4fh7s+xtAsET9mlOxwLt7sBY0OoubRedAaA5FcSz1J9s1T9v +ox+AkN4XkyV4Jkay3xFELloZ7nbS3rgNmt94itoYkQaOetsK8LIzv/KUD/I7kFtAI AkIpxDKtVfoQwDQ7LJzFnAoqThPc+pdEKvuuLRePYUQk1SRmYgi1RnyF1dtIn5HTvG AYr5SjuOSjMEQ== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 11BE41209C7; Fri, 6 Jan 2023 11:44:11 -0500 (EST) In-Reply-To: <87fscpifdw.fsf@localhost> (Ihor Radchenko's message of "Thu, 05 Jan 2023 07:56:11 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252730 Archived-At: > 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. f org-babel-execute:sh > 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")