unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* define-key for a major-mode, 'face and external program
@ 2012-09-08 22:38 pascal chenevas
  2012-09-11 15:18 ` pascal chenevas
       [not found] ` <mailman.8626.1347376754.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: pascal chenevas @ 2012-09-08 22:38 UTC (permalink / raw)
  To: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 1371 bytes --]

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:

<center>Welcome Message </center>

<Menu1>General options</Menu1>
[Q] to quit
<Menu2>FTP</Menu2>
[F3] to start
<Menu3>IRC</Menu3>
[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.

Pascal

[-- Attachment #1.2: Type: text/html, Size: 1884 bytes --]

[-- Attachment #2: rct-mode.el --]
[-- Type: application/octet-stream, Size: 2662 bytes --]

;; This file is not part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;;; 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
\\{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 to the Remote Connection Tool for Emacs ~~" '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)

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

end of thread, other threads:[~2012-09-13  3:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-08 22:38 define-key for a major-mode, 'face and external program pascal chenevas
2012-09-11 15:18 ` pascal chenevas
     [not found] ` <mailman.8626.1347376754.855.help-gnu-emacs@gnu.org>
2012-09-12  0:45   ` Stefan Monnier
2012-09-12  9:10     ` pascal chenevas
     [not found]     ` <mailman.8702.1347441052.855.help-gnu-emacs@gnu.org>
2012-09-13  3:46       ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).