Package: emacs;
Message #8 received at 66750 <at> debbugs.gnu.org (full text, mbox):
From: Andrea Corallo <acorallo <at> gnu.org> To: Alan Mackenzie <acm <at> muc.de> Cc: 66750 <at> debbugs.gnu.org Subject: Re: bug#66750: Unhelpful text in C-h v for variables with a lambda form as value Date: Wed, 25 Oct 2023 16:53:38 -0400
Alan Mackenzie <acm <at> muc.de> writes: > Hello, Emacs. > > Supposing a variable has as a value a lambda function. On doing C-h v > for this variable, there ensues a useless lack of information about the > lambda. All one gets told is that it is a lambda function, not where the > source code for it is, or anything useful like that. > > A typical example is C-h v search-default-mode, which prints something > like the following: > > Its value is > #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_109> > Original value was nil > Local in buffer *info*<3>; global value is nil > > .. When native compilation is not enabled, the printout is only slightly > better. > > Merely amongst the customisable options (i.e. not ordinary defvars and > defconsts) there are approximately 63 places where these options get set > to lambda functions. The following list lists the file and line number > where it's done, and the customisable option it gets done to: > > ../autorevert.el:471 before-save-hook > ../emacs-lisp/pp.el:320 temp-buffer-show-function > ../emulation/viper.el:950 eshell-mode-hook > ../erc/erc-pcomplete.el:99 pcomplete-default-completion-function > ../eshell/em-cmpl.el:191 eshell-command-completion-function > ../eshell/em-cmpl.el:202 eshell-default-completion-function > ../eshell/em-cmpl.el:280 eshell-mode-hook > ../eshell/em-prompt.el:50 eshell-prompt-function > ../eshell/em-smart.el:187 eshell-post-command-hook > ../gnus/gnus-art.el:3077 gnus-exit-gnus-hook > ../gnus/gnus-delay.el:150 message-send-hook > ../gnus/gnus-diary.el:213 gnus-summary-menu-hook > ../gnus/gnus-diary.el:370 nndiary-request-accept-article-functions > ../gnus/gnus-draft.el:274 message-post-method > ../gnus/gnus-msg.el:1145 message-reply-to-function > ../gnus/gnus-msg.el:387 message-header-setup-hook > ../gnus/gnus-msg.el:392 message-mode-hook > ../gnus/gnus-registry.el:1000 gnus-summary-menu-hook > ../gnus/gnus-sum.el:1321 gnus-alter-articles-to-read-function > ../gnus/gnus-util.el:1205 iswitchb-make-buflist-hook > ../gnus/message.el:3157 facemenu-add-face-function > ../gnus/message.el:701 message-cite-level-function > ../gnus/nnmairix.el:286 nnmairix-widget-select-window-function > ../help.el:1946 temp-buffer-max-height > ../help.el:1963 temp-buffer-max-width > ../isearch.el:4685 search-default-mode > ../locate.el:670 locate-make-command-line > ../mail/emacsbug.el:466 message-sent-hook > ../mail/emacsbug.el:540 message-send-hook > ../mail/feedmail.el:1400 feedmail-queue-runner-mode-setter > ../mail/feedmail.el:1436 feedmail-queue-runner-message-sender > ../mail/feedmail.el:1457 feedmail-queue-runner-cleaner-upper > ../net/mairix.el:176 mairix-widget-select-window-function > ../obsolete/gulp.el:103 mail-setup-hook > ../org/ob-core.el:1524 org-mode-hook > ../org/ob-latex.el:101 org-babel-latex-end-env > ../org/ob-latex.el:79 org-babel-latex-preamble > ../org/ob-latex.el:90 org-babel-latex-begin-env > ../org/ob-python.el:208 python-shell-first-prompt-hook > ../org/ol-bibtex.el:268 org-bibtex-headline-format-function > ../org/org-compat.el:1272 imenu-after-jump-hook > ../org/org-compat.el:1276 org-mode-hook > ../org/org-compat.el:1339 speedbar-visiting-tag-hook > ../org/org-crypt.el:317 org-mode-hook > ../org/org-ctags.el:196 org-mode-hook > ../org/org.el:15220 after-save-hook > ../org/org.el:18651 occur-mode-find-occurrence-hook > ../org/org-mouse.el:866 org-mode-hook > ../org/ox-ascii.el:378 org-ascii-format-drawer-function > ../org/ox-html.el:657 org-html-format-drawer-function > ../org/ox-latex.el:888 org-latex-format-drawer-function > ../org/ox-odt.el:635 org-odt-format-drawer-function > ../org/ox-texinfo.el:334 org-texinfo-format-drawer-function > ../pcomplete.el:305 pcomplete-command-completion-function > ../pcomplete.el:315 pcomplete-default-completion-function > ../play/gametree.el:118 gametree-make-heading-function > ../progmodes/cperl-mode.el:1848 add-log-current-defun-function > ../progmodes/octave.el:607 fill-nobreak-predicate > ../progmodes/ps-mode.el:108 ps-mode-print-function > ../vc/add-log.el:1129 fill-nobreak-predicate > ../vc/emerge.el:2086 temp-buffer-show-function > ../vc/smerge-mode.el:1358 ediff-quit-hook > ../window.el:6662 pop-up-frame-function > > .. Additionally there are about 29 instances in the doc strings where > users are urged to use lambda functions (rather than defuns) for this > purpose. They are at: > > ../calendar/calendar.el:395 calendar-move-hook > ../calendar/cal-tex.el:154 cal-tex-hook > ../comint.el:189 comint-mode-hook > ../dired-loaddefs.el:646 dired-mode-hook > ../dired-x.el:152 dired-mode-hook > ../erc/erc-log.el:218 erc-enable-logging > ../erc/erc-page.el:55 erc-page-function > ../files.el:466 auto-save-visited-predicate > ../font-lock.el:704 c-mode-hook > ../gnus/gnus-sum.el:1044 gnus-select-group-hook > ../gnus/nnmail.el:179 nnmail-expiry-wait-function > ../gnus/nnmail.el:286 nnmail-read-incoming-hook > ../gnus/nnmail.el:299 nnmail-read-incoming-hook > ../icomplete.el:154 icomplete-minibuffer-setup-hook > ../ido.el:890 ido-minibuffer-setup-hook > ../ielm.el:63 ielm-mode-hook > ../ldefs-boot.el:29820 sql-mode-hook > ../ldefs-boot.el:5069 c-mode-hook > ../loaddefs.el:29950 sql-mode-hook > ../loaddefs.el:5069 c-mode-hook > ../obsolete/nnir.el:415 nnir-notmuch-filter-group-names-function > ../org/org-keys.el:688 org-use-speed-commands > ../org/ox-html.el:968 org-html-table-row-open-tag > ../progmodes/compile.el:885 c-mode-hook > ../progmodes/prog-mode.el:296 emacs-lisp-mode-hook > ../progmodes/sql.el:4134 sql-mode-hook > ../progmodes/sql.el:4256 sql-interactive-mode-hook > ../textmodes/tildify.el:156 tildify-foreach-region-function > ../transient.el:278 transient-substitute-key-function > > .. Furthermore there are, perhaps, around 150 such settings of ordinary > defvars or defconsts to lambda functions. > > ######################################################################### > > I see two ways to fix this bug: > (i) Systematically to replace each of these lambda functions by a named > defun. > (ii) To adopt git branch feature/named-lambdas, which attaches to every > lambda function the name of the defun (or defvar) in which it was > defined. This extra information could then be printed out for C-h v, > something like this: > > Its value is > {isearch-fold-quotes-mode} #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_109> > Original value was nil > Local in buffer *info*<3>; global value is nil > > , thus enabling the user quickly to locate the source of the lambda form > in isearch.el. Hi Alan, what (if any) do you think are the downsides of option ii? Thanks Andrea
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.