unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Cc: Vinicius Jose Latorre <viniciusjl@ig.com.br>, emacs-devel@gnu.org
Subject: RE: Icicles, Printing and Easy Menu
Date: Sat, 28 Oct 2006 12:45:56 -0700	[thread overview]
Message-ID: <EIENLHALHGIMHGDOLMIMGEDLCMAA.drew.adams@oracle.com> (raw)
In-Reply-To: <E1Gdsh0-0004Il-2r@fencepost.gnu.org>

        But Icicles mode put something in local maps so
        that `easy-menu-get-map' returns the local map but not the
        global map, so Printing complained, an error was signaled, and
        customizations was cleared.

    It sounds to me like a bug in Icicles.
    So far I don't see that Emacs is wrong.

No, I don't think so. Herbert can provide more information; he has tracked
this down in detail. In a nutshell, easy-menu-get-map is not getting the
global map, in which printing.el has placed its File > Print menu. Instead,
it is getting a minor-mode map, which has only a limited File menu (with no
Print submenu).

Icicles defines a menu item in the File menu-bar menu in icicle-mode-map, a
minor-mode map - it does not change the global-map. If Icicle mode is turned
on before loading printing.el is loaded, then when printing.el is loaded it
calls the easy-menu functions that Herbert mentioned, which pass nil instead
of the global map, which causes easy-menu to look at the current map only (I
think). Since the current map is icicle-mode-map, and it has only an Icicles
entry in its tiny File menu, printing.el fails, because easy-menu does not
find any Print submenu under File.

Herbert can explain the details better. Probably his details will be
necessary to see just what fix is needed.

This really has nothing per se to do with Icicles. Here is a test that
reproduces the error:

1. create file foo.el with these contents:

(defun define-foo-mode-map () ""
  (setq foo-mode-map (make-sparse-keymap))
  ;; Bind foo-find-file in foo-mode-map to whatever
  ;; whatever find-file is bound to globally.
  (substitute-key-definition 'find-file
                             'foo-find-file
                             foo-mode-map global-map))

(define-minor-mode foo-mode "" (define-foo-mode-map))
(defun foo-find-file (file &optional wild) "" (interactive))

2. emacs -Q
3. M-x load-file foo.el
4. M-x foo-mode
5. M-x load-file printing.el
6. M-: (pr-update-menus t)

The problem is that there is no Print submenu in menu File, and there should
be.

With the above recipe, you will in fact get a wrong-type arg, 3 error in
pr-menu-get-item, because the key [menu-bar file Print PostScript\ Print
File] is too long to look up. However, if a test of the result of lookup-key
is added to the code to avoid that error being raised, the real problem
shows up anyway: no Print submenu under File.

(defun pr-menu-get-item (name-list)
  ;; NAME-LIST is a string or a list of strings.
  (or (listp name-list)
      (setq name-list (list name-list)))
  (and name-list
       (let* ((reversed (reverse name-list))
              (name (pr-get-symbol (car reversed)))
              (path (nreverse (cdr reversed)))
              (menu (lookup-key
                     global-map
                     (vconcat pr-menu-bar
                              (mapcar 'pr-get-symbol path)))))
         (and (not (wholenump menu)) ;; *** THIS TEST ADDED ***
              (assq name (nthcdr 2 menu))))))

The problem, I believe, is that easy-menu is not trying to update the right
menu (keymap). In foo mode, the minor-mode keymap is `foo-mode-map'. The
following is the menu-bar stuff in foo-mode-map - the File menu has only one
item:

(keymap
 (open . foo-find-file)
 (menu-bar
  keymap
  (file keymap
        (new-file
         menu-item "Visit New File..." foo-find-file
         ([24 6]
         . "  (C-x C-f)")
         :enable
         (menu-bar-non-minibuffer-window-p)
         :help "Specify a new file's name, to edit the file")))
 (24 keymap
     (6 . foo-find-file)))

It is this map that is (first) used by easy-menu, and it chokes when it
cannot look up [menu-bar file Print PostScript\ Print File] in it. It looks
as if the printing.el call to `easy-menu-get-map' mistakenly uses nil as the
first argument. According to the doc, that stands for "the local menu-bar
keymap". (Probably, it would be more exact to say "local or minor-mode
menu-bar keymap".)

Herbert mentioned that the code actually picks up all maps, but it picks up
the global-map last. I didn't look into this in detail - I just went by the
doc string here, which suggests that only the local map is used. If the
local or minor-mode map is used, whether as the first or the only map, no
Print menu is found under File in that map (because Print is only in the
global-map).

Perhaps the first arg to easy-menu-get-map should be `global-map', but I'm
not sure if that is appropriate or is even a fix. If all maps are checked
during the menu update, then the updating needs to be tolerant wherever the
Print menu is not present in the map.

HTH.

  reply	other threads:[~2006-10-28 19:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-28  2:38 Icicles, Printing and Easy Menu Herbert Euler
2006-10-28 18:14 ` Richard Stallman
2006-10-28 19:45   ` Drew Adams [this message]
2006-10-30  7:38   ` Herbert Euler
2006-10-30  7:46     ` Herbert Euler
2006-11-01  2:11       ` Vinicius Jose Latorre
2006-11-01  3:04         ` Herbert Euler
2006-11-01  5:08           ` Vinicius Jose Latorre

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=EIENLHALHGIMHGDOLMIMGEDLCMAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=viniciusjl@ig.com.br \
    /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).