From 8610a39381085559163856240ce722a5279128a5 Mon Sep 17 00:00:00 2001 From: Jason Blevins Date: Sat, 31 May 2008 14:12:42 -0400 Subject: [PATCH] Initial Markdown menu based on Greg Bognar's code The menu is implemented via the easymenu package in a way that is compatible with both GNU Emacs and XEmacs. The XEmacs version of easymenu does not seem to support :help text. It also requires calling (easy-menu-add) to enable the menu. --- markdown-mode.el | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 0ed135b..4c34ed1 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -44,6 +44,12 @@ ;; [screenshot]: http://jblevins.org/projects/markdown-mode/screenshots/20071011-001.png ;; [release notes]: http://jblevins.org/projects/markdown-mode/rev-1-5 +;;; Dependencies: + +;; markdown-mode requires easymenu, a standard package since GNU Emacs +;; 19 and XEmacs 19, which provides a uniform interface for creating +;; menus in GNU Emacs and XEmacs. + ;;; Installation: ;; Make sure to place `markdown-mode.el` somewhere in the load-path and add @@ -124,7 +130,7 @@ ;; * Cyril Brulebois for Debian packaging. ;; * Conal Elliott for a font-lock regexp patch. ;; * Edward O'Connor for a font-lock regexp fix. -;; * Greg Bognar for a patch for (markdown). +;; * Greg Bognar for menus and a patch. ;;; Bugs: @@ -137,6 +143,8 @@ ;;; Code: +(require 'easymenu) + ;;; User Customizable Variables =============================================== ;; To enable itex/wiki syntax highlighting, change to @@ -547,6 +555,36 @@ which case it is turned into a blockquote region." markdown-mode-map) "Keymap for Markdown major mode") +;;; Menu ================================================================== + +(easy-menu-define markdown-mode-menu markdown-mode-map + "Menu for Markdown mode" + '("Markdown" + ["Compile" markdown] + ["Preview" markdown-preview] + "---" + ("Headers (setext)" + ["Insert Title" markdown-insert-title] + ["Insert Section" markdown-insert-section]) + ("Headers (atx)" + ["First level" markdown-insert-header-1] + ["Second level" markdown-insert-header-2] + ["Third level" markdown-insert-header-3] + ["Fourth level" markdown-insert-header-4] + ["Fifth level" markdown-insert-header-5]) + "---" + ["Bold" markdown-insert-bold] + ["Italic" markdown-insert-italic] + ["Blockquote" markdown-insert-blockquote] + ["Code" markdown-insert-code] + "---" + ["Insert inline link" markdown-insert-link] + ["Insert image" markdown-insert-image] + ["Insert horizontal rule" markdown-insert-hr] + "---" + ["Version" markdown-show-version] + )) + ;;; Commands ================================================================== @@ -580,7 +618,9 @@ which case it is turned into a blockquote region." ;; Font lock. (set (make-local-variable 'font-lock-defaults) '(markdown-mode-font-lock-keywords)) - (set (make-local-variable 'font-lock-multiline) t)) + (set (make-local-variable 'font-lock-multiline) t) + ;; For menu support in XEmacs + (easy-menu-add markdown-mode-menu markdown-mode-map)) ;(add-to-list 'auto-mode-alist '("\\.text$" . markdown-mode)) -- 2.11.4.GIT