emacs-devel
[Top][All Lists]
Advanced

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

Re: tabulated-list-mode needs incremental search option


From: Jean Louis
Subject: Re: tabulated-list-mode needs incremental search option
Date: Sun, 15 Nov 2020 12:15:13 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

I actually wish to say for that feauture:

real time filtering

Please see emacs-tangents as I am discussing with Thien-Thi about it.
https://lists.gnu.org/archive/html/emacs-tangents/2020-11/index.html

Other question that you may know and I do not know it related to
tabulated-list-mode. How could I get it to return the value of the
tabulated list ID after closing the buffer, and when invoked from
other program or buffer.

Here is what I am trying to do, to make it as menu system where I can
feed entries to be selected:

(defun hyperscope-choice (entries &optional buffer-name)
  "This is meant to be te general choice UI with tabulated list mode"
  (interactive)
  (let* ((buffer-name (if buffer-name buffer-name "*HyperScope*")))
    (pop-to-buffer buffer-name)
    (read-only-mode 0)
    (erase-buffer)
    (read-only-mode 1)        
    (hyperscope-choice-mode)
    (hl-line-mode)
    (setq tabulated-list-entries entries)
    (tabulated-list-print t)))

(defun hyperscope-choice-sql (sql &optional buffer-name)
  (interactive)
  (let* ((buffer-name (if buffer-name buffer-name "*HyperScope*"))
         (entries (hyperscope-sql-prepare-entries sql)))
    (hyperscope-choice entries buffer-name)))

;; (setq idb (hyperscope-choice-sql "SELECT contacts_id, 
get_full_contacts_name(contacts_id), '' FROM contacts WHERE contacts_lastname 
~* 'louis'" "Choice"))

;; (hyperscope-sql-prepare-entries "SELECT contacts_id, 
get_full_contacts_name(contacts_id), '' FROM contacts WHERE contacts_lastname 
~* 'louis'")

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

So this function here I do not know how to make it:

- to kill the buffer and return the value back. I cannot kill the
  buffer this way, I have not yet discovered how.

(defun hyperscope-get-id ()
  "Returns the ID from hyperscope-choice-mode"
  (interactive)
  (let ((id (tabulated-list-get-id)))
    (when id
      (set-register 100 id) ;; character d, I am trying to enter value
                            ;; in register, to obtain it later.
      (kill-this-buffer))))

But buffer does not get killed that I may return to previous program.


* Jean Louis <bugs@gnu.support> [2020-11-10 13:37]:
> * Chong Yidong <cyd@stupidchicken.com> [2020-11-10 10:25]:
> > Hi Jean Louis,
> > 
> > > But now when you gave me references on how to filter the view then I
> > > can make function for my particular case myself to enter one or more
> > > words to filter by words. That is workaround, not real solution.
> > > ...
> > > In my opinion the above is enough for me. You said how / k filtering
> > > is implemented, even I used it but I forgot it. You reminded me, so
> > > now I can filter in similar way myself.
> > >
> > > If it happens that you decide to improve it, I have idea how you could
> > > do it: simply concatenating all tabulated items with space between and
> > > then using matching words on that list.
> > 
> > Glad the interim solution can be done.
> > 
> > I think the incremental typing functionality is best implemented as its
> > own minor mode.  It should not be tied to tabulated-list-mode.
> > 
> > This could be modelled after Emacs' completion functions.  In
> > completion, you start typing and Emacs draws in information from the
> > buffer to try and complete what you have in the minibuffer.  In the new
> > incremental processing mode, you start typing and Emacs alters the
> > buffer to reflect what's in the minibuffer.  Similar to completion, it
> > would not be mode-specific, but different modes would be able to
> > customize the effects in a way that makes sense for that mode.
> > 
> > Could you file a feature request in the Emacs bug tracker, or send an
> > email to emacs-devel to open a discussion?  It's possible there's
> > already related functionality that I'm not current aware of, e.g. in an
> > external package.
> 
> I will Cc: this email to emacs-devel.
> 
> In general I am advising that every application with choices offers
> among others the narrowing incremental search.
> 
> Be it by invoking a key binding first or directly by simply
> typing. Because there are various key bindings in almost every mode it
> is better to start narrowing incremental seach when user press special
> key like / or something.
> 
> To come out of narrowed list one could press other key binding and see
> the original list.
> 
> In my program I am using (setq tabulated-list-entries entries) and it
> is common in tabulated-list-mode.
> 
> In my program I am using (setq tabulated-list-entries entries) and it
> is common in tabulated-list-mode.
> 
> So I guess it could be implemented as you said in a derived mode
> invoked by programmer or program where:
> 
> - user press some key to start a real-time narrowing incremental
>   search
> 
> - program remembers the original `tabulated-list-entries' as
>   ORIGINAL-DATA
> 
> - program can concatenate parts of each entry into strings (or maybe
>   use other method) during the incremental narrowing search
> 
> - user starts typing and lines shown in tabulated-list-mode get
>   narrowed to selected lines
> 
> - program obtains the ID numbers and displays only those ID numbers by
>   using (setq tabulated-list-entries NARROWED-DATA) and redisplays
> 
> - use could press ENTER and narrowing incremental search stops at that
>   point, user is facing new tabulated list and can handle it in usual
>   manner.
> 
> - user may press a key to go back to go to original
>   `tabulated-list-entries' and program does (setq
>   tabulated-list-entries ORIGINAL-DATA) and re-displays
> 
> Jean



reply via email to

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