"Stephen J. Turnbull" <stephen(a)xemacs.org> writes:
Dominik Honnef writes:
> The way I initially solved it for GNU Emacs was with an alias a la
>
> > (defalias 'go--prog-mode
> > (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
>
> which I then used in the mode definition:
>
> > (define-derived-mode go-mode go--prog-mode "Go"
>
> In GNU Emacs, this works fine.
The only reason I can imagine this working in GNU is that prog-mode is
always available. Or maybe they've had enough people try it that they
decided to put in a total hack that dereferences the function cell of
the mode symbol and checks if it's a symbol naming a mode, in which
case it doesn't treat it as a function but as a mode name.
prog-mode was introduced in GNU Emacs 24.1, before that it's undefined.
Even if it weren't, without the hack you're mentioning, it would have to
break equally in GNU Emacs and XEmacs.
[snip (22 lines)]
The really big problem problem is that your prog-mode pollutes the
name-space (there's only one...) and will confuse other modes that
hack around XEmacs's lack in the same way. I recommend:
Okay, I'll have to update my implementation to avoid polluting the
namespace, especially since my entirely blank definition of prog-mode
might not be what others would expect.
(if (fboundp 'prog-mode)
(define-derived-mode go--prog-mode prog-mode)
(define-derived-mode go--prog-mode fundamental-mode)
;; Add prog-mode features needed by go-mode here.
)
> (It probably makes sense to have prog-mode added to xemacs, too, no? Even
> if just as a place-holder).
Yes, but not as a place-holder, please, for the same reason as above.
For what it is worth, go-mode does not depend on any behaviour set up by
prog-mode – and there's generally not much that prog-mode does, its whole
definition fits into 20 lines of code. The biggest point in prog-mode
in GNU Emacs is to allow users to have hooks that execute for all
programming modes. So me wanting to derive from prog-mode is more about
GNU Emacs convention than it is about functionality.
Dominik Honnef writes:
> XEmacs, however, apparently tries to inherit the keymap from
> go--prog-mode,
That's what it should do. Mode symbols are just symbols with special
conventions for the use of function and value cells, and properties.
> instead of what it points to (in this case fundamental-mode),
Ah, but defalias makes go--prog-mode point to fundamental-mode as a
*function*, not as a variable or mode. I can understand why you might
think it should work as a mode symbol, but XEmacs is philosophically
opposed to the kind of hack that would make it work.
Okay, that makes sense. I can see how it's a hack.
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta