unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* tabulated-list-mode: how to activate button?
@ 2020-12-07  0:36 Jean Louis
  2020-12-07  0:44 ` Michael Heerdegen
  0 siblings, 1 reply; 9+ messages in thread
From: Jean Louis @ 2020-12-07  0:36 UTC (permalink / raw)
  To: Help GNU Emacs

I have reported this as bug, but maybe somebody has solution as I need
help to extend Hyperscope dynamic knowledge repository.

Here I am defining new `my-mode' child of `tabulated-list-mode'

(define-derived-mode my-mode tabulated-list-mode "Choice" "Choice Mode"
  (setq tabulated-list-padding 1)
  (setq tabulated-list-format  [("Title" 60 t) ("Button" 20 t)])
  (tabulated-list-init-header))

Then I wish to create a button as described in
{C-h v tabulated-list-entries RET}

Documentation:
Entries displayed in the current Tabulated List buffer.
This should be either a function, or a list.
If a list, each element has the form (ID [DESC1 ... DESCN]),
where:
 - ID is nil, or a Lisp object uniquely identifying this entry,
   which is used to keep the cursor on the "same" entry when
   rearranging the list.  Comparison is done with ‘equal’.

 - Each DESC is a column descriptor, one for each column
   specified in ‘tabulated-list-format’.  A descriptor is either
   a string, which is printed as-is, or a list (LABEL . PROPS),
   which means to use ‘insert-text-button’ to insert a text
   button with label LABEL and button properties PROPS.
   The string, or button label, must not contain any newline.

(defun my-display ()
  (let* ((buffer "Choice")
	 (buffer (get-buffer-create buffer)))
    (switch-to-buffer-other-window buffer)
    (my-mode)
    (setq tabulated-list-entries '((1 ["Something" ("Button" 'action (lambda (b) (message "Hello")) 'font-lock-face 'link 'follow-link t)])))
    (tabulated-list-print t)))
    
When activated this function shows the button, but I cannot activate
the button.

(my-display) ;; This will not activate the button as I cannot see "Hello"

;; while this works fine and I can see "Hello" when button is activated
(insert-text-button "Button" 'action (lambda (b) (message "Hello")))




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  0:36 tabulated-list-mode: how to activate button? Jean Louis
@ 2020-12-07  0:44 ` Michael Heerdegen
  2020-12-07  0:55   ` Jean Louis
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2020-12-07  0:44 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> (setq tabulated-list-entries '((1 ["Something" ("Button" 'action (lambda (b) (message "Hello")) 'font-lock-face 'link 'follow-link t)])))

A quoting issue?

Michael.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  0:44 ` Michael Heerdegen
@ 2020-12-07  0:55   ` Jean Louis
  2020-12-07  1:07     ` Michael Heerdegen
  0 siblings, 1 reply; 9+ messages in thread
From: Jean Louis @ 2020-12-07  0:55 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2020-12-07 03:45]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > (setq tabulated-list-entries '((1 ["Something" ("Button" 'action (lambda (b) (message "Hello")) 'font-lock-face 'link 'follow-link t)])))
> 
> A quoting issue?

I cannot know if you ask me.

This works as button will show "Hello":

(insert-text-button "Button"
      'help-echo "Yes"
      'action (lambda (b) (message "Hello")))

But this does not work as how it is used in tabulated-list-mode, it
will show button but I cannot use it to activate action.

(apply 'insert-text-button "Button"
   (cdr '("Button" 'action (lambda (b) (message "Hello")))))




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  0:55   ` Jean Louis
@ 2020-12-07  1:07     ` Michael Heerdegen
  2020-12-07  1:16       ` Jean Louis
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2020-12-07  1:07 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> (apply 'insert-text-button "Button"
>    (cdr '("Button" 'action (lambda (b) (message "Hello")))))

I mean, do you want/need the doubled quoting of `action` here, for
example (also the lambda should probably not be quoted)?

Michael.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  1:07     ` Michael Heerdegen
@ 2020-12-07  1:16       ` Jean Louis
  2020-12-07  1:31         ` Michael Heerdegen
  2020-12-07  2:26         ` Drew Adams
  0 siblings, 2 replies; 9+ messages in thread
From: Jean Louis @ 2020-12-07  1:16 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2020-12-07 04:08]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > (apply 'insert-text-button "Button"
> >    (cdr '("Button" 'action (lambda (b) (message "Hello")))))
> 
> I mean, do you want/need the doubled quoting of `action` here, for
> example (also the lambda should probably not be quoted)?

How do you mean double quoting?

This is how it is in source, similar:
(setq args '("Button" 'action (lambda (b) (message (emacs-uptime)))))

