aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-05-28 18:56:08 +0000
committerStefan Monnier2008-05-28 18:56:08 +0000
commitd338d019e40a9b7c334b04a017d3d6e485403be4 (patch)
treec732d3445fffd6c40c3b0149aeeff43253fef9a5
parentdd798c64f3b27b657d04bba804bf0a63759609ca (diff)
downloademacs-d338d019e40a9b7c334b04a017d3d6e485403be4.tar.gz
emacs-d338d019e40a9b7c334b04a017d3d6e485403be4.zip
(easy-menu-convert-item, easy-menu-convert-item-1):
Move the duplicate-generation outside of the caching so it also works for identical entries.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/easymenu.el36
2 files changed, 23 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1f6901920c4..5c123a80c82 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12008-05-28 Stefan Monnier <monnier@iro.umontreal.ca> 12008-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/easymenu.el (easy-menu-convert-item)
4 (easy-menu-convert-item-1): Move the duplicate-generation outside of
5 the caching so it also works for identical entries.
6
3 * tar-mode.el (tar-summarize-buffer): Fix reporter initialization. 7 * tar-mode.el (tar-summarize-buffer): Fix reporter initialization.
4 (tar-mode): Use write-region-annotate-functions rather than 8 (tar-mode): Use write-region-annotate-functions rather than
5 write-contents-functions. 9 write-contents-functions.
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 957de4dfe2a..bdca92e7fb0 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -277,9 +277,25 @@ conversion is done from within a filter.
277This also helps when the NAME of the entry is recreated each time: 277This also helps when the NAME of the entry is recreated each time:
278since the menu is built and traversed separately, the lookup 278since the menu is built and traversed separately, the lookup
279would always fail because the key is `equal' but not `eq'." 279would always fail because the key is `equal' but not `eq'."
280 (or (gethash item easy-menu-converted-items-table) 280 (let* ((cache (gethash item easy-menu-converted-items-table))
281 (puthash item (easy-menu-convert-item-1 item) 281 (result (or cache (easy-menu-convert-item-1 item)))
282 easy-menu-converted-items-table))) 282 (key (car-safe result)))
283 (when (and (listp easy-menu-avoid-duplicate-keys) (symbolp key))
284 ;; Merging multiple entries with the same name is sometimes what we
285 ;; want, but not when the entries are actually different (e.g. same
286 ;; name but different :suffix as seen in cal-menu.el) and appear in
287 ;; the same menu. So we try to detect and resolve conflicts.
288 (while (memq key easy-menu-avoid-duplicate-keys)
289 ;; We need to use some distinct object, ideally a symbol, ideally
290 ;; related to the `name'. Uninterned symbols do not work (they
291 ;; are apparently turned into strings and re-interned later on).
292 (setq key (intern (format "%s-%d" (symbol-name key)
293 (length easy-menu-avoid-duplicate-keys))))
294 (setq result (cons key (cdr result))))
295 (push key easy-menu-avoid-duplicate-keys))
296
297 (unless cache (puthash item result easy-menu-converted-items-table))
298 result))
283 299
284(defun easy-menu-convert-item-1 (item) 300(defun easy-menu-convert-item-1 (item)
285 "Parse an item description and convert it to a menu keymap element. 301 "Parse an item description and convert it to a menu keymap element.
@@ -376,20 +392,6 @@ ITEM defines an item as in `easy-menu-define'."
376 ;; It also makes it easier/possible to lookup/change menu bindings 392 ;; It also makes it easier/possible to lookup/change menu bindings
377 ;; via keymap functions. 393 ;; via keymap functions.
378 (let ((key (easy-menu-intern name))) 394 (let ((key (easy-menu-intern name)))
379 (when (listp easy-menu-avoid-duplicate-keys)
380 ;; Merging multiple entries with the same name is sometimes what we
381 ;; want, but not when the entries are actually different (e.g. same
382 ;; name but different :suffix as seen in cal-menu.el) and appear in
383 ;; the same menu. So we try to detect and resolve conflicts.
384 (while (and (stringp name)
385 (memq key easy-menu-avoid-duplicate-keys))
386 ;; We need to use some distinct object, ideally a symbol, ideally
387 ;; related to the `name'. Uninterned symbols do not work (they
388 ;; are apparently turned into strings and re-interned later on).
389 (setq key (intern (format "%s (%d)" (symbol-name key)
390 (length easy-menu-avoid-duplicate-keys)))))
391 (push key easy-menu-avoid-duplicate-keys))
392
393 (cons key 395 (cons key
394 (and (not remove) 396 (and (not remove)
395 (cons 'menu-item 397 (cons 'menu-item