Subject: bug#44764: 28.0.50; Wrong menu binding for file in tree fileset

From: Mauro Aranda <[email-masked]>
Date: Fri, 20 Nov 2020 12:56:04 -0300

tags 44764 patch
quit

Mauro Aranda <[email-masked]> writes:

> To reproduce:
> 0) Setup a directory with subdirectories and files, for later definition
> of a tree fileset:
> mkdir fileset-test
> cd fileset-test
> touch file.el
> mkdir subdir
> cd subdir
> touch file1.el file2.el file3.el file4.el file5.el
>
> 5 files seems kinda arbitrary, but it's needed so that one of the files
> is left alone as a menu item.
>
> 1) Start Emacs: emacs -Q
>
> 2) Eval: (filesets-init)
>
> 3) M-x set-variable RET filesets-max-submenu-length RET 3
>
> This is so I don't bore you with creating more than 25 files.
>
> 4) M-x filesets-edit
>
> Add a new entry to filesets-data, like so:
> Name: test
> In Data, select the Directory Tree option and then:
> Dir: /path/to/fileset-test
> Pattern: ^.+\.el$
>
> Set for current session.
>
> Now data should look like this:
> (("test (:tree "path/to/fileset-test" "^.+\\.el$")))
>
> 5) Click the File menu, and follow the Filesets entry, then the test
> entry and finally the subdir entry.
>
> You should see that file1.el and file2.el are grouped.  Also, file3.el
> and file4.el got grouped, while file5.el is left alone.  This is OK.
>
> Clicking any file but file5.el works fine.  But clicking file5.el raises
> an error:
> Invalid function: (filesets-file-open nil
'"/path/to/fileset-test/subdir/file5.el" '"test")
>
> The menu entry for file5.el is wrong.

The attached patch should fix it.  OK to install?
From 6f5012d7cc7cb1bf3e650366b14fc367261c186f Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Fri, 20 Nov 2020 12:52:56 -0300
Subject: [PATCH] Fix menu binding for files in fileset

* lisp/filesets.el (filesets-remake-shortcut): We want the callback of
the menu item, not a list that contains the callback.  (Bug#44764)
---
 lisp/filesets.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/filesets.el b/lisp/filesets.el
index c7ec3f77f4..cddaccbb2a 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -1878,8 +1878,7 @@ filesets-remake-shortcut
 		       (substring (elt submenu 0) 2))))
     (if (listp submenu)
 	(cons name (cdr submenu))
-      (apply 'vector (list name (cdr (append submenu nil)))))))
-;      (vconcat `[,name] (subseq submenu 1)))))
+      (apply 'vector (list name (cadr (append submenu nil)))))))
 
 (defun filesets-wrap-submenu (submenu-body)
   "Split long submenus."
-- 
2.29.2