unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14797: 24.3.50; new, undocumented menu structure using VECTORS?
@ 2013-07-04 23:54 Drew Adams
  2013-07-05 10:42 ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Drew Adams @ 2013-07-04 23:54 UTC (permalink / raw)
  To: 14797

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)) ; <============
         (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=/c/usr --enable-checking CFLAGS='-O0 -g3'
 CPPFLAGS='-DGLYPH_DEBUG=1 -I/c/usr/include''





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

end of thread, other threads:[~2016-08-06 19:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04 23:54 bug#14797: 24.3.50; new, undocumented menu structure using VECTORS? Drew Adams
2013-07-05 10:42 ` Stefan Monnier
2013-07-05 15:17   ` Drew Adams
2013-07-05 22:45     ` Stefan Monnier
2013-07-06  1:40       ` Drew Adams
2013-10-19 17:48     ` Drew Adams
2016-08-06 13:09     ` npostavs
2016-08-06 14:42       ` Eli Zaretskii
2016-08-06 15:42         ` Noam Postavsky
2016-08-06 17:36           ` Eli Zaretskii
2016-08-06 19:53             ` npostavs
     [not found]     ` <<87d1lm6o2p.fsf@users.sourceforge.net>
     [not found]       ` <<83k2fuj6vp.fsf@gnu.org>
2016-08-06 16:15         ` Drew Adams
2016-08-06 16:35           ` npostavs
2016-08-06 16:52             ` Drew Adams
2016-08-06 17:40             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

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).