Subject: bug#55245: 28.1; project--read-project-buffer predicate fails with wrong-type-argument listp

From: Reindert-Jan Ekker <[email-masked]>
Date: Tue, 03 May 2022 14:01:05 +0200

I encountered this bug because I use helm. After the following:

(require 'helm)
(require 'helm-config)
(helm-mode 1)

the command project-switch-to-buffer always fails with "wrong type
argument listp". I posted this as a helm issue at first and got the
following answer (quoting from
https://github.com/emacs-helm/helm/issues/2506):

The bug is not helm related, it is a bug in project--read-project-buffer
(and possibly other functions which use the same predicate?), where its
predicate expect a cons cell like (bufname . buf_object) and when the
first call of the predicate used to determine default for read-buffer
returns a buffer-name, this one is called next by the predicate function
of read-buffer (which use the same predicate) with a buffer-name as
argument instead of a cons cell hence the error "wrong type argument
listp". Here a possible (quick) fix (not fully safe as it should check
if buffer is a string or a buffer or nil):

(defun project--read-project-buffer ()
      (let* ((pr (project-current t))
             (current-buffer (current-buffer))
             (other-buffer (other-buffer current-buffer))
             (other-name (buffer-name other-buffer))
             (buffers (project-buffers pr))
             (predicate
              (lambda (buffer)
                ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
                (if (consp buffer)
                    (memq (cdr buffer) buffers)
                  (memq (get-buffer buffer) buffers)))))
        (read-buffer
         "Switch to buffer: "
         (when (funcall predicate (cons other-name other-buffer))
           other-name)
         nil
         predicate)))

In GNU Emacs 28.1 (build 2, aarch64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5.2 (Build 20G95))
 of 2022-05-01 built on CodeSensei-MacBook-Air.local
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.5.2

Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
 --infodir=/opt/homebrew/Cellar/emacs-plus@28/28.1/share/info/emacs
 --prefix=/opt/homebrew/Cellar/emacs-plus@28/28.1 --with-xml2
 --with-gnutls --with-native-compilation --without-dbus
 --without-imagemagick --with-modules --with-rsvg --with-ns
 --disable-ns-self-contained 'CFLAGS=-I/opt/homebrew/opt/gcc/include
 -I/opt/homebrew/opt/libgccjit/include -I/opt/homebrew/opt/gmp/include
 -I/opt/homebrew/opt/jpeg/include' 'LDFLAGS=-L/opt/homebrew/lib/gcc/11
 -I/opt/homebrew/opt/gcc/include -I/opt/homebrew/opt/libgccjit/include
 -I/opt/homebrew/opt/gmp/include -I/opt/homebrew/opt/jpeg/include''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM
ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: elisp

Minor modes in effect:
  edebug-mode: t
  helm-mode: t
  helm-minibuffer-history-mode: t
  helm--remap-mouse-mode: t
  async-bytecomp-package-mode: t
  rainbow-delimiters-mode: t
  which-key-mode: t
  super-save-mode: t
  recentf-mode: t
  savehist-mode: t
  save-place-mode: t
  global-diff-hl-mode: t
  diff-hl-mode: t
  global-anzu-mode: t
  anzu-mode: t
  volatile-highlights-mode: t
  windmove-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  global-company-mode: t
  company-mode: t
  global-hl-line-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-strict-mode: t
  smartparens-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  override-global-mode: t
  magit-wip-initial-backup-mode: t
  magit-wip-before-change-mode: t
  magit-wip-after-apply-mode: t
  magit-wip-after-save-mode: t
  magit-wip-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  global-auto-revert-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/.emacs.d/rje/custom hides /opt/homebrew/Cellar/emacs-plus@28/28.1/share/emacs/28.1/lisp/custom
/Users/reindert/.emacs.d/elpa/transient-20220425.1314/transient hides /opt/homebrew/Cellar/emacs-plus@28/28.1/share/emacs/28.1/lisp/transient

Features:
(shadow pulse bug-reference helm-config helm-projectile vc-mtn vc-hg
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs cl-print debug ace-window avy
goto-addr view emacsbug eieio-opt speedbar ezimage dframe shortdoc
help-fns radix-tree tabify man helm-command helm-elisp helm-eval edebug
backtrace helm-mode helm-misc gnutls epa-file network-stream nsm
mailalias sort gnus-cite mail-extr qp vc-git winner tramp-archive
tramp-gvfs helm-x-files helm-for-files helm-bookmark helm-adaptive
helm-info bookmark pp helm-external helm-net helm-files image-dired
helm-tags helm-locate helm-buffers helm-occur helm-grep helm-regexp
helm-utils helm-help helm-types helm helm-core async-bytecomp
helm-global-bindings helm-easymenu helm-source helm-multi-match helm-lib
async rainbow-delimiters course course-ui course-server course-publish
course-backend course-topic-link course-meta course-log course-projects
course-deps publish-course yasnippet projectile lisp-mnt grep compile
ibuf-ext ibuffer ibuffer-loaddefs ox-reveal ox-odt rng-loc rng-uri
rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar ox-html table ox-ascii
ox-publish ox htmlize exec-path-from-shell midnight which-key flyspell
ispell sane-term dired-x rje-savefiles super-save recentf tree-widget
savehist saveplace rje-looks dimmer face-remap color diff-hl log-view
vc-dir ewoc vc vc-dispatcher anzu volatile-highlights whitespace
diminish rje-move move-text windmove rje-keys rje-windows
rje-programming flycheck hl-todo rje-company company-oddmuse
company-keywords company-etags etags fileloop xref project company-gtags
company-dabbrev-code company-dabbrev company-files company-clang
company-capf company-cmake company-semantic company-template
company-bbdb company pcase rje-pass password-store auth-source-pass
rje-agenda org-agenda rje-theme org-element avl-tree generator ol-w3m
org-inlinetask ol-info ol-eww eww xdg url-queue mm-url ol-doi
org-link-doi ol-docview org-ctags org-crypt deeper-blue-theme rje-mail
org-mu4e mu4e mu4e-org mu4e-main mu4e-view mu4e-view-gnus gnus-art mm-uu
mml2015 mm-view mml-smime smime dig gnus-sum gnus-group gnus-undo
gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7
netrc nnoo gnus-spec gnus-int gnus-range gnus-win gnus nnheader wid-edit
mu4e-view-common mu4e-headers mu4e-compose mu4e-context mu4e-draft
mu4e-actions ido rfc2368 smtpmail sendmail mu4e-mark mu4e-proc
mu4e-utils doc-view jka-compr image-mode exif mu4e-lists mu4e-message
shr kinsoku svg xml dom flow-fill hl-line mu4e-vars mu4e-meta f s
rje-edit zop-to-char sudo-edit smartparens-config smartparens-org
smartparens-text smartparens-python smartparens thingatpt
browse-kill-ring undo-tree queue rje-org org-tempo tempo org-id
org-refile org org-macro org-footnote org-pcomplete org-list org-faces
org-entities noutline outline org-version ob-emacs-lisp ob-plantuml
ob-ditaa ob-python python tramp-sh tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time ls-lisp ob-shell ob
ob-tangle org-src ob-ref ob-lob ob-table ob-exp ob-comint ob-core
ob-eval org-table oc-basic bibtex iso8601 ol org-keys oc org-compat
advice org-macs org-loaddefs find-func cal-menu calendar cal-loaddefs
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core rje-packages epl
finder-inf magit-wip magit-log which-func imenu magit-diff smerge-mode
diff diff-mode git-commit log-edit easy-mmode message rmc puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process with-editor shell pcomplete
comint ring server ansi-color magit-mode transient comp comp-cstr
warnings cl-extra edmacro kmacro help-mode magit-git magit-base
magit-section format-spec crm dash compat-27 compat-26 compat delsel
cus-load rx info package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
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 lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax 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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads kqueue
cocoa ns lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 1061008 99689)
  (symbols 48 62100 17)
  (strings 32 253698 9988)
  (string-bytes 1 8470187)
  (vectors 16 110269)
  (vector-slots 8 2374615 163638)
  (floats 8 672 364)
  (intervals 56 36959 1700)
  (buffers 992 47))

-- 
Reindert-Jan Ekker
Code Sensei