From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#14797: 24.3.50; new, undocumented menu structure using VECTORS? Date: Thu, 4 Jul 2013 16:54:21 -0700 (PDT) Message-ID: <6b4ca396-4d2b-4719-8b1e-1ef9eb6f5610@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1372982112 10762 80.91.229.3 (4 Jul 2013 23:55:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Jul 2013 23:55:12 +0000 (UTC) To: 14797@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 05 01:55:12 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UutMl-0002YY-9z for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Jul 2013 01:55:11 +0200 Original-Received: from localhost ([::1]:57715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutMk-00059t-Fk for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2013 19:55:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutMf-00052Z-DE for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:55:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UutMe-0008PU-4Y for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:55:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutMd-0008KW-7I for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UutMc-00059n-Ih for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2013 23:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14797 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.137298208119784 (code B ref -1); Thu, 04 Jul 2013 23:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Jul 2013 23:54:41 +0000 Original-Received: from localhost ([127.0.0.1]:58335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UutMG-000591-32 for submit@debbugs.gnu.org; Thu, 04 Jul 2013 19:54:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42429) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UutMC-00058k-BV for submit@debbugs.gnu.org; Thu, 04 Jul 2013 19:54:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UutM5-00089N-Qu for submit@debbugs.gnu.org; Thu, 04 Jul 2013 19:54:30 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutM5-00089J-Nn for submit@debbugs.gnu.org; Thu, 04 Jul 2013 19:54:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutM3-0004or-Ib for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:54:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UutM2-00088w-6Z for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:54:27 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:42488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UutM1-00088q-WC for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2013 19:54:26 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r64NsOWL007332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Jul 2013 23:54:25 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r64NsNoB015908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 4 Jul 2013 23:54:24 GMT Original-Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r64NsN2A015900 for ; Thu, 4 Jul 2013 23:54:23 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:75927 Archived-At: I have a library, lacarte.el, that lets you use the keyboard to navigate the menu-bar menus. The aim is thus similar to that of tmm, but you can use completion against the full "path" to a menu item (submenus etc.). Completion candidates look like this: `Buffers > Frames > foo.el' (item `foo.el' in submenu `Frames' of menu-bar menu `Buffers'. When you have multiple frames, the dynamically created `Buffers' menu-bar menu has a (dynamically created) submenu `Frames'. Starting with Emacs 23, instead of seeing candidates like `Buffers > Frames > foo.el' in LaCarte, you see only a pseudo candidate for the submenu itself: `Buffers > Frames', and if you choose that candidate you get an error saying that there is no such command. That's because the LaCarte code assumes that the menu data structure corresponds to the documented menu structures. It seems that the Emacs code now uses an undocumented menu structure here. The code in menu-bar.el that creates the `Buffers' menu (and its `Frames' submenu) changed in Emacs 23 to use a vector of buffer (and a vector of frame) entries instead of a list of them. I don't see anything in the manual that mentions that a menu can take this form. Dunno whether I am not reading it well enough or the doc is incomplete. And I see nothing in the Emacs 23 NEWS about such a new menu structure. (I do not understand how someone can make such a fundamental change and not mention it in NEWS. New menu structures are not something that Emacs adds everyday.) 1. So at a minimum this is a DOC bug report: I would like the doc to describe all of the possible forms of menus. Apparently it no longer does that. 2. Beyond that, using vectors here is a PITA for Lisp code. It makes code that traverses such code difficult, if not impossible. Without this change to vectors, a simple recursion on a list cdr is all that is needed. No doubt I'll find a fix, once I know the actual possible menu structures available. But using vectors here does not seem very lispy. Could you perhaps consider changing the code back to using lists? Here are some details - see function `menu-bar-update-buffers' in `menu-bar.el. This is a snippet from that function - the part that creates the `Frames' submenu: Emacs 22 (and prior is similar, but a little different (but still uses a list, not a vector)): ;; Make a Frames menu if we have more than one frame. (when (cdr frames) (let ((frames-menu (cons 'keymap (cons "Select Frame" (mapcar (lambda (frame) (nconc (list (frame-parameter frame 'name) (frame-parameter frame 'name) (cons nil nil)) 'menu-bar-select-frame)) frames))))) ;; Put it after the normal buffers (setq buffers-menu (nconc buffers-menu `((frames-separator "--") (frames menu-item "Frames" ,frames-menu)))))) Emacs 23 - uses a vector (why?): ;; Make a Frames menu if we have more than one frame. (when (cdr frames) (let* ((frames-vec (make-vector (length frames) nil)) ; <=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D (frames-menu (cons 'keymap (list "Select Frame" frames-vec))) (i 0)) (dolist (frame frames) (aset frames-vec i (nconc (list (frame-parameter frame 'name) (cons nil nil)) `(lambda () (interactive) (menu-bar-select-frame ,frame)))) (setq i (1+ i))) ;; Put it after the normal buffers (setq buffers-menu (nconc buffers-menu `((frames-separator "--") (frames menu-item "Frames" ,frames-menu)))))) I assume (hope) this change to using vectors was not gratuitous. But is it necessary? The cost is added difficulty analyzing and traversing the data structure, a priori. What is the benefit? As a heads-up, can you tell me where else, besides these two dynamically created menus (`Buffers' and `Frames'), Emacs use vectors in menu data structures? In GNU Emacs 24.3.50.1 (i686-pc-mingw32) of 2013-07-01 on LEG570 Bzr revision: 113246 lekktu@gmail.com-20130701165437-ea20s94hqwp3ttaj Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=3D/c/usr --enable-checking CFLAGS=3D'-O0 -g3' CPPFLAGS=3D'-DGLYPH_DEBUG=3D1 -I/c/usr/include''