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: Tue, 11 Sep 2012 15:18:54 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8ff1c584a18e4a04c96e97c0 X-Trace: ger.gmane.org 1347376764 28210 80.91.229.3 (11 Sep 2012 15:19:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2012 15:19:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 11 17:19:27 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 1TBSFG-0005Wc-1Y for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 17:19:22 +0200 Original-Received: from localhost ([::1]:57745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBSFC-00071Z-Gg for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 11:19:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBSEx-00071A-Os for help-gnu-emacs@gnu.org; Tue, 11 Sep 2012 11:19:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBSEp-0004fI-IN for help-gnu-emacs@gnu.org; Tue, 11 Sep 2012 11:19:03 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:62088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBSEp-0004fE-9f for help-gnu-emacs@gnu.org; Tue, 11 Sep 2012 11:18:55 -0400 Original-Received: by obhx4 with SMTP id x4so1084426obh.0 for ; Tue, 11 Sep 2012 08:18:54 -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=fSN0q2pvoY0AohOdGNeRJbIaTd8gBXqfK9mv9CDiH5U=; b=UyxHbjKXXdgHOiXIgAEYt7x2zNdo3lu/trtN39zxAd7SAqBnZ9ne54T+L7I5eSkgiB iXkcQOudl5kILiJtzFzbuderdxdlfeUhreJwLBJgkkxtNsXkW/xqa+GYDvoyQA18/tv5 CjWXf3vPTe5hktdSV4DDc9Um5Tmv78lK9xf8nTHACASz63Oj0wAmIR3fuoxNSmIc/4GW 4paJiM7K5PEcDAV5RwRMamfeY/NbLtviaMKYasVb7mxGaplvog27Q7lrbGSUoqhsBqMN zqykty6D7KjBwLOppmBDs8lsxA4xPMJKoqPVgrgd4G1TmbdsqxmZ2HL7DjKVOVKCdXGz F92Q== Original-Received: by 10.60.30.201 with SMTP id u9mr18535504oeh.51.1347376734375; Tue, 11 Sep 2012 08:18:54 -0700 (PDT) Original-Received: by 10.182.177.42 with HTTP; Tue, 11 Sep 2012 08:18:54 -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:86727 Archived-At: --e89a8ff1c584a18e4a04c96e97c0 Content-Type: text/plain; charset=ISO-8859-1 Hello, can you please help me with the following LISP code? ;(require 'rct-util) ; (defconst rct-mode-buffer-name "*rct-main*" "*internal* Name of the rct main view buffer.") ; let the user have the possibility to run his hown code (defcustom rct-mode-hook nil "Normal hook run when entering Text mode and many related modes." :type 'hook :group 'data) ; Keymap (defvar rct-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c m") (lambda() (interactive) (message "C-c m pressed"))) (define-key map (kbd "") (lambda() (interactive) (message " pressed"))) (define-key map (kbd "") (lambda() (interactive) (message " pressed"))) map ) "Keymap for `rct-mode'.") ;; h1 first header in blue (defface h1 '((t :inherit default (:background "blue") )) "Face for a header without any special flags." :group 'rct-faces) (define-derived-mode rct-mode special-mode "rct:main" "Major mode for remote connections \\{rct-main-mode-map}." (setq debug-on-error t) (use-local-map rct-mode-map) (run-hooks 'rct-mode-hook) (main-menu)) ; Main Menu (defun main-menu () "This function display the main menu of the RCT mode." (with-current-buffer (get-buffer-create rct-mode-buffer-name) (erase-buffer) (insert "\n\n\n\n" (propertize "~~ Welcome ~~" 'face 'h1) "\n\n" "Main commands" "\n\n" "\t[Q] To quit the RCT-mode" "\n\n" "Section 1" "\n\n" "\t[F2] To Start XXXX\n" "\t[F3] To Start YYYYY\n" "\n" "Section 2" "\n\n" "\t[F4] To Start ZZZZZ\n" "\n\n" ); end-of insert );end-of with-current-buffer ;);end-of let (switch-to-buffer rct-mode-buffer-name) (toggle-read-only t) );end-of main-menu ; (provide 'rct-mode) Many thanks. Pascal 2012/9/8 pascal chenevas > Hello, > > First of all I would like to say that I'm starting for a week to program > in LIsp and to use Emacs too. > I'm reading such documentation like the emacswiki, the "intoduction to > programming in Emacs Lisp". > > For a week I have planed to create a major-mode and from there I can > launch a set of programs. > My major-mode should have a main menu like mu4e.el. > > To start with coding I have used the text-mode.el and the source code of > mu4e. > > Draft of the main menu: > >
Welcome Message
> > General options > [Q] to quit > FTP > [F3] to start > IRC > [F4] to start > > Note : The Welcome message should be in blue and the text in > bold (or in a different color). > > My questions are the following: > > 1) I have tried several set of functions to define a local-map that I can > use for example F2 to run an external program and I still don't understand > why my set of "local keys" are not loaded. I get the error message: is > undefined. > 2) I cannot get working to have a set of 'face to put a text in blue and > the other one in bold. > 3) I can run external program with (shell-command "cmd") but I cannot get > Emacs "free" to do anything else I would like (this part is not included in > the source code I have attached). > > Attached to the mail you will find the source code I have written. > > Many tanks for your help. > > Pascal > --e89a8ff1c584a18e4a04c96e97c0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

can you please help me with the following LISP co= de?

;(require 'rct-util)

;
(defconst rct-mode-buffer-name "*rct-main*"<= /div>
=A0=A0"*internal* Name of the rct main view buffer.") =A0

; let the user have the possibility to run his hown = code
(defcustom rct-mode-hook nil
=A0=A0"Normal ho= ok run when entering Text mode and many related modes."
=A0=A0:type 'hook
=A0=A0:group 'data)

=
; Keymap
(defvar rct-mode-map=A0
=A0=A0(let = ((map (make-sparse-keymap)))
=A0=A0 =A0(define-key map (kbd "= ;C-c m")=A0
=A0=A0 =A0 (lambda() (inte= ractive) (message "C-c m pressed")))
=A0=A0 =A0(define-= key map (kbd "<f4>")
=A0=A0 =A0 (lambda() (interactive) (message "<f4>= ; pressed")))
=A0=A0 =A0(define-key map (kbd "<f5>")=A0
= =A0=A0 =A0 (lambda() (interacti= ve) (message "<f5> pressed")))
=A0=A0 =A0map )
=A0=A0"Keymap for `rct-mode'.")

;; h1 first header in blue
(defface h1
=A0=A0'((t = :inherit default=A0
=A0=A0 =A0 =A0 (:background "blue")=
=A0=A0 =A0 =A0 ))
=A0=A0"Face for a header without any special flags."
=A0=A0:group 'rct-faces)

(define-derived-mo= de rct-mode special-mode "rct:main"
=A0=A0"Major m= ode for remote connections
\\{rct-main-mode-map}."
=A0=A0(setq debug-on-error t)
=A0=A0(use-local-map rct-mode-map)
=A0=A0(run-hooks '= ;rct-mode-hook)
=A0=A0(main-menu))

; Mai= n Menu
(defun main-menu ()
=A0=A0"This function display the ma= in menu of the RCT mode."
=A0=A0(with-current-buffer (get-bu= ffer-create rct-mode-buffer-name)
=A0=A0 =A0(erase-buffer)
<= div>=A0=A0 =A0(insert
=A0=A0 =A0 "\n\n\n\n"
=A0=A0 =A0 (propertize "= ;~~ Welcome =A0~~" 'face 'h1)
=A0=A0 =A0 "\n\n&= quot;
=A0=A0 =A0 "Main commands"
=A0=A0 =A0 &= quot;\n\n"
=A0=A0 =A0 "\t[Q] =A0To quit the RCT-mode&qu= ot;
=A0=A0 =A0 "\n\n"
=A0=A0 =A0 "Section 1"=
=A0=A0 =A0 "\n\n"
=A0=A0 =A0 "\t[F2] To= Start XXXX\n"
=A0=A0 =A0 "\t[F3] To Start YYYYY\n"= ;
=A0=A0 =A0 "\n"
=A0=A0 =A0 "Section 2"
=A0=A0 =A0 "\n\n"=
=A0=A0 =A0 "\t[F4] To Start ZZZZZ\n"
=A0=A0 = =A0 "\n\n"
=A0=A0 =A0 ); end-of insert
=A0=A0= =A0);end-of with-current-buffer
=A0=A0;);end-of let
=A0=A0(switch-to-buffer rct-mode-buffer-= name)
=A0=A0(toggle-read-only t)
=A0);end-of main-menu<= /div>
;
(provide 'rct-mode)

Many thanks.

Pascal

2012/9/8 pascal chenevas <pch.netz@gm= ail.com>
Hello,

First of all I would like to say that I'm sta= rting for a week to program in LIsp and to use Emacs too.
I'm= reading such documentation like the emacswiki, the "intoduction to pr= ogramming in Emacs Lisp".

For a week I have planed to create a major-mode and fro= m there I can launch a set of programs.
My major-mode should have= a main menu like mu4e.el.

To start with coding I = have used the text-mode.el and the source code of mu4e.

Draft =A0of the main menu:

<= ;center>Welcome Message </center>

<Men= u1>General options</Menu1>
[Q] to quit
<Men= u2>FTP</Menu2>
[F3] to start
<Menu3>IRC</Menu3>
[F4] = to start

Note : The =A0Welcome message should be i= n blue and the <Menu>text</Menu> in bold (or in a different col= or).

My questions are the=A0following:

<= div>1) I have tried several set of functions to define a local-map that I c= an use for example F2 to run an external program and I still don't unde= rstand why my set of "local keys" are not loaded. I get the error= message: <f2> is undefined.
2) I cannot get working to have a set of 'face to put a text in bl= ue and the other one in bold.
3) I can run external program with= =A0(shell-command "cmd") =A0but I cannot get Emacs "free&quo= t; to do anything else I would like (this part is not included in the sourc= e code I have attached).

Attached to the mail you will find the source code I ha= ve written.

Many tanks for your help.
<= font color=3D"#888888">

Pascal

--e89a8ff1c584a18e4a04c96e97c0--