unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* strange error from global-ede-mode
@ 2015-09-10 19:52 Stephen Leake
  2015-09-10 23:47 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-09-10 19:52 UTC (permalink / raw)
  To: emacs-devel

I'm getting an error from something in ede when I move an elisp buffer
to a new frame.

From Emacs master -Q on Windows (built with mingw64):

    (package-initialize)
    (require 'other-frame-window)
    (other-frame-window-mode t)
    (require 'ede)
    (require 'ede/emacs)
    (global-ede-mode 1) ;; not just single-buffer ede-minor-mode
    (find-file (locate-file "ede/files.el" load-path))

Then invoke 'C-x F'; this gives an error message starting with

"(wrong-type-argument (or eieio-object class) [cl-struct-eieio--class
ede-project"

The elisp file has to be in the Emacs core source directory, so EDE
detects the Emacs project. I get the same error from a C file in Emacs
core source.

Invoking C-x F when there is another frame does not give the error.

Killing the new frame and then running C-x F in files.el repeats the
error.

Enabling debug-on-error does not catch the error.

Enabling edebug in ofw-move-to-other-frame and stepping thru isolates
the error to x-create-frame in w32fns.c. I haven't tried debugging at
the C level yet, nor running on Linux. I'll try those next.

The error only happens with global-ede-mode enabled. So I'm guessing it
has something to do with running ede-minor-mode in a new buffer. But I
don't think ofw-move-to-other-frame creates a new buffer, so I don't see
why that matters.

Any other ideas for pinning this down?

--
-- Stephe



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

* Re: strange error from global-ede-mode
  2015-09-10 19:52 strange error from global-ede-mode Stephen Leake
@ 2015-09-10 23:47 ` Stefan Monnier
  2015-09-11 16:58   ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2015-09-10 23:47 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

> Enabling debug-on-error does not catch the error.

Have you tried debug-on-signal?

If that still doesn't help, try running in GDB, then putting a break
point on maybe_call_debugger and then look at "xbacktrace".


        Stefan



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

* Re: strange error from global-ede-mode
  2015-09-10 23:47 ` Stefan Monnier
@ 2015-09-11 16:58   ` Stephen Leake
  2015-09-11 19:47     ` Stephen Leake
  2015-09-12  0:27     ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Leake @ 2015-09-11 16:58 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Enabling debug-on-error does not catch the error.
>
> Have you tried debug-on-signal?

No help.

> If that still doesn't help, try running in GDB, then putting a break
> point on maybe_call_debugger and then look at "xbacktrace".

Also no help.

I traced thru x-create-frame in gdb; the error occurs in
initialize_frame_menubar.

I get the same error message by activating the menubar with F10 in the
files.el buffer in the initial fraem. But debug-on-error is still no
help. So I'm off to study the menu init code; I'm guessing it's
something in the EDE "Development" menu.

-- 
-- Stephe



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

* Re: strange error from global-ede-mode
  2015-09-11 16:58   ` Stephen Leake
@ 2015-09-11 19:47     ` Stephen Leake
  2015-09-12  0:26       ` Stefan Monnier
  2015-09-12  0:27     ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-09-11 19:47 UTC (permalink / raw)
  To: emacs-devel

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> Enabling debug-on-error does not catch the error.
>>
>> Have you tried debug-on-signal?
>
> No help.
>
>> If that still doesn't help, try running in GDB, then putting a break
>> point on maybe_call_debugger and then look at "xbacktrace".
>
> Also no help.
>
> I traced thru x-create-frame in gdb; the error occurs in
> initialize_frame_menubar.
>
> I get the same error message by activating the menubar with F10 in the
> files.el buffer in the initial fraem. But debug-on-error is still no
> help. So I'm off to study the menu init code; I'm guessing it's
> something in the EDE "Development" menu.

Found the problem; it's from ede-project-forms-menu, operating on the
EDE Emacs project.

The code walks up the class hierarchy, collecting the class default
value from the menu slot at each level.

To reproduce the error from Emacs master -Q:

(require 'ede/emacs)
(setq prj
    (ede-emacs-project
    :name "Emacs"
    :version "25.0.50"
    :directory "/Projects/emacs/master"
    :file "/Projects/emacs/master/src/emacs.c"))

(setq class (eieio-object-class prj))
(oref-default class menu) ;; no error
(setq parent (eieio-class-parent class))
(oref-default parent menu) ;; error

The error is from:

    (cl-check-type obj (or eieio-object class))

I'm not familiar enough with cl stuff to figure out what's wrong here.

-- 
-- Stephe



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

* Re: strange error from global-ede-mode
  2015-09-11 19:47     ` Stephen Leake
@ 2015-09-12  0:26       ` Stefan Monnier
  2015-09-13 13:45         ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2015-09-12  0:26 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

>     (cl-check-type obj (or eieio-object class))

I think the patch below will fix it,


        Stefan


diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 29c4467..f97667c 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -135,10 +135,10 @@ Currently under control of this var:
       (or (cl--find-class class) class)
     class))
 
-(defun class-p (class)
-  "Return non-nil if CLASS is a valid class vector.
-CLASS is a symbol."                     ;FIXME: Is it a vector or a symbol?
-  (and (symbolp class) (eieio--class-p (cl--find-class class))))
+(defun class-p (x)
+  "Return non-nil if X is a valid class vector.
+X can also be is a symbol."
+  (eieio--class-p (if (symbolp x) (cl--find-class x) x)))
 
 (defun eieio--class-print-name (class)
   "Return a printed representation of CLASS."



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

* Re: strange error from global-ede-mode
  2015-09-11 16:58   ` Stephen Leake
  2015-09-11 19:47     ` Stephen Leake
@ 2015-09-12  0:27     ` Stefan Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2015-09-12  0:27 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

>> If that still doesn't help, try running in GDB, then putting a break
>> point on maybe_call_debugger and then look at "xbacktrace".
> Also no help.

You mean it doesn't hit maybe_call_debugger?
If so, try to place the breakpoint on Fsignal.


        Stefan



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

* Re: strange error from global-ede-mode
  2015-09-12  0:26       ` Stefan Monnier
@ 2015-09-13 13:45         ` Stephen Leake
  2015-09-15 17:23           ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-09-13 13:45 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>     (cl-check-type obj (or eieio-object class))
>
> I think the patch below will fix it,

That helps, but then it throws a different error:

No applicable method for %S: slot-missing, [cl-struct-eieio--class
ede-project "Top level EDE project specification. ...


This is because of the logic in eieio-oref-default;

(defun eieio-oref-default (obj slot)
  "Do the work for the macro `oref-default' with similar parameters.
Fills in OBJ's SLOT with its default value."
  (cl-check-type obj (or eieio-object class))
  (cl-check-type slot symbol)
  (let* ((cl (cond ((symbolp obj) (cl--find-class obj))
                   (t (eieio--object-class obj))))
	 (c (eieio--slot-name-index cl slot)))

If "obj" is a class, then "cl" should just be "obj", not
"(eieio--object-class obj)".

In Emacs 24.5, that logic is:

  (let* ((cl (if (eieio-object-p obj) (eieio--object-class obj) obj))
	 (c (eieio-slot-name-index cl obj slot)))

As I suggest above.

So the full patch is:

diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 3b07c5d..e0b7770 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -135,10 +135,10 @@ Currently under control of this var:
       (or (cl--find-class class) class)
     class))
 
-(defun class-p (class)
-  "Return non-nil if CLASS is a valid class vector.
-CLASS is a symbol."                     ;FIXME: Is it a vector or a symbol?
-  (and (symbolp class) (eieio--class-p (cl--find-class class))))
+(defun class-p (x)
+  "Return non-nil if X is a valid class vector.
+X can also be is a symbol."
+  (eieio--class-p (if (symbolp x) (cl--find-class x) x)))
 
 (defun eieio--class-print-name (class)
   "Return a printed representation of CLASS."
@@ -766,7 +766,8 @@ Fills in OBJ's SLOT with its default value."
   (cl-check-type obj (or eieio-object class))
   (cl-check-type slot symbol)
   (let* ((cl (cond ((symbolp obj) (cl--find-class obj))
-                   (t (eieio--object-class obj))))
+                   ((eieio-object-p obj) (eieio--object-class obj))
+                   (t obj)))
 	 (c (eieio--slot-name-index cl slot)))
     (if (not c)
 	;; It might be missing because it is a :class allocated slot.


That fixes my original problem; I'll commit this.


We should also provide a "slot-missing" implementation for something
here, so future errors of this sort will give a better error message.
But apparently that's supposed to be provided by
eieio-default-superclass; I'll leave that for later.

-- 
-- Stephe



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

* Re: strange error from global-ede-mode
  2015-09-13 13:45         ` Stephen Leake
@ 2015-09-15 17:23           ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2015-09-15 17:23 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

> @@ -766,7 +766,8 @@ Fills in OBJ's SLOT with its default value."
>    (cl-check-type obj (or eieio-object class))
>    (cl-check-type slot symbol)
>    (let* ((cl (cond ((symbolp obj) (cl--find-class obj))
> -                   (t (eieio--object-class obj))))
> +                   ((eieio-object-p obj) (eieio--object-class obj))
> +                   (t obj)))
>  	 (c (eieio--slot-name-index cl slot)))
>      (if (not c)
>  	;; It might be missing because it is a :class allocated slot.

Thanks, that looks good.

> That fixes my original problem; I'll commit this.

Please do.

> We should also provide a "slot-missing" implementation for something
> here, so future errors of this sort will give a better error message.

I guess we could simply do.


        Stefan


diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 790e8bc..8c37f8c 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -768,7 +768,7 @@ dynamically set from SLOTS."
 (cl-defgeneric slot-missing (object slot-name operation &optional new-value)
   "Method invoked when an attempt to access a slot in OBJECT fails.")
 
-(cl-defmethod slot-missing ((object eieio-default-superclass) slot-name
+(cl-defmethod slot-missing (object slot-name
 			 _operation &optional _new-value)
   "Method invoked when an attempt to access a slot in OBJECT fails.
 SLOT-NAME is the name of the failed slot, OPERATION is the type of access
@@ -777,8 +777,9 @@ to be set.
 
 This method is called from `oref', `oset', and other functions which
 directly reference slots in EIEIO objects."
-  (signal 'invalid-slot-name (list (eieio-object-name object)
-				   slot-name)))
+  (signal 'invalid-slot-name
+          (list (if (eieio-object-p object) (eieio-object-name object) object)
+                slot-name)))
 
 (cl-defgeneric slot-unbound (object class slot-name fn)
   "Slot unbound is invoked during an attempt to reference an unbound slot.")



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

end of thread, other threads:[~2015-09-15 17:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-10 19:52 strange error from global-ede-mode Stephen Leake
2015-09-10 23:47 ` Stefan Monnier
2015-09-11 16:58   ` Stephen Leake
2015-09-11 19:47     ` Stephen Leake
2015-09-12  0:26       ` Stefan Monnier
2015-09-13 13:45         ` Stephen Leake
2015-09-15 17:23           ` Stefan Monnier
2015-09-12  0:27     ` Stefan Monnier

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