* New special-mode parent
@ 2008-06-13 15:49 Stefan Monnier
2008-06-13 16:24 ` Lennart Borgman (gmail)
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Stefan Monnier @ 2008-06-13 15:49 UTC (permalink / raw)
To: emacs-devel
While thinking about the key-binding problems we have in vc-annotate it
occurred to me that it should use a view-mode minor mode, but rather it
should inherit from a sort of view-mode major mode, so it can override
its key-bindings. And it occurred to me that it should be called
`special-mode' and should probably be used by most "special" major modes
(those that set the mode-class property to `special').
So I'm considering adding to subr.el a simple parent major mode:
(defvar special-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "q" 'quit-window)
(define-key map " " 'scroll-up)
(define-key map "\C-?" 'scroll-down)
(define-key map "?" 'describe-mode)
(define-key map ">" 'end-of-buffer)
(define-key map "<" 'beginning-of-buffer)
(define-key map "g" 'revert-buffer)
map))
(put 'special-mode 'mode-class 'special)
(define-derived-mode special-mode nil "Special"
"Parent major mode from which special major modes should inherit."
(setq buffer-read-only t))
The above is 100% guaranteed thoroughly untested (written directly in
this *mail* buffer), so it's just a rough approximation, but should give
you some idea of where I'm going.
Any comment?
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 15:49 New special-mode parent Stefan Monnier
@ 2008-06-13 16:24 ` Lennart Borgman (gmail)
2008-06-13 16:56 ` Tom Tromey
2008-06-13 18:25 ` Dan Nicolaescu
2 siblings, 0 replies; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-13 16:24 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier wrote:
> While thinking about the key-binding problems we have in vc-annotate it
> occurred to me that it should use a view-mode minor mode, but rather it
> should inherit from a sort of view-mode major mode, so it can override
> its key-bindings. And it occurred to me that it should be called
> `special-mode' and should probably be used by most "special" major modes
> (those that set the mode-class property to `special').
>
> So I'm considering adding to subr.el a simple parent major mode:
>
> (defvar special-mode-map
> (let ((map (make-sparse-keymap)))
> (suppress-keymap map)
> (define-key map "q" 'quit-window)
> (define-key map " " 'scroll-up)
> (define-key map "\C-?" 'scroll-down)
> (define-key map "?" 'describe-mode)
> (define-key map ">" 'end-of-buffer)
> (define-key map "<" 'beginning-of-buffer)
> (define-key map "g" 'revert-buffer)
> map))
>
> (put 'special-mode 'mode-class 'special)
> (define-derived-mode special-mode nil "Special"
> "Parent major mode from which special major modes should inherit."
> (setq buffer-read-only t))
>
> The above is 100% guaranteed thoroughly untested (written directly in
> this *mail* buffer), so it's just a rough approximation, but should give
> you some idea of where I'm going.
>
> Any comment?
I did not follow the vc discussion, but I like the idea of inherited
general key binding sets. Though I am not sure they have to be in the
form of a major mode. (Maybe sometimes multiple keymap parents would be
useful, but that is another question.)
To me your suggestion here looks good. I would however prefer
`special-view-mode'.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 15:49 New special-mode parent Stefan Monnier
2008-06-13 16:24 ` Lennart Borgman (gmail)
@ 2008-06-13 16:56 ` Tom Tromey
2008-06-13 17:51 ` Stefan Monnier
2008-06-13 18:25 ` Dan Nicolaescu
2 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2008-06-13 16:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
>>>>> "Stefan" == Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
Stefan> (put 'special-mode 'mode-class 'special)
I think it would be nice is define-derived-mode automatically did this
for modes derived from special-mode.
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 16:56 ` Tom Tromey
@ 2008-06-13 17:51 ` Stefan Monnier
2008-06-14 20:03 ` Tom Tromey
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2008-06-13 17:51 UTC (permalink / raw)
To: Tom Tromey; +Cc: emacs-devel
Stefan> (put 'special-mode 'mode-class 'special)
> I think it would be nice is define-derived-mode automatically did this
> for modes derived from special-mode.
Your wish was granted several years ago already,
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 17:51 ` Stefan Monnier
@ 2008-06-14 20:03 ` Tom Tromey
2008-06-14 21:46 ` Stefan Monnier
0 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2008-06-14 20:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
>>>>> "Stefan" == Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> I think it would be nice is define-derived-mode automatically did this
>> for modes derived from special-mode.
Stefan> Your wish was granted several years ago already,
Thanks, I did not realize that.
Here's a patch to update the documentation.
Tom
2008-06-14 Tom Tromey <tromey@redhat.com>
* modes.texi (Derived Modes): Document mode-class.
*** modes.texi 30 Jan 2008 09:40:10 -0700 1.4
--- modes.texi 14 Jun 2008 14:02:24 -0600
***************
*** 779,784 ****
--- 779,787 ----
the end of this docstring. If you omit @var{docstring},
@code{define-derived-mode} generates a documentation string.
+ If the parent mode has a @code{mode-class} property, the new mode's
+ @code{mode-class} property is given the same value.
+
The @var{keyword-args} are pairs of keywords and values. The values
are evaluated. The following keywords are currently supported:
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 15:49 New special-mode parent Stefan Monnier
2008-06-13 16:24 ` Lennart Borgman (gmail)
2008-06-13 16:56 ` Tom Tromey
@ 2008-06-13 18:25 ` Dan Nicolaescu
2008-06-13 21:52 ` Stefan Monnier
2 siblings, 1 reply; 9+ messages in thread
From: Dan Nicolaescu @ 2008-06-13 18:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> While thinking about the key-binding problems we have in vc-annotate it
> occurred to me that it should use a view-mode minor mode, but rather it
> should inherit from a sort of view-mode major mode, so it can override
> its key-bindings. And it occurred to me that it should be called
> `special-mode' and should probably be used by most "special" major modes
> (those that set the mode-class property to `special').
>
> So I'm considering adding to subr.el a simple parent major mode:
> (defvar special-mode-map
> (let ((map (make-sparse-keymap)))
> (suppress-keymap map)
> (define-key map "q" 'quit-window)
> (define-key map " " 'scroll-up)
> (define-key map "\C-?" 'scroll-down)
> (define-key map "?" 'describe-mode)
This one does not seem that useful
> (define-key map ">" 'end-of-buffer)
> (define-key map "<" 'beginning-of-buffer)
> (define-key map "g" 'revert-buffer)
or this one
> Any comment?
IMO, good idea in genearal.
How about having an even more minimalistic version of this turned on
even for read-only files?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New special-mode parent
2008-06-13 18:25 ` Dan Nicolaescu
@ 2008-06-13 21:52 ` Stefan Monnier
2008-06-14 11:27 ` Juanma Barranquero
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2008-06-13 21:52 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
>> (defvar special-mode-map
>> (let ((map (make-sparse-keymap)))
>> (suppress-keymap map)
>> (define-key map "q" 'quit-window)
>> (define-key map " " 'scroll-up)
>> (define-key map "\C-?" 'scroll-down)
>> (define-key map "?" 'describe-mode)
> This one does not seem that useful
view-mode provides it and it seemed like it wouldn't hurt. But I don't
really care about it.
>> (define-key map ">" 'end-of-buffer)
>> (define-key map "<" 'beginning-of-buffer)
>> (define-key map "g" 'revert-buffer)
> or this one
You mean the "g" one? That's actually one I find important: all/most
special modes provide it.
> How about having an even more minimalistic version of this turned on
> even for read-only files?
It'd be kind of incompatible with the idea of a major mode.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-06-14 21:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13 15:49 New special-mode parent Stefan Monnier
2008-06-13 16:24 ` Lennart Borgman (gmail)
2008-06-13 16:56 ` Tom Tromey
2008-06-13 17:51 ` Stefan Monnier
2008-06-14 20:03 ` Tom Tromey
2008-06-14 21:46 ` Stefan Monnier
2008-06-13 18:25 ` Dan Nicolaescu
2008-06-13 21:52 ` Stefan Monnier
2008-06-14 11:27 ` Juanma Barranquero
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.