Then apply receives it so like below, it creates button but function
is not working.

(apply 'insert-text-button "Button" (car args))





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  1:16       ` Jean Louis
@ 2020-12-07  1:31         ` Michael Heerdegen
  2020-12-07  5:44           ` [solved] " Jean Louis
  2020-12-07  2:26         ` Drew Adams
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2020-12-07  1:31 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> This is how it is in source, similar:
> (setq args '("Button" 'action (lambda (b) (message (emacs-uptime)))))

Where is that?

> Then apply receives it so like below, it creates button but function
> is not working.
>
> (apply 'insert-text-button "Button" (car args))

AFAIU the property has the name "action" while you pass "'action".

Michael.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: tabulated-list-mode: how to activate button?
  2020-12-07  1:16       ` Jean Louis
  2020-12-07  1:31         ` Michael Heerdegen
@ 2020-12-07  2:26         ` Drew Adams
  2020-12-07  5:46           ` Jean Louis
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2020-12-07  2:26 UTC (permalink / raw)
  To: Jean Louis, Michael Heerdegen; +Cc: help-gnu-emacs

> > I mean, do you want/need the doubled quoting of `action` here, for
> > example (also the lambda should probably not be quoted)?
> 
> How do you mean double quoting?

I answered in the bug #45090 thread.  You are passing a list
by quoting it.  Nothing is trying to _evaluate_ things inside
that list - it's inappropriate to quote them.  This applies
to symbol `action', the lambda form, and the other symbols:
`font-lock-face', `link', `follow-link', and `t'.

(setq tabulated-list-entries 
      '((1 ["Something"
            ("Button"
             action (lambda (b) (message "Hello"))
             font-lock-face link 
             follow-link t)])))



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [solved] Re: tabulated-list-mode: how to activate button?
  2020-12-07  1:31         ` Michael Heerdegen
@ 2020-12-07  5:44           ` Jean Louis
  0 siblings, 0 replies; 9+ messages in thread
From: Jean Louis @ 2020-12-07  5:44 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2020-12-07 04:32]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > This is how it is in source, similar:
> > (setq args '("Button" 'action (lambda (b) (message (emacs-uptime)))))
> 
> Where is that?
> 
> > Then apply receives it so like below, it creates button but function
> > is not working.
> >
> > (apply 'insert-text-button "Button" (car args))
> 
> AFAIU the property has the name "action" while you pass "'action".

Thank you.

My confusion came from looking into other sources where for tabulated
list-mode they do something like:

                 ,(if (display-mouse-p)
                      (propertize name
                                  'font-lock-face 'bookmark-menu-bookmark
                                  'mouse-face 'highlight
                                  'follow-link t
                                  'help-echo "mouse-2: go to this
                      bookmark in other wi


but now is clear that I cannot use quotes in the same way.

Jean



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tabulated-list-mode: how to activate button?
  2020-12-07  2:26         ` Drew Adams
@ 2020-12-07  5:46           ` Jean Louis
  0 siblings, 0 replies; 9+ messages in thread
From: Jean Louis @ 2020-12-07  5:46 UTC (permalink / raw)
  To: Drew Adams; +Cc: Michael Heerdegen, help-gnu-emacs

* Drew Adams <drew.adams@oracle.com> [2020-12-07 05:26]:
> > > I mean, do you want/need the doubled quoting of `action` here, for
> > > example (also the lambda should probably not be quoted)?
> > 
> > How do you mean double quoting?
> 
> I answered in the bug #45090 thread.  You are passing a list
> by quoting it.  Nothing is trying to _evaluate_ things inside
> that list - it's inappropriate to quote them.  This applies
> to symbol `action', the lambda form, and the other symbols:
> `font-lock-face', `link', `follow-link', and `t'.
> 
> (setq tabulated-list-entries 
>       '((1 ["Something"
>             ("Button"
>              action (lambda (b) (message "Hello"))
>              font-lock-face link 
>              follow-link t)])))

Thank you, now I know why. Confusion came from interpreting (wrongly
probaly) other code.

This gave me problem yesterday and I am glad there is solution!



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-07  5:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-07  0:36 tabulated-list-mode: how to activate button? Jean Louis
2020-12-07  0:44 ` Michael Heerdegen
2020-12-07  0:55   ` Jean Louis
2020-12-07  1:07     ` Michael Heerdegen
2020-12-07  1:16       ` Jean Louis
2020-12-07  1:31         ` Michael Heerdegen
2020-12-07  5:44           ` [solved] " Jean Louis
2020-12-07  2:26         ` Drew Adams
2020-12-07  5:46           ` Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).