all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44550@debbugs.gnu.org
Subject: bug#44550: 28.0.50; proposal for tabulated-list-mode to provide narrowing incremental search
Date: Wed, 11 Nov 2020 20:22:04 +0300	[thread overview]
Message-ID: <X6wdvIx95Woc8+EZ@protected.rcdrun.com> (raw)
In-Reply-To: <83ft5f29fc.fsf@gnu.org>

* Eli Zaretskii <eliz@gnu.org> [2020-11-11 18:35]:
> > Date: Tue, 10 Nov 2020 22:57:35 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: 44550@debbugs.gnu.org
> > 
> > - imagine list of items in tabulated-list-mode
> > 
> > - user press / to open up the feature (real time incremental narrowing)
> > 
> > - when user starts typing the list of items in tabulated-list-mode are
> >   narrowing themselves visually and in real time. It is very similar
> >   to completion networks.
> 
> What does "narrowing" mean in this context?  What should happen in
> real time?  Do you mean "filtering", i.e. that some items should
> disappear from view?

Yes, thank you. I mean filtering. By pressing specific key for
filtering let us say "/" or other key, user starts typing and anything
above X length of characters (normally 3, should be customizable)
starts removing other lines that do not contain the written
query. User could enter few words and words could go match filter also
in reverse order (could be customizable). When user finishes filtering
process one could press enter to get the display in order to browse
down or up in the list. Even filtered list as result can be very long.

> If so, what criteria should be used to filter out items, and how is
> that derived from what the user types?

Criteria is that query should match the line. I prefer that several
words or parts of words can be inserted and that they can be matched
in reverse order.

When choosing a chocolate, designation in the database can be:

"Chocolate (white)" or "White Chocolate" and program does not know how
user will want to search for white chocolate. That is why reverse
order helps. Multiple words should be possible

As I am using tabulated list mode I see that lines can be concatenated
so that it is a list of strings. Query that user types would make
temporary tabulated-list-entries-filtered that replaces the original
tabulated-list-entries. User could go back to unfiltered view.

> I'm still confused regarding the feature you are looking for, and
> how it relates to completion.

I am using already tabulated mode to choose an entry. I guess it was
made for that as there is function (tabulated-list-get-id) and by that
id the choice is completed.

tabulated-list-mode can be used as additional completing-read function
and is very suitable for that. I know it is no adapted to that. I just
see it is very simple as it works with the list tabulated-list-entries
and when redisplayed it shows candidates, one can obtain ID and
candidate entry.

This below should serve to concept understanding that such function
"tabulated-completing-read" is possible.

(define-derived-mode choice-mode tabulated-list-mode "Choice" "Choice Mode"
  (setq tabulated-list-format [("Prompt here" 80 t)])
  (setq tabulated-list-padding 1)
  (tabulated-list-init-header))

(define-key choice-mode-map (kbd "<RET>") 'choice-get-id)

(defun tabulated-completing-read (prompt collection)
  (erase-buffer)
  (choice-mode)
  (setq tabulated-list-entries collection)
  (read-only-mode 1)
  (tabulated-list-print t))

(setq collection '((1 ["~/tmp"]) (2 ["~/Maildir"])))

(defun choice-get-id ()
  "Returns the choice"
  (interactive)
  (let ((id (tabulated-list-get-id)))
    (when id
      (set-register 100 (aref (car (alist-get id collection)) 0)) ;; character d
      (kill-this-buffer)
      (get-register 100))))

;; I do not know how to return, so in my program I am using register,
;; but I do not know how to return register from similar function as
;; above

;; When you evaluate this below buffer will change.

;; (tabulated-completing-read "Files" collection)

> > In general I would like to have direct real time incremental narrowing
> > of collection instead of blowing up minibuffer, making modeline jump
> > up and down with ivy-mode and splitting windows.
> > 
> > Interface would be clean just as tabulated-list-mode is and minibuffer
> > could be used for narrowing.
> 
> And now I'm completely confused: I thought you were talking about
> tabulated-list-mode, but now you've made some gigantic leap to much
> more general issues.

For my personal use case I almost finished such function but I do not
know how to return the ID. When that is solved then it becomes
possible for tabulated list mode to be used as replacement for usual
completing-read.







  reply	other threads:[~2020-11-11 17:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 10:36 bug#44550: 28.0.50; proposal for tabulated-list-mode to provide narrowing incremental search Jean Louis
2020-11-10 15:57 ` Eli Zaretskii
2020-11-10 19:57   ` Jean Louis
2020-11-11 15:35     ` Eli Zaretskii
2020-11-11 17:22       ` Jean Louis [this message]
2020-11-15 20:03     ` Juri Linkov
2020-11-15 22:04       ` Jean Louis
2020-11-15 23:26         ` Drew Adams
2020-11-15 22:51       ` Stefan Kangas
2020-11-16  9:05         ` Juri Linkov
2020-11-16 13:04           ` Stefan Kangas
2020-11-16 20:53             ` bug#44699: Add package filter by description Juri Linkov
2020-11-17  3:15               ` Stefan Kangas
2020-11-17  8:30                 ` Juri Linkov
2020-11-17 11:27                   ` Stefan Kangas
2020-11-16 16:22           ` bug#44550: 28.0.50; proposal for tabulated-list-mode to provide narrowing incremental search Drew Adams
2020-11-16 17:49             ` Jean Louis
2020-11-17  7:05           ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X6wdvIx95Woc8+EZ@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=44550@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.