unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [viniciusjl@ig.com.br: Re: Icicles, Printing and Easy Menu]
@ 2006-11-02 21:47 Richard Stallman
  2006-11-04  3:18 ` Chong Yidong
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2006-11-02 21:47 UTC (permalink / raw)


Would one of the expert debuggers please turn attention to this issue?
We need to figure out what is happening in this simple test case.


------- Start of forwarded message -------
Date: Wed, 01 Nov 2006 03:08:05 -0200
From: Vinicius Jose Latorre <viniciusjl@ig.com.br>
MIME-Version: 1.0
To: Herbert Euler <herberteuler@hotmail.com>
CC:  rms@gnu.org,  emacs-devel@gnu.org
Subject: Re: Icicles, Printing and Easy Menu
In-Reply-To: <BAY112-F2010C16B628AB27018B3CADAF80@phx.gbl>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed 
	version=3.0.4

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
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [viniciusjl@ig.com.br: Re: Icicles, Printing and Easy Menu]
  2006-11-02 21:47 [viniciusjl@ig.com.br: Re: Icicles, Printing and Easy Menu] Richard Stallman
@ 2006-11-04  3:18 ` Chong Yidong
  2006-11-08  2:00   ` Vinicius Jose Latorre
  0 siblings, 1 reply; 3+ messages in thread
From: Chong Yidong @ 2006-11-04  3:18 UTC (permalink / raw)
  Cc: Vinicius Jose Latorre, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> Would one of the expert debuggers please turn attention to this issue?
> We need to figure out what is happening in this simple test case.

This is because when you redefine some keys to the File Menu, the menu
keymap changes.  The result is that the changes that pr-menu-bind (in
printing.el) tries to make to the File Menu using easymenu won't
succeed.  The following patch fixes how pr-menu-bind changes the File
Menu.  It also fixes a bug where loading printing.el twice causes
pr-menu-bind to be called.

I'll check it in if there are no objections over the next couple of
days.

*** emacs/lisp/printing.el.~1.37.~	2006-09-21 10:57:33.000000000 -0400
--- emacs/lisp/printing.el	2006-11-03 22:06:22.000000000 -0500
***************
*** 1144,1149 ****
--- 1144,1150 ----
    "Set the value of custom variables for printer & utility selection."
    (set symbol value)
    (and (featurep 'printing)		; update only after printing is loaded
+        (not pr-menu-print-item)
         (pr-update-menus t)))
  
  
***************
*** 1151,1156 ****
--- 1152,1158 ----
    "Update utility menu entry."
    (set symbol value)
    (and (featurep 'printing)		; update only after printing is loaded
+        (not pr-menu-print-item)
         (pr-menu-set-utility-title value)))
  
  
***************
*** 1158,1163 ****
--- 1160,1166 ----
    "Update `PostScript Printer:' menu entry."
    (set symbol value)
    (and (featurep 'printing)		; update only after printing is loaded
+        (not pr-menu-print-item)
         (pr-menu-set-ps-title value)))
  
  
***************
*** 1165,1170 ****
--- 1168,1174 ----
    "Update `Text Printer:' menu entry."
    (set symbol value)
    (and (featurep 'printing)		; update only after printing is loaded
+        (not pr-menu-print-item)
         (pr-menu-set-txt-title value)))
  
  
***************
*** 3096,3118 ****
  				  (pr-get-symbol "Printing")))))
       ;; Emacs 21 & 22
       (t
!       (let* ((has-file  (lookup-key global-map (vector 'menu-bar 'file)))
! 	     (item-file (if has-file '("file") '("files"))))
! 	(cond
! 	 (pr-menu-print-item
! 	  (easy-menu-change item-file "Print" pr-menu-spec "print-buffer")
! 	  (let ((items '("print-buffer"          "print-region"
! 			 "ps-print-buffer-faces" "ps-print-region-faces"
! 			 "ps-print-buffer"       "ps-print-region")))
! 	    (while items
! 	      (easy-menu-remove-item nil item-file (car items))
! 	      (setq items (cdr items)))
! 	    (setq pr-menu-print-item nil
! 		  pr-menu-bar (vector 'menu-bar
! 				      (if has-file 'file 'files)
! 				      (pr-get-symbol "Print")))))
! 	 (t
! 	  (easy-menu-change item-file "Print" pr-menu-spec))))))))
    (pr-update-menus t))
  
  
