Subject: 27.2; Reference Manual sec. 10.2.4; Incorrect example for indirect-function

From: Scott Marks <[email-masked]>
Date: Mon, 19 Jul 2021 14:38:34 -0400

If one copies the example:

Here is how you could define indirect-function in Lisp:

(defun indirect-function (function)

  (if (symbolp function)

      (indirect-function (symbol-function function))

    function))

this code will throw due to infinite recursion when invoked as

(indirect-function nil)

The fix is obvious: wrap (symbolp function) with (and function ...)

I don't think this would distract from the point of the example.

Hope this helps

Scott

In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
Version 10.14.6 (Build 18G95))

 of 2021-03-27 built on builder10-14.porkrind.org

Windowing system distributor 'Apple', version 10.3.2022

System Description:  macOS 11.4

Recent messages:

Quit

Mark set

Quit

<nil> <down-mouse-1> is undefined

<nil> <mouse-1> is undefined

kill-region: Text is read-only: #<buffer *ielm*> [2 times]

<nil> <down-mouse-1> is undefined

<nil> <mouse-1> is undefined

Quit [4 times]

Configured using:

 'configure --with-ns '--enable-locallisppath=/Library/Application

 Support/Emacs/${version}/site-lisp:/Library/Application

 Support/Emacs/site-lisp' --with-modules'

Configured features:

NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

THREADS JSON PDUMPER GMP

Important settings:

  value of $LANG: en_US.UTF-8

  locale-coding-system: utf-8-unix

Major mode: IELM

Minor modes in effect:

  override-global-mode: t

  global-git-commit-mode: t

  magit-auto-revert-mode: t

  shell-dirtrack-mode: t

  gcmh-mode: t

  straight-use-package-mode: t

  straight-package-neutering-mode: t

  desktop-save-mode: t

  tooltip-mode: t

  global-eldoc-mode: t

  eldoc-mode: t

  electric-indent-mode: t

  mouse-wheel-mode: t

  tool-bar-mode: t

  menu-bar-mode: t

  file-name-shadow-mode: t

  global-font-lock-mode: t

  font-lock-mode: t

  blink-cursor-mode: t

  auto-composition-mode: t

  auto-encryption-mode: t

  auto-compression-mode: t

  line-number-mode: t

  transient-mark-mode: t

Load-path shadows:

/Users/scott/.emacs.d/straight/build/let-alist/let-alist hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/let-alist

Features:

(shadow sort mail-extr emacsbug sendmail misearch multi-isearch cl-print

ielm pp etags fileloop generator xref project dired-aux sh-script smie

executable jka-compr vc-git my-haskell-elisp-autoloads

use-package-bind-key bind-key hindent-autoloads hlint-refactor-autoloads

flycheck-haskell-autoloads dante-autoloads lcr-autoloads

company-autoloads haskell-mode-autoloads attrap flycheck find-func s

attrap-autoloads flycheck-autoloads let-alist-autoloads

pkg-info-autoloads epl-autoloads f-autoloads s-autoloads magit-gitflow

magit-popup magit-gitflow-autoloads magit-popup-autoloads

magit-submodule magit-obsolete magit-blame magit-stash magit-reflog

magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote

magit-commit magit-sequence magit-notes magit-worktree magit-tag

magit-merge magit-branch magit-reset magit-files magit-refs magit-status

magit package browse-url url-handlers magit-repos magit-apply magit-wip

magit-log which-func imenu magit-diff smerge-mode diff diff-mode

git-commit rx log-edit message rfc822 mml mml-sec epa derived epg

epg-config gnus-util rmail rmail-loaddefs text-property-search mm-decode

mm-bodies mm-encode mailabbrev gmm-utils mailheader pcvs-util add-log

magit-core magit-autorevert autorevert filenotify magit-margin

magit-transient magit-process with-editor server magit-mode transient

magit-git magit-section magit-utils crm dash magit-autoloads

magit-section-autoloads git-commit-autoloads with-editor-autoloads

transient-autoloads pandoc-mode-autoloads dash-autoloads hydra-autoloads

lv-autoloads markdown-mode-autoloads dirtrack native-complete

native-complete-autoloads dired dired-loaddefs edmacro kmacro

exec-path-from-shell exec-path-from-shell-autoloads ffap tramp

tramp-loaddefs trampver tramp-integration files-x tramp-compat shell

pcomplete comint ansi-color ring parse-time iso8601 time-date ls-lisp

format-spec finder-inf gcmh gcmh-autoloads cl-extra use-package-core

use-package-autoloads bind-key-autoloads straight-autoloads straight

info autoload radix-tree easy-mmode pcase checkdoc lisp-mnt thingatpt

help-mode easymenu mail-utils gnutls network-stream url-http mail-parse

rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc

puny url-cache url-auth url url-proxy url-privacy url-expand url-methods

url-history url-cookie url-domsuf url-util url-parse auth-source cl-seq

eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map

seq byte-opt gv bytecomp byte-compile cconv url-vars mailcap

deeper-blue-theme desktop frameset cl-loaddefs cl-lib cus-start cus-load

tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type

mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win

tool-bar dnd fontset image regexp-opt fringe tabulated-list replace

newcomment text-mode elisp-mode lisp-mode prog-mode register page

tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse

jit-lock font-lock syntax facemenu font-core term/tty-colors frame

minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese

tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek

romanian slovak czech european ethiopic indian cyrillic chinese

composite charscript charprop case-table epa-hook jka-cmpr-hook help

simple abbrev obarray cl-preloaded nadvice loaddefs button faces

cus-face macroexp files text-properties overlay sha1 md5 base64 format

env code-pages mule custom widget hashtable-print-readable backquote

threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:

((conses 16 210890 189150)

 (symbols 48 21515 1)

 (strings 32 69271 38020)

 (string-bytes 1 2340771)

 (vectors 16 38156)

 (vector-slots 8 828157 241244)

 (floats 8 125 1238)

 (intervals 56 2074 118)

 (buffers 1000 30))