all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Defining keys in derived modes
@ 2007-02-28  9:37 Lennart Borgman (gmail)
  2007-02-28 17:51 ` Johan Bockgård
  0 siblings, 1 reply; 3+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-28  9:37 UTC (permalink / raw)
  To: Emacs Devel

I have the following code

(define-derived-mode nxhtml-part-mode nxhtml-mode "nXhtmlPart"
   "Mode for editing part of an XHTML file.
Based on `nxhtml-mode."
   (nxml-part-mode-enter))

(defvar nxhtml-part-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map nxhtml-mode-map)
     (define-key map [(control ?c) ?t] 'nxhtml-part-toggle-invisible-hf)
     map)
  "Keymap for `nxhtml-part-mode'.")

The keymap nxhtml-mpart-mode map then gets the doc string from above. I 
would expect it to also contain the definition of C-c t, but it does 
not. Should it behave this way? How should key bindings be done for 
derived modes?

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

* Re: Defining keys in derived modes
  2007-02-28  9:37 Defining keys in derived modes Lennart Borgman (gmail)
@ 2007-02-28 17:51 ` Johan Bockgård
  2007-02-28 20:58   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Bockgård @ 2007-02-28 17:51 UTC (permalink / raw)
  To: emacs-devel

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

> (define-derived-mode nxhtml-part-mode nxhtml-mode "nXhtmlPart" [...]
>
> (defvar nxhtml-part-mode-map [...]
>
> I would expect it to also contain the definition of C-c t, but it
> does not. Should it behave this way?

 -- Special Form: defvar symbol [value [doc-string]]
    [...]
     If SYMBOL is void and VALUE is specified, `defvar' evaluates it
     and sets SYMBOL to the result.  But if SYMBOL already has a value
     (i.e., it is not void), VALUE is not even evaluated, and SYMBOL's
     value remains unchanged.

-- 
Johan Bockgård

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

* Re: Defining keys in derived modes
  2007-02-28 17:51 ` Johan Bockgård
@ 2007-02-28 20:58   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 3+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-28 20:58 UTC (permalink / raw)
  To: emacs-devel

Johan Bockgård wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> 
>> (define-derived-mode nxhtml-part-mode nxhtml-mode "nXhtmlPart" [...]
>>
>> (defvar nxhtml-part-mode-map [...]
>>
>> I would expect it to also contain the definition of C-c t, but it
>> does not. Should it behave this way?
> 
>  -- Special Form: defvar symbol [value [doc-string]]
>     [...]
>      If SYMBOL is void and VALUE is specified, `defvar' evaluates it
>      and sets SYMBOL to the result.  But if SYMBOL already has a value
>      (i.e., it is not void), VALUE is not even evaluated, and SYMBOL's
>      value remains unchanged.

Thanks, yes, but I am a bit confused. There is something else going on 
too, it works defining in that order now, after restarting Emacs. Maybe 
something I do not understand in the compilation order? (I do not claim 
to understand anything there at all, I am just referring to my vague 
picture of it ;-)

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

end of thread, other threads:[~2007-02-28 20:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-28  9:37 Defining keys in derived modes Lennart Borgman (gmail)
2007-02-28 17:51 ` Johan Bockgård
2007-02-28 20:58   ` Lennart Borgman (gmail)

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.