[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: define-key for a major-mode, 'face and external program

From: pascal chenevas
Subject: Re: define-key for a major-mode, 'face and external program
Date: Tue, 11 Sep 2012 15:18:54 +0000


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 "<f4>")
     (lambda() (interactive) (message "<f4> pressed")))
    (define-key map (kbd "<f5>") 
     (lambda() (interactive) (message "<f5> 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
  (setq debug-on-error t)
  (use-local-map rct-mode-map)
  (run-hooks 'rct-mode-hook)

; 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)
     (propertize "~~ Welcome  ~~" 'face 'h1)
     "Main commands"
     "\t[Q]  To quit the RCT-mode"
     "Section 1"
     "\t[F2] To Start XXXX\n"
     "\t[F3] To Start YYYYY\n"
     "Section 2"
     "\t[F4] To Start ZZZZZ\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.


2012/9/8 pascal chenevas <>

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:

<center>Welcome Message </center>

<Menu1>General options</Menu1>
[Q] to quit
[F3] to start
[F4] to start

Note : The  Welcome message should be in blue and the <Menu>text</Menu> 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: <f2> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]