* 23.0.60; easymenu does not display multiple separators
@ 2008-05-28 6:42 Daiki Ueno
2008-05-28 18:56 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Daiki Ueno @ 2008-05-28 6:42 UTC (permalink / raw)
To: emacs-pretest-bug
[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]
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)
In GNU Emacs 23.0.60.2 (i686-pc-linux-gnu, GTK+ Version 2.12.9)
of 2008-05-28 on p360
Windowing system distributor `The X.Org Foundation', version 11.0.10400090
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: ja_JP.UTF-8
value of $XMODIFIERS: @im=SCIM
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t
Major mode: Group
Minor modes in effect:
gnus-topic-mode: t
gnus-undo-mode: t
which-function-mode: t
icomplete-mode: t
tooltip-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
global-auto-composition-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
<escape> x g n u SPC s n o SPC SPC <backspace> <backspace>
<backspace> SPC n o SPC SPC <return> <escape> x r e
p o r <tab> <return>
Recent messages:
Loading remem...done
Loading /home/ueno/.emacs/init.el (source)...done
Loading /home/ueno/.emacs/custom.el (source)...
Loading icomplete...done
Loading which-func...done
Loading /home/ueno/.emacs/custom.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Reading /home/ueno/.newsrc.eld...
Ignoring disappeared server `nnimap'
Checking new news...done
[-- Attachment #2: easymenu-bug.png --]
[-- Type: image/png, Size: 17932 bytes --]
[-- Attachment #3: Type: text/plain, Size: 16 bytes --]
--
Daiki Ueno
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: 23.0.60; easymenu does not display multiple separators
2008-05-28 6:42 23.0.60; easymenu does not display multiple separators Daiki Ueno
@ 2008-05-28 18:56 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2008-05-28 18:56 UTC (permalink / raw)
To: Daiki Ueno; +Cc: emacs-pretest-bug
>>>>> "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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-28 18:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-28 6:42 23.0.60; easymenu does not display multiple separators Daiki Ueno
2008-05-28 18:56 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.