--- 3100,3120 ----
  				  (pr-get-symbol "Printing")))))
       ;; Emacs 21 & 22
       (t
!       (cond
!        (pr-menu-print-item
! 	(easy-menu-add-item menu-bar-file-menu nil
! 			    (easy-menu-create-menu "Print" pr-menu-spec)
! 			    "print-buffer")
! 	(dolist (item '("print-buffer"          "print-region"
! 			"ps-print-buffer-faces" "ps-print-region-faces"
! 			"ps-print-buffer"       "ps-print-region"))
! 	  (easy-menu-remove-item menu-bar-file-menu nil item))
! 	(setq pr-menu-print-item nil
! 	      pr-menu-bar (vector 'menu-bar
! 				  'file
! 				  (pr-get-symbol "Print"))))
!        (t
! 	(easy-menu-change '("file") "Print" pr-menu-spec)))))))
    (pr-update-menus t))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [viniciusjl@ig.com.br: Re: Icicles, Printing and Easy Menu]
  2006-11-04  3:18 ` Chong Yidong
@ 2006-11-08  2:00   ` Vinicius Jose Latorre
  0 siblings, 0 replies; 3+ messages in thread
From: Vinicius Jose Latorre @ 2006-11-08  2:00 UTC (permalink / raw)
  Cc: rms, emacs-devel

Chong Yidong wrote:
> Richard Stallman <rms@gnu.org> writes:
>
>   
>> Would one of the expert debuggers please turn attention to this issue?
>> We need to figure out what is happening in this simple test case.
>>     
>
> This is because when you redefine some keys to the File Menu, the menu
> keymap changes.  The result is that the changes that pr-menu-bind (in
> printing.el) tries to make to the File Menu using easymenu won't
> succeed.  The following patch fixes how pr-menu-bind changes the File
> Menu.  It also fixes a bug where loading printing.el twice causes
> pr-menu-bind to be called.
>
> I'll check it in if there are no objections over the next couple of
> days.
>   

Well, IMHO, the problem is the easymenu api, the easy-menu-change 
definition:

    (defun easy-menu-change (path name items &optional before)

should be replaced by:

   (defun easy-menu-change (map path name items &optional before)

So, easy-menu-add-item receives a map instead of nil.

In the tests that I've done, all works if the map parameter is specified in
easy-menu-remove-item and in easy-menu-add-item calling,
instead of given a nil value. To fix the problem, just pass "global-map" as
the map parameter.

Also, the patch that was done in printing.el doesn't work for Emacs 21
running in GNU/Linux, the problem still persists. I've made some
modifications in the patch.

Also, there wasn't a bug when printing.el was loaded twice or more times.
The variable pr-menu-print-item only deals with the interaction between
pr-menu-bind and pr-update-menus functions, that is, no other function
should be involved in the process.

The problem in printing.el only happens when "Print" submenu is not created.

The patch below fix the problem in Emacs 21 & 22.


Vinicius


*** emacs/lisp/printing.el.~1.38.~    2006-11-06 16:01:42.000000000 -0200
--- emacs/lisp/printing.el    2006-11-07 23:20:14.000000000 -0200
***************
*** 5,11 ****
 
  ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
  ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
! ;; Time-stamp: <2006/09/15 18:53:14 vinicius>
  ;; Keywords: wp, print, PostScript
  ;; Version: 6.8.4
  ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
--- 5,11 ----
 
  ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
  ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
! ;; Time-stamp: <2006/11/07 23:20:14 vinicius>
  ;; Keywords: wp, print, PostScript
  ;; Version: 6.8.4
  ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
***************
*** 68,74 ****
  ;; interface to ps-print package and it also provides some extra stuff.
  ;;
  ;; To download the latest ps-print package see
! ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'.
  ;; Please, see README file for ps-print installation instructions.
  ;;
  ;; `printing' was inspired on:
--- 68,74 ----
  ;; interface to ps-print package and it also provides some extra stuff.
  ;;
  ;; To download the latest ps-print package see
! ;; `http://www.emacswiki.org/cgi-bin/emacs/download/ps-print.tar.gz'.
  ;; Please, see README file for ps-print installation instructions.
  ;;
  ;; `printing' was inspired on:
***************
*** 958,965 ****
  ;;
  ;; * For `printing' package:
  ;;
! ;;    printing    `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz'
! ;;    ps-print    `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'
  ;;
  ;; * For GNU or Unix system:
  ;;
--- 958,965 ----
  ;;
  ;; * For `printing' package:
  ;;
! ;;    printing    
`http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
! ;;    ps-print    
`http://www.emacswiki.org/cgi-bin/emacs/download/ps-print.tar.gz'
  ;;
  ;; * For GNU or Unix system:
  ;;
***************
*** 1144,1150 ****
    "Set the value of custom variables for printer & utility selection."
    (set symbol value)
    (and (featurep 'printing)        ; update only after printing is loaded
-        (not pr-menu-print-item)
         (pr-update-menus t)))
 
 
--- 1144,1149 ----
***************
*** 1152,1158 ****
    "Update utility menu entry."
    (set symbol value)
    (and (featurep 'printing)        ; update only after printing is loaded
-        (not pr-menu-print-item)
         (pr-menu-set-utility-title value)))
 
 
--- 1151,1156 ----
***************
*** 1160,1166 ****
    "Update `PostScript Printer:' menu entry."
    (set symbol value)
    (and (featurep 'printing)        ; update only after printing is loaded
-        (not pr-menu-print-item)
         (pr-menu-set-ps-title value)))
 
 
--- 1158,1163 ----
***************
*** 1168,1174 ****
    "Update `Text Printer:' menu entry."
    (set symbol value)
    (and (featurep 'printing)        ; update only after printing is loaded
-        (not pr-menu-print-item)
         (pr-menu-set-txt-title value)))
 
 
--- 1165,1170 ----
***************
*** 3091,3097 ****
      ;; third... time, but "print" item exists only in the first load.
      (cond
       ;; Emacs 20
!      ((string< emacs-version "21.")
        (easy-menu-change '("tools") "Printing" pr-menu-spec 
pr-menu-print-item)
        (when pr-menu-print-item
      (easy-menu-remove-item nil '("tools") pr-menu-print-item)
--- 3087,3093 ----
      ;; third... time, but "print" item exists only in the first load.
      (cond
       ;; Emacs 20
!      ((< emacs-major-version 21)
        (easy-menu-change '("tools") "Printing" pr-menu-spec 
pr-menu-print-item)
        (when pr-menu-print-item
      (easy-menu-remove-item nil '("tools") pr-menu-print-item)
***************
*** 3100,3120 ****
                    (pr-get-symbol "Printing")))))
       ;; Emacs 21 & 22
       (t
!       (cond
!        (pr-menu-print-item
!     (easy-menu-add-item menu-bar-file-menu nil
!                 (easy-menu-create-menu "Print" pr-menu-spec)
!                 "print-buffer")
!     (dolist (item '("print-buffer"          "print-region"
!             "ps-print-buffer-faces" "ps-print-region-faces"
!             "ps-print-buffer"       "ps-print-region"))
!       (easy-menu-remove-item menu-bar-file-menu nil item))
!     (setq pr-menu-print-item nil
!           pr-menu-bar (vector 'menu-bar
!                   'file
!                   (pr-get-symbol "Print"))))
!        (t
!     (easy-menu-change '("file") "Print" pr-menu-spec)))))))
    (pr-update-menus t))
 
 
--- 3096,3119 ----
                    (pr-get-symbol "Printing")))))
       ;; Emacs 21 & 22
       (t
!       (let ((menu-file (if (lookup-key global-map (vector 'menu-bar 
'file))
!                '("menu-bar" "file")     ; Emacs 22
!              '("menu-bar" "files")))) ; Emacs 21
!     (cond
!      (pr-menu-print-item
!       (easy-menu-add-item global-map menu-file
!                   (easy-menu-create-menu "Print" pr-menu-spec)
!                   "print-buffer")
!       (dolist (item '("print-buffer"          "print-region"
!               "ps-print-buffer-faces" "ps-print-region-faces"
!               "ps-print-buffer"       "ps-print-region"))
!         (easy-menu-remove-item global-map menu-file item))
!       (setq pr-menu-print-item nil
!         pr-menu-bar (vector 'menu-bar
!                     (pr-get-symbol (nth 1 menu-file))
!                     (pr-get-symbol "Print"))))
!      (t
!       (easy-menu-change (cdr menu-file) "Print" pr-menu-spec))))))))
    (pr-update-menus t))
 
 
***************
*** 6056,6062 ****
    ;; header
    (let ((versions (concat "printing v" pr-version
                "    ps-print v" ps-print-version)))
!     (widget-insert (make-string (- 79 (length versions)) ?\s) versions))
    (pr-insert-italic "\nCurrent Directory : " 1)
    (pr-insert-italic default-directory)
 
--- 6055,6063 ----
    ;; header
    (let ((versions (concat "printing v" pr-version
                "    ps-print v" ps-print-version)))
!     ;; to keep compatibility with Emacs 20 & 21:
!     ;; DO NOT REPLACE `?\ ' BY `?\s'
!     (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
    (pr-insert-italic "\nCurrent Directory : " 1)
    (pr-insert-italic default-directory)
 

Diff finished.  Tue Nov  7 23:21:03 2006

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-08  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-02 21:47 [viniciusjl@ig.com.br: Re: Icicles, Printing and Easy Menu] Richard Stallman
2006-11-04  3:18 ` Chong Yidong
2006-11-08  2:00   ` Vinicius Jose Latorre

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).