* Icicles, Printing and Easy Menu
@ 2006-10-28 2:38 Herbert Euler
2006-10-28 18:14 ` Richard Stallman
0 siblings, 1 reply; 8+ messages in thread
From: Herbert Euler @ 2006-10-28 2:38 UTC (permalink / raw)
This is another problem that arised when I tried Icicles mode (by Drew
Adams -- http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Libraries).
The reason my customizations were cleared (see also
http://lists.gnu.org/archive/html/emacs-devel/2006-10/msg00863.html)
was an init-file loading error. The error is caused because Icicles
mode confuses `easy-menu-get-map'.
I have Printing settings in my init file. Precisely, I have the
following lines:
(if (>= emacs-major-version 22)
(progn (require 'printing)
(pr-update-menus)))
I found that when I put `(icicle-mode t)' before this if-clause, I
would get an error, but not if after. I then traced and knew what was
wrong.
Printing updates a sub-menu in the "File" menu with `pr-update-menus'.
It does this update with `easy-menu-change'. `easy-menu-change' will
search for a map in which the modification of menu will be done with
`easy-menu-get-map'.
`easy-menu-get-map' requires an argument named `map'. If this
argument is bound to something not nil, `easy-menu-get-map' will
search for the desired map in it. Otherwise, it searches in the
result returned by `(current-active-maps)'. This will be a list of
all of the active maps currently, with the current global map as the
last element. `easy-menu-get-map' will return the first appropriate
entry, so I think it will return the global map only for the case when
the meaning of caller makes sense to all modes, i.e. not local to the
current major mode.
Printing wants to add a menu entry to the "File" menu, so I think it
wants `global-map'. 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.
I wrote to Drew Adams, he suggested me to report this problem to
emacs-devel.
Should things which may confuse other packages on menu manipulation be
put into `global-map', or `easy-menu-*' be modified?
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
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
2006-10-30 7:38 ` Herbert Euler
0 siblings, 2 replies; 8+ messages in thread
From: Richard Stallman @ 2006-10-28 18:14 UTC (permalink / raw)
Cc: emacs-devel
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Icicles, Printing and Easy Menu
2006-10-28 18:14 ` Richard Stallman
@ 2006-10-28 19:45 ` Drew Adams
2006-10-30 7:38 ` Herbert Euler
1 sibling, 0 replies; 8+ messages in thread
From: Drew Adams @ 2006-10-28 19:45 UTC (permalink / raw)
Cc: Vinicius Jose Latorre, emacs-devel
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
2006-10-28 18:14 ` Richard Stallman
2006-10-28 19:45 ` Drew Adams
@ 2006-10-30 7:38 ` Herbert Euler
2006-10-30 7:46 ` Herbert Euler
1 sibling, 1 reply; 8+ messages in thread
From: Herbert Euler @ 2006-10-30 7:38 UTC (permalink / raw)
Cc: emacs-devel
I reproduce the same problem with the following operations:
1. Start Emacs with either
$ emacs -Q
or
$ emacs -q
2. In the *scratch* window:
(require 'pp)
==> pp
(require 'printing)
==> printing
(pr-update-menus t)
==> Debugger entered--Lisp error: (wrong-type-argument listp 3)
So, there is clearly something wrong with Easy Menu. I will
track this later.
Regards,
Guanpeng Xu
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
2006-10-30 7:38 ` Herbert Euler
@ 2006-10-30 7:46 ` Herbert Euler
2006-11-01 2:11 ` Vinicius Jose Latorre
0 siblings, 1 reply; 8+ messages in thread
From: Herbert Euler @ 2006-10-30 7:46 UTC (permalink / raw)
Cc: emacs-devel
>I reproduce the same problem with the following operations:
>
>1. Start Emacs with either
>
> $ emacs -Q
>
>or
>
> $ emacs -q
>
>2. In the *scratch* window:
>
>(require 'pp)
>==> pp
>(require 'printing)
>==> printing
>(pr-update-menus t)
>==> Debugger entered--Lisp error: (wrong-type-argument listp 3)
>
>So, there is clearly something wrong with Easy Menu. I will
>track this later.
The problem is in Printing. (require 'pp) is not needed at all. Only
(require 'printing) and (pr-update-menus t) when Emacs is started with '-q'
is sufficient to produce the error.
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
2006-10-30 7:46 ` Herbert Euler
@ 2006-11-01 2:11 ` Vinicius Jose Latorre
2006-11-01 3:04 ` Herbert Euler
0 siblings, 1 reply; 8+ messages in thread
From: Vinicius Jose Latorre @ 2006-11-01 2:11 UTC (permalink / raw)
Cc: rms, emacs-devel
Herbert Euler wrote:
>> I reproduce the same problem with the following operations:
>>
>> 1. Start Emacs with either
>>
>> $ emacs -Q
>>
>> or
>>
>> $ emacs -q
>>
>> 2. In the *scratch* window:
>>
>> (require 'pp)
>> ==> pp
>> (require 'printing)
>> ==> printing
>> (pr-update-menus t)
>> ==> Debugger entered--Lisp error: (wrong-type-argument listp 3)
>>
>> So, there is clearly something wrong with Easy Menu. I will
>> track this later.
>
> The problem is in Printing. (require 'pp) is not needed at all. Only
> (require 'printing) and (pr-update-menus t) when Emacs is started with
> '-q' is sufficient to produce the error.
>
> Regards,
> Guanpeng Xu
Well, I'm using Linux and Emacs 22.0.50.1.
I couldn't reproduce the problem using the steps above.
But using the steps that Drew Adams wrote, I got the error too.
The steps are:
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)
Regards,
Vinicius
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
2006-11-01 2:11 ` Vinicius Jose Latorre
@ 2006-11-01 3:04 ` Herbert Euler
2006-11-01 5:08 ` Vinicius Jose Latorre
0 siblings, 1 reply; 8+ messages in thread
From: Herbert Euler @ 2006-11-01 3:04 UTC (permalink / raw)
Cc: rms, emacs-devel
>Herbert Euler wrote:
>>>I reproduce the same problem with the following operations:
>>>
>>>1. Start Emacs with either
>>>
>>> $ emacs -Q
>>>
>>>or
>>>
>>> $ emacs -q
>>>
>>>2. In the *scratch* window:
>>>
>>>(require 'pp)
>>>==> pp
>>>(require 'printing)
>>>==> printing
>>>(pr-update-menus t)
>>>==> Debugger entered--Lisp error: (wrong-type-argument listp 3)
>>>
>>>So, there is clearly something wrong with Easy Menu. I will
>>>track this later.
>>
>>The problem is in Printing. (require 'pp) is not needed at all. Only
>>(require 'printing) and (pr-update-menus t) when Emacs is started with
>>'-q' is sufficient to produce the error.
>>
>>Regards,
>>Guanpeng Xu
>
>Well, I'm using Linux and Emacs 22.0.50.1.
>
>I couldn't reproduce the problem using the steps above.
>
>But using the steps that Drew Adams wrote, I got the error too.
>The steps are:
>
> 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)
I have known what is wrong, and written to Drew Adams. Thank you.
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Icicles, Printing and Easy Menu
2006-11-01 3:04 ` Herbert Euler
@ 2006-11-01 5:08 ` Vinicius Jose Latorre
0 siblings, 0 replies; 8+ messages in thread
From: Vinicius Jose Latorre @ 2006-11-01 5:08 UTC (permalink / raw)
Cc: rms, emacs-devel
Herbert Euler wrote:
>> Herbert Euler wrote:
>>>> I reproduce the same problem with the following operations:
>>>>
>>>> 1. Start Emacs with either
>>>>
>>>> $ emacs -Q
>>>>
>>>> or
>>>>
>>>> $ emacs -q
>>>>
>>>> 2. In the *scratch* window:
>>>>
>>>> (require 'pp)
>>>> ==> pp
>>>> (require 'printing)
>>>> ==> printing
>>>> (pr-update-menus t)
>>>> ==> Debugger entered--Lisp error: (wrong-type-argument listp 3)
>>>>
>>>> So, there is clearly something wrong with Easy Menu. I will
>>>> track this later.
>>>
>>> The problem is in Printing. (require 'pp) is not needed at all.
>>> Only (require 'printing) and (pr-update-menus t) when Emacs is
>>> started with '-q' is sufficient to produce the error.
>>>
>>> Regards,
>>> Guanpeng Xu
>>
>> Well, I'm using Linux and Emacs 22.0.50.1.
>>
>> I couldn't reproduce the problem using the steps above.
>>
>> But using the steps that Drew Adams wrote, I got the error too.
>> The steps are:
>>
>> 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)
>
> I have known what is wrong, and written to Drew Adams. Thank you.
For some reason the command:
(easy-menu-change '("file") "Print" pr-menu-spec "print-buffer")
has no effect just after step 5.
The command above is correct, but has no effect, that is, "Print"
submenu is not created.
But if after step 5, you do:
5.1 C-h v global-map RET ;; create *Help* buffer in another window
5.2 C-x o ;; switch to *Help* buffer
Now, all works.
Regards,
Vinicius
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-11-01 5:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.