Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahmed-shariff opened this issue Jun 26, 2021 · 7 comments · May be fixed by #311
Open
Assignees
Labels
Milestone

Comments

@ahmed-shariff
Copy link

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.
@ahmed-shariff ahmed-shariff changed the title Use of :initial-input in org-ql-view--expand-buffers-files conflicting with selectrum Use of :initial-input in org-ql-view--expand-buffers-files conflicting with completing-read Jun 26, 2021
@alphapapa
Copy link
Owner

Thanks, I'll look into this.

@alphapapa alphapapa self-assigned this Jun 30, 2021
@alphapapa alphapapa added the bug label Jun 30, 2021
@alphapapa alphapapa added this to the 0.6 milestone Jun 30, 2021
@ahmed-shariff
Copy link
Author

as a temporary fix I have the following edit in org-ql-view:

(defun org-ql-view--complete-buffers-files ()
  "Return value for `org-ql-view-buffers-files' using completion."
  (cl-labels ((initial-input
               () (when org-ql-view-buffers-files
                    (cons (car (org-ql-view--contract-buffers-files
                                org-ql-view-buffers-files))
                          0))))
....

@alphapapa
Copy link
Owner

Retargeting this for 0.7. 0.6 has been delayed for too long.

@alphapapa
Copy link
Owner

I'm afraid I need to defer this again. Apologies that I haven't made time to review this fully yet. With the limited time I have, I often have to prioritize features that I need myself, and this hasn't affected me much yet. In the meantime, features I do need are ready to be tagged for release.

@alphapapa
Copy link
Owner

For future reference: These issues/PRs are a part of this overall feature:

Also, @ahmed-shariff: I'm still hoping to upstream org-ql into org.git eventually. Work toward that might start sometime next year. That will mean, of course, having to assign copyright to the FSF. Have you signed the FSF CA for Emacs? If not, can you do so for the sake of these changes? Thanks.

@alphapapa alphapapa linked a pull request Dec 16, 2023 that will close this issue
@alphapapa alphapapa modified the milestones: 0.8, Future Dec 16, 2023
@ahmed-shariff
Copy link
Author

I understand.

I am glad to know org-ql could become part of org, that's exciting. I have not signed the FSF. Correct me if I am wrong - I have to follow this: https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future
right?

I have to clarify a few things with my employer(s)/school. Once clarified I'll sign them.

@yantar92
Copy link
Contributor

yantar92 commented Dec 16, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment