From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Daiki Ueno <ueno@unixuser.org>
Cc: emacs-pretest-bug@gnu.org
Subject: Re: 23.0.60; easymenu does not display multiple separators
Date: Wed, 28 May 2008 14:56:19 -0400 [thread overview]
Message-ID: <jwviqwygswv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87fxs33p62.fsf@broken.deisui.org> (Daiki Ueno's message of "Wed, 28 May 2008 15:42:29 +0900")
>>>>> "Daiki" == Daiki Ueno <ueno@unixuser.org> writes:
> Please try the following expression. You will see only the first
> separator in the "Test" menu on the menu-bar (screenshot attached).
> (easy-menu-define
> test-menu
> (current-local-map)
> "Test menu"
> '("Test"
> ["doctor" doctor t]
> "----"
> ["hanoi" hanoi t]
> "----"
> ["life" life t]
> "----"
> ["zone" zone t]))
> (easy-menu-add nil test-menu)
I believe the patch below which I just installed fixes the problem.
Stefan
--- easymenu.el.~1.91.~ 2008-05-11 17:49:26.000000000 -0400
+++ easymenu.el 2008-05-28 14:54:29.000000000 -0400
@@ -277,9 +277,25 @@
This also helps when the NAME of the entry is recreated each time:
since the menu is built and traversed separately, the lookup
would always fail because the key is `equal' but not `eq'."
- (or (gethash item easy-menu-converted-items-table)
- (puthash item (easy-menu-convert-item-1 item)
- easy-menu-converted-items-table)))
+ (let* ((cache (gethash item easy-menu-converted-items-table))
+ (result (or cache (easy-menu-convert-item-1 item)))
+ (key (car-safe result)))
+ (when (and (listp easy-menu-avoid-duplicate-keys) (symbolp key))
+ ;; Merging multiple entries with the same name is sometimes what we
+ ;; want, but not when the entries are actually different (e.g. same
+ ;; name but different :suffix as seen in cal-menu.el) and appear in
+ ;; the same menu. So we try to detect and resolve conflicts.
+ (while (memq key easy-menu-avoid-duplicate-keys)
+ ;; We need to use some distinct object, ideally a symbol, ideally
+ ;; related to the `name'. Uninterned symbols do not work (they
+ ;; are apparently turned into strings and re-interned later on).
+ (setq key (intern (format "%s-%d" (symbol-name key)
+ (length easy-menu-avoid-duplicate-keys))))
+ (setq result (cons key (cdr result))))
+ (push key easy-menu-avoid-duplicate-keys))
+
+ (unless cache (puthash item result easy-menu-converted-items-table))
+ result))
(defun easy-menu-convert-item-1 (item)
"Parse an item description and convert it to a menu keymap element.
@@ -376,20 +392,6 @@
;; It also makes it easier/possible to lookup/change menu bindings
;; via keymap functions.
(let ((key (easy-menu-intern name)))
- (when (listp easy-menu-avoid-duplicate-keys)
- ;; Merging multiple entries with the same name is sometimes what we
- ;; want, but not when the entries are actually different (e.g. same
- ;; name but different :suffix as seen in cal-menu.el) and appear in
- ;; the same menu. So we try to detect and resolve conflicts.
- (while (and (stringp name)
- (memq key easy-menu-avoid-duplicate-keys))
- ;; We need to use some distinct object, ideally a symbol, ideally
- ;; related to the `name'. Uninterned symbols do not work (they
- ;; are apparently turned into strings and re-interned later on).
- (setq key (intern (format "%s (%d)" (symbol-name key)
- (length easy-menu-avoid-duplicate-keys)))))
- (push key easy-menu-avoid-duplicate-keys))
-
(cons key
(and (not remove)
(cons 'menu-item
prev parent reply other threads:[~2008-05-28 18:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-28 6:42 23.0.60; easymenu does not display multiple separators Daiki Ueno
2008-05-28 18:56 ` Stefan Monnier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwviqwygswv.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-pretest-bug@gnu.org \
--cc=ueno@unixuser.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).