emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package


From: Jean Louis
Subject: Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico
Date: Fri, 9 Apr 2021 14:12:21 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Juri Linkov <juri@linkov.net> [2021-04-07 23:39]:
> > It maybe possible to improve tabulated-list-mode so that it may be
> > used for selection of items.
> 
> You meant to improve completing-read to support tabulated-list-mode?

What I mean is:

- to be able to offer either list of strings or list of lists with
  various data

- data is automatically formatted to fit into tabulated-list-mode

- user may select one or more entries in tabulated-list-mode by
  browsing or filtering

- user may press RET or something else to select, the
  tabulated-list-mode buffer is burried and selection taken.

Now if that or similar flow can be glued to completing-read even
better, it would be great.

I find default completing-read in many cases superior to various
completion packages, but this may be due to my personalized habits of
using TAB, using "-" to complete shorter or using  wildcard "*". But
those completions are interferring with the work. They are focusing on
minibuffer or other window where user is expected to do exactly that
what program wants, usually user cannot exit from there and review
other window, or do some other selection.

The concept I have explained I already use in a limited manner and it
offers me browsing from one set of data to other set of data.

But I do not have possibility (yet) to construct tabulated-list-frame
and just click to get the result.

Small example on what I would need:

(defun complete-by-tab ()
  (let ((tabulated-list-format [("ID" 10 t) ("Name" 30 t) ("Group" 30 t)])
        (tabulated-list-entries '((1 ["1" "Joe" "Friends"]) (2 ["2" "Jane" 
"Love"]) (3 ["3" "Jimmy" "Job"])))
        (buffer (generate-new-buffer "Tabulated List Mode")))
    (switch-to-buffer buffer)
    (tabulated-list-mode)
    (setq tabulated-list-padding 1)
    (tab-select-local-map)
    (tabulated-list-init-header)
    (tabulated-list-print)))

(defvar-local rcd-tabulated-marked-items nil
  "Collects IDs for tabulated list modes")

(defun rcd-tabulated-mark-id ()
  "To mark entries"
  (interactive)
  (let ((id (tabulated-list-get-id)))
    (when id
      (tabulated-list-put-tag "⇉" t)
      (cl-pushnew id rcd-tabulated-marked-items))))
      ;; (message "Marked ID %s (%s)" id rcd-tabulated-marked-items))))

(defun tab-select-local-map ()
  (interactive)
  (let ((map (make-sparse-keymap)))
    (set-keymap-parent map tabulated-list-mode-map)
    (define-key map "m" 'rcd-tabulated-mark-id)
    (define-key map (kbd "RET") '(lambda () (interactive)
                                   (if rcd-tabulated-marked-items
                                       (setq my-selection 
rcd-tabulated-marked-items)
                                     (setq my-selection (list 
(tabulated-list-get-id))))
                                   (quit-window)))
    (use-local-map map)))

(complete-by-tab)

Now after this I can mark entries or select one entry, that is fine, and I get 
result:

my-selection ⇒ (3 2 1)

Not bad...

But I would like to find the solution to return the result back to program 
execution.

As this below does not work how I would like it:

(progn
  (complete-by-tab)
  (message "%s" my-selection))

Result is that I cannot get the selection. Maybe if I use
with-temp-buffer and invoke tabulated-list-mode?

I would like to know how to wait without blocking for
complete-by-tab until it finishes it execution that I can read
`my-selection'.

tabulated-list-mode is great tool for menu and submenu browsing,
or tree browsing. But it is not visible tree on the page, I have
to create new frames to browse subtres, which is not bad for now.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]