From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pascal chenevas Newsgroups: gmane.emacs.help Subject: Re: define-key for a major-mode, 'face and external program Date: Wed, 12 Sep 2012 11:10:39 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8fb1ff008bc4c204c97d9016 X-Trace: ger.gmane.org 1347441056 11091 80.91.229.3 (12 Sep 2012 09:10:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2012 09:10:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 12 11:10:59 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TBiyI-0002Xq-Kq for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 11:10:58 +0200 Original-Received: from localhost ([::1]:56599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBiyE-0000XK-Vb for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 05:10:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBiy6-0000XF-FF for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 05:10:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBiy0-0005Cq-FA for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 05:10:46 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:41447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBiy0-00050R-9H for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 05:10:40 -0400 Original-Received: by mail-ob0-f169.google.com with SMTP id x4so2522183obh.0 for ; Wed, 12 Sep 2012 02:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=mP6kxjVfUkkEG4bSwc5o0PiuWMX/Vv3WXcjhe5j4Aq0=; b=TuZijdKJiN6MdbjKDNVwpZmLM18cSoxgEd24hRX+IxhZYH/gNFdLGIF3x68qlyaA7f igVK4tGTv1XAl5dAhKfhwde2rEu9Ji+CfOgohEaVib0BaXBsiTtrv+mZHj3y6FzQojUq TgwhYEwmR1RXsl4mFn02jWe48ocz5zzWjZLNEXFKd6dMcIajcN3SkECFZBF+uE76QLFn 9/q7tG9D3sAbspHqH3TtnQZ8YguC9a2WBslDJ2AwbPQl60dhX6t6c8vesc8XFdL9yT0W 7nHuJ5vwyOU1SyBou0DUxQxchP1wKtCqKlL4dBX6899zrb1ITvHjhgAnBWXFynGetqIi yBqA== Original-Received: by 10.60.22.103 with SMTP id c7mr20896624oef.75.1347441040016; Wed, 12 Sep 2012 02:10:40 -0700 (PDT) Original-Received: by 10.182.177.42 with HTTP; Wed, 12 Sep 2012 02:10:39 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86730 Archived-At: --e89a8fb1ff008bc4c204c97d9016 Content-Type: text/plain; charset=ISO-8859-1 Stefan, Thank you so much for your answer! I have corrected my code and now my keys are set ! But now my main menu is not displayed anymore and the hook cannot be added too. (defcustom rct-mode-hook nil "Normal hook run when entering rct mode and many related modes." :type 'hook :options '(font-lock-mode t) :group 'rct) Actualy I don't know if it's usefull to add the property :options. I get an error: Debugger entered--Lisp error: (void-function add-hooks) (define-derived-mode rct-mode special-mode "rct:main" (add-hooks 'rct-mode-hook) ) (defun main() (main-menu) (rct-mode) ) Thank you, Pascal 2012/9/12 Stefan Monnier > > can you please help me with the following LISP code? > > Looks fine. > > > (define-derived-mode rct-mode special-mode "rct:main" > > "Major mode for remote connections > > \\{rct-main-mode-map}." > > (setq debug-on-error t) > > Don't use `setq' in a major-mode since the change will affect > all buffers. Better use (set (make-local-variable 'debug-on-error) t). > > > (use-local-map rct-mode-map) > > (run-hooks 'rct-mode-hook) > > Don't do that, it's done by `define-derived-mode already. > > > (main-menu)) > > This shouldn't be in the major-mode function, but in another function > (which will probably call the major-mode function). > > > (switch-to-buffer rct-mode-buffer-name) > > You should probably call pop-to-buffer here instead. > > > Stefan > --e89a8fb1ff008bc4c204c97d9016 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Stefan,

Thank you so much for your answer!

I have corrected m= y code and now my keys are set !
But now my main menu is not displayed a= nymore and the hook cannot be added too.

(defcustom rct-mode-hook ni= l
=A0=A0=A0=A0=A0=A0 "Normal hook run when entering rct mode and many re= lated modes."
=A0=A0=A0=A0=A0=A0 :type 'hook
=A0=A0=A0=A0=A0= =A0 :options '(font-lock-mode t)
=A0=A0=A0=A0=A0=A0 :group 'rct)=

Actualy I don't know if it's usefull to add the property :o= ptions. I get an error:

Debugger entered--Lisp error: (void-function add-hooks)

(define-= derived-mode rct-mode special-mode "rct:main"
=A0=A0=A0 (add-h= ooks 'rct-mode-hook)
)

(defun main()
=A0=A0 (main-menu)=A0=A0 (rct-mode)
=A0 )

Thank you,

Pascal




2012/9/12 Stefan Monnier <monnier@iro.umontreal.ca>=
> can you please help m= e with the following LISP code?

Looks fine.

> (define-derived-mode rct-mode special-mode "rct:main"
> =A0 "Major mode for remote connections
> \\{rct-main-mode-map}."
> =A0 (setq debug-on-error t)

Don't use `setq' in a major-mode since the change will affect=
all buffers. =A0Better use (set (make-local-variable 'debug-on-error) t= ).

> =A0 (use-local-map rct-mode-map)
> =A0 (run-hooks 'rct-mode-hook)

Don't do that, it's done by `define-derived-mode already.

> =A0 (main-menu))

This shouldn't be in the major-mode function, but in another function (which will probably call the major-mode function).

> =A0 (switch-to-buffer rct-mode-buffer-name)

You should probably call pop-to-buffer here instead.


=A0 =A0 =A0 =A0 Stefan

--e89a8fb1ff008bc4c204c97d9016--