Skip to content

Use of :initial-input in org-ql-view--expand-buffers-files conflicting with completing-read #227

@ahmed-shariff

Description

@ahmed-shariff

The initial-input in the org-ql-view--expand-buffers-files is causing an issue with completing-read. When I try the C-u r command from org-ql-view :

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  completing-read-default("Buffers/Files: " (buffer org-agenda-files org-directory all) nil nil ("~/Documents/org/brain/research_papers.org") nil nil nil)
  completing-read("Buffers/Files: " (buffer org-agenda-files org-directory all) nil nil ("~/Documents/org/brain/research_papers.org"))
  (org-ql-view--expand-buffers-files (completing-read "Buffers/Files: " (list 'buffer 'org-agenda-files 'org-directory 'all) nil nil (funcall --cl-initial-input--)))
  (if (and org-ql-view-buffers-files (bufferp org-ql-view-buffers-files)) org-ql-view-buffers-files (org-ql-view--expand-buffers-files (completing-read "Buffers/Files: " (list 'buffer 'org-agenda-files 'org-directory 'all) nil nil (funcall --cl-initial-input--))))
  (let (--cl-initial-input--) (setq --cl-initial-input-- #'(lambda nil (if org-ql-view-buffers-files (progn (org-ql-view--contract-buffers-files org-ql-view-buffers-files))))) (message "%s" (funcall --cl-initial-input--)) (if (and org-ql-view-buffers-files (bufferp org-ql-view-buffers-files)) org-ql-view-buffers-files (org-ql-view--expand-buffers-files (completing-read "Buffers/Files: " (list 'buffer 'org-agenda-files 'org-directory 'all) nil nil (funcall --cl-initial-input--)))))
  org-ql-view--complete-buffers-files()
  (list (org-ql-view--complete-buffers-files) (read-string "Query: " (if org-ql-view-query (progn (format "%S" org-ql-view-query)))) :narrow (or org-ql-view-narrow (eq current-prefix-arg '(4))) :super-groups (org-ql-view--complete-super-groups) :sort (org-ql-view--complete-sort))
  call-interactively(org-ql-search)
  (if prompt (call-interactively #'org-ql-search) (apply #'org-ql-search defaults))
  (let* ((current-line (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (old-pos (point)) (defaults (list org-ql-view-buffers-files org-ql-view-query :sort org-ql-view-sort :narrow org-ql-view-narrow :super-groups org-ql-view-super-groups :title org-ql-view-title)) (org-ql-view-buffer (current-buffer))) (if prompt (call-interactively #'org-ql-search) (apply #'org-ql-search defaults)) (rename-buffer (format "%s %s*" org-ql-view-buffer-name-prefix (or org-ql-view-title org-ql-view-query)) 'unique) (goto-char (point-min)) (or (if (search-forward current-line nil t) (progn (beginning-of-line))) (goto-char old-pos)) (message "View refreshed"))
  org-ql-view-refresh((4))
  funcall-interactively(org-ql-view-refresh (4))
  call-interactively(org-ql-view-refresh nil nil)
  command-execute(org-ql-view-refresh)

The initial-input label referred above returns a list with only one string. But according to the docs, it is expected to be a cons of the form (string . position). I initially noticed this with selectum, where selectrum is operating under the assumption that the cdr of the initial-input is a number, which is what is causing the issue. Also, according to the docs, this feature is deprecated?

If INITIAL-INPUT is non-nil, insert it in the minibuffer initially,
  with point positioned at the end.  If it is (STRING . POSITION), the
  initial input is STRING, but point is placed at _zero-indexed_
  position POSITION in STRING.  (*Note* that this is different from
  ‘read-from-minibuffer’ and related functions, which use one-indexing
  for POSITION.)  This feature is deprecated--it is best to pass nil
  for INITIAL-INPUT and supply the default value DEF instead.  The
  user can yank the default value into the minibuffer easily using
  M-n.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions