Permalink
Browse files

first commit; was stolen from somewhere on the web as-is

  • Loading branch information...
0 parents commit 837fb6cd863b952ffbbee735a166f64dc29a9bb0 Nicholas E. May (on Enterprise) committed Mar 9, 2010
Showing with 1,121 additions and 0 deletions.
  1. +68 −0 000contrib.txt
  2. +104 −0 0readmefirst.txt
  3. +163 −0 dmode.el
  4. +689 −0 newlisp.el
  5. +8 −0 readmesometime.txt
  6. +89 −0 tj-parenface.el
@@ -0,0 +1,68 @@
+Author: Tim Johnson (Currently Primary Maintainer)
+Purpose:
+
+To constructively make this mode a organically growing system. For the most
+part, I think this is also relevant for vim and any other development system in
+the Open Source venue.
+
+1)Let there be a Primary Maintainer - for now it is me, but if I don't start
+coding in newlisp myself - I would like to see that change. The Primary
+Maintainer (PM) should be the one responsible for finalizing code changes.
+
+2)Let there be a single location for publicly posted code modules. I recommend
+that it be http://newlisp.org/code/ or something like that...
+
+3)If one has code changes to submit, post those changes to the forum, but take
+care to annotate the code changes so that the PM can easly identify the changes
+and document them. The contributor should let the PM know also whether he/she
+wants their email address posted, obfuscated or left out entirely. The PM
+should receive an email on this subject, a link to the topic in the forum would
+be sufficient.
+
+4)The PM would then integrate the new code into the existing codebase and then
+submit it to Lutz for public posting.
+
+5)If there are errors, the PM should be notified similarly as above.
+
+------------------------------------------------------------------------------
+7)Of a practical nature, submitting code changes or additions to the original
+author or the current maintainer for implementation creates a single 'code
+repository' that allows changes to proceed from one point and would be a more
+appealing alternative to numerous "code forks" IMHO.
+-------------------------------------------------------------------------------
+
+The following may be more pertinent to GNU emacs and XEmacs than to vim, but
+bears stating:
+----------------------------------------------------------------------------------
+8)Emacs is a very large, system. It is essentially an operating environment for a
+General Purpose Programming Language (GPL) called elisp. Elisp modules that are
+part of the system and included as part of the standard distribution have to
+meet some exacting standards. Regardless of whether someone reading this is an
+emacs user or uses some other development environment, you would probably agree
+that it would be a good thing for a newlisp mode to be part of the standard
+emacs distribution.
+----------------------------------------------------------------------------------
+
+If we make the "Emacs Gods" happy, newlisp mode could be a candidate for
+distribution with GNU Emacs or Xemacs or both.
+
+Tips and Pointers:
+
+A)Please maintain a readable indendation scheme. Code that is all left-justified looks
+bad in any Programming Language.
+
+B)Please don't use setq to define a symbol. For symbols local to a function, use
+the 'let form. For global variable and constant symbols, use defvar and defconst.
+If you think that elisp's approach to scope is kind of wierd, you'll get no
+argument from me...... anyway, here's why:
+
+ ==>Using setq inside of a function without binding it properly can cause
+ upredictable results by inadvertantly reseting a global symbol or
+ introducing a symbol unnecessarily into the global environment. *And* it
+ *will* displease the Emacs Gods! See item 8.
+
+C)Begin any symbol with 'newlisp-
+ elisp doesn't have any kind of namespace features, so the convention is
+ that all symbols start with the module name. Thanks.
+
+D)Feel free to let me know if I break any of my "own rules".
@@ -0,0 +1,104 @@
+Text following the line of asterisks is of historical note. :-), I'm now
+starting to (slowly) code in newlisp.
+
+Please contact me at:
+tim@johnsons-web.com
+
+If there are any problems. I recommend that you also post the questions,
+comments or caveats at newLISP Fan Club Forum Index -> newLISP newS, but
+since I don't always check in at the Forum, shoot me an email also. This has
+not been thoroughly tested, any bugs that you find and report or fix will
+improve the product. Furthermore there is the possibility that I may have
+mistakenly inserted function calls from other elisp modules that I've written,
+if you find references to them, I'll get the code imported into the mode.
+
+On-demand documentation has been removed. Too much trouble with parsing.
+This has *only* been tested on linux. I now longer use Xemacs, any references
+in the code to Xemacs should be considered incidental.
+
+Manifest:
+ This file
+ tj-parenface.el
+ newlisp.el
+ dmode.el
+ 000contrib.txt
+********************************************************************************
+Here it is warts and all.
+
+The better part is that now newlisp-mode is a bona-fide major mode, 'inherited'
+from scheme-mode, using the 'derived-mode' approach, whereas the original was a
+crude hack of another mode. You should find the main source file easier to
+modify.
+
+First, a general disclaimer. The General Public License applies. Nothing is
+guaranteed to work. I assume no liability whatsoever.
+This has been tested with both Xemacs and emacs on Linux. I don't use Windows.
+You may find differences with Windows. Let me know.
+
+Of practical concern: I am not a newlisp programmer. I worked thru jsmall's
+tutorial about a year ago. I hope to start 'studying' newlisp sometime in the
+future. But first, I wanted a mode to code with. In the meantime, the elisp
+code that I wrote is to a great deal re-usable for other modes, and this should
+prove to be a good exercise in customizing other modes to my own tastes.
+(I'm currently coding in rebol, python, javascript, and elisp)
+
+Some things to bear in mind:
+1)Evaluating a function sometimes throws errors. It may be because newlines
+ are not being properly handled.
+2)The following strings: "(define", "(defun", "(fn" are search targets for
+ marking a function beginning. Placing a space after the "(" will cause a
+ search to fail.
+3)Many functions are 'borrowed' directly from scheme-mode. scheme-mode attempts
+ to make "the right decision" for you, and sometimes results may not be what
+ you expect.
+4)Multi-line strings: I used the 'simple' approach for syntax highlighting.
+ If the results are anything like rebol, expect the following: If you edit a
+ multi-line string, the highlight will fail. When finished, move the cursor
+ outside of the string and refontify. (This feature is available in the menu).
+ There is a more complex approach, such as used for perl-mode that I hope
+ to implement in the future.
+5)Keymapping: The 'Gods of Emacs' expect the following convention:
+ Mode-specific key sequences should begin with Control-C.
+ The next keypress should be either a Control-alpha combination or
+ an non-alpha character.
+ Examples: C-c C-a ;; GOOD
+ C-c a ;; BAD
+ C-c = ;; GOOD
+ As for my private use, I'll probably unset C-l and use that as a prefix.
+ It's easier on my hands. Feel free to remap as you see fit.
+ To get a quick handle on commands, when in newlisp-mode, press
+ Control-C Control-H (assuming the standard C-c prefix). All commands
+ in the menu are keymapped, and you will get a help screen.
+6)Syntax highlighting: See "newlisp-user-keywords-regexp" in the main file.
+ It's there for you to add your own keywords from your own library.
+7)Files:
+ a)newlisp.el. Main file. The source of the mode.
+ b)tj-parenface.el. To highlight parens and brackets
+ c)nl-docs.el. One-liner documentation
+ NOTE: Uses associative list.
+ d)nl-docstrings. Verbose documentation.
+ NOTE: The docs here are produced by docstrings belonging to
+ dummy functions. I have it in the back of my mind to
+ someday make other uses of those dummy functions.
+8)Autoloading:
+ ------------
+ In your .emacs or .init.el
+ (add-to-list 'auto-mode-alist '("\\.lsp\\'" . newlisp-mode))
+ (autoload 'newlisp-mode "newlisp" "Turn on NewLisp mode" t)
+ (turn-on-font-lock)
+9)Upon autoload you should see 2 menus:
+ a)"Newlisp" - all functions
+ b)"Index" - imenu function indexing
+ Turn off 'auto-rescan if you don't want it.
+ Change sort mode if you like. See comments in newlisp.el
+ SPECIAL NOTE: See the keymapping for 'forward-sexp in newlisp.el
+ You will see that emacs displays it as 'C-c ESC' in the view buffer
+ and in the Menu. That is because emacs maps C-[ to ESC.
+10)Revisit my reference to windows.
+11)Let me know if the translation of the documentation is correct.
+ There is a possibility that escaping may have obfuscated some
+ text.
+12)Let me know of any problems, wish lists or whatever. I hope to make this
+ highly functional (eventually) and I hope that the code is written in such
+ a way as to make it understandable to a newlisp programmer.
+ Hint! Hint! I can use all the help I can get. :-)
@@ -0,0 +1,163 @@
+;;; package --- Summary
+;; dmode.el --- a guide for implementing a derived mode.
+;; - should be of particular interest to one who wishes to extend
+;; a programming mode.
+;; this file is not a part of gnu Emacs or Xemacs
+;; Author: tim johnson <tim@johnsons-web.com> (TJ)
+;;
+;;; Commentary:
+;; Thanks to Stefan Monnier <monnier@iro.umontreal.ca> (SM)
+;; Thanks also to: johan bockgård <bojohan+news@dd.chalmers.se> (JB)
+;;
+;;; Related links and files
+;; http://www.emacswiki.org/cgi-bin/wiki/DerivedMode,
+;; http://www.iro.umontreal.ca/~monnier/elisp/bibtex-style.el
+;; http://www.emacswiki.org/cgi-bin/wiki?SampleMode
+;; derived.el, which should be included with your Emacs or Xemacs installation
+;;
+;; 'Emacs' is meant to refer to *either* GNU Emacs *or* to the Xemacs fork
+;;
+;; About 'help-command': The standard Emacs installation maps control-h to the
+;; 'help-command' prefix. Sometimes control-h is mapped to backward-delete.
+;; if you have done so, then where 'c-h' is used in this file, substitute
+;; the appropriate prefix (such as F1)
+;;
+;; Derived mode is an Emacs feature that allows you to 'inherit' a major mode as a 'parent',
+;; and create a new major mode with the 'parent' features and add new features.
+;; 'define-derived-mode is defined in derived.el as a macro form.
+;;
+;;; History:
+;; version 0.1
+;;
+;;; Why implement 'derived-mode?
+;; 1)As a programmer, you might wish to enable additional syntax highlighting, such as keywords
+;; defining your own libraries or additional packages for the language of your choice.
+;; you may wish to install further functionality, like a template package for python not
+;; included in the original major mode distribution; remap keystrokes, add new keystrokes, etc.
+;; 2)You may be working with a language extension, such as the "C" dynace extension or you
+;; might be working with a language that is not included among Emacs major modes and
+;; you wish to "roll your own" - based on and leveraging an existing major mode.
+;;
+;; I speak from the viewpoint of a programmer, doubtless there are many, many other uses for
+;; derived-mode. Example: in the future, I may wish to implement on-demand documentation with some
+;; simple syntax highlighting, so I may wish to use fundamental mode as a 'parent'.
+;;
+;;; PLEASE NOTE:
+;; This template is a special case. It is my hope that one may learn about the details
+;; of developing a derived mode here, but many features may be unnecessary and other
+;; features are not included. For other examples see `Related Links and Files'
+;;
+;; The following code is not functional, but a great deal of the "work" of implementing a
+;; derived mode may be achieved by following these steps:
+;; 1)Where 'parent' is part of a symbol, substitute a symbol that describe the parent that
+;; you wish to 'inherit'.
+;; example: 'parent-mode => 'python-mode
+;; 'parent-mode => 'scheme-mode
+;; 'parent-font-lock-keywords => 'python-font-lock-keywords
+;; 2)Where 'dmode' is part of a symbol, substitute the name of your 'child' mode.
+;; 3)Follow further examples where illustrated
+;; !)Results will vary. I will be installing this file at a website and adding notes
+;; as I implement this.
+;;
+;;; Code:
+;; ===========================================================================================
+(require 'parent-mode)
+;; ===========================================================================================
+;; Not all major or derived modes need to define new faces. This example need not be used.
+;; This is best used for those who may wish to add new keywords to the mode. Such new
+;; keywords might be (as an example) additional standard features of the language OR
+;; the programmer's own library routines.
+;; Additionally, one may wish to colorize language features not covered in the parent mode.
+;; Some find this irritating, others - myself included - whose eyesite is less than ideal,
+;; might find additional contrast helpful.
+;; ===========================================================================================
+(defface dmode-font-lock-keywords-face
+ '((((class color) (background light)) (:foreground "green4"))
+ (((class color) (background dark)) (:foreground "yellow"))
+ (((class grayscale) (background light)) (:foreground "dimgray" :italic t))
+ (((class grayscale) (background dark)) (:foreground "lightgray" :italic t))
+ (t (:bold t)))
+ "sample font lock mode face used to highlight
+ a syntax group for the derived mode."
+ :group 'font-lock-faces)
+(defvar dmode-font-lock-keywords-face 'dmode-font-lock-keywords-face)
+;; ==========================================================================
+;; Using 'regexp-opt, construct a regular expression from a list of keywords
+;; that will be highlight with our sample face above.
+;; ==========================================================================
+(defconst
+ dmode-keywords-regexp
+ (regexp-opt '( ;; c-h f regexp-opt <ret>
+ ;; list of keywords here
+ )))
+;; ==========================================================================
+(defvar dmode-font-lock-keywords
+ `(,@parent-font-lock-keywords ;; note: backquote and splice operator!
+ ;; add new keywords for highlighting in our sample face
+ (,(concat "\\<\\(" dmode-keywords-regexp "\\)\\>") ;; keywords + word boundaries
+ 0 dmode-font-lock-keywords-face)
+ ;; To illustrate the use of a string literal regex:
+ ;; add braces "{}" for multi-line strings to an existing face
+ ;; NOTE: emacs does not handle multi-line string well in this manner.
+ ;; (JB) suggests looking at how perl and AUCTex handle this.
+ ("[^#]\\({[^{}]*}\\)" 0 'font-lock-string-face)
+ )
+ "List of dmode keywords and faces.")
+;; ==========================================================================
+;; Construct a keymap for the mode.
+;; Traditionally, Emacs reserves Control-c for a major mode prefix.
+;; However, in case the parent mode has already made extensive use of the
+;; Control-c prefix, I illustrate the alternative of Control-=
+;; ==========================================================================
+(defvar dmode-mode-map
+ (let ((map (make-sparse-keymap))) ;; c-h make-sparse-keymap <RET>
+ ;; Here we may define any number of key sequences for our mode
+ ;; c-h define-key <RET>
+ (define-key map [(control =) (b)] 'dmode-test-fun)
+ map)
+ "Keymap for `dmode-mode'.")
+;; ==========================================================================
+;; Just a sample function to test the menu and key definition.
+;; ==========================================================================
+(defun dmode-test-fun()
+ "Use to test keymapping and menu"
+ (interactive)
+ (message-box "Hello World from dmode-mode."))
+;; ==========================================================================
+;; Define the menu using 'easy-menu-define for
+;; best compatibility for both forks.
+;; ==========================================================================
+(easy-menu-define ;; c-h f easy-menu-define <RET>
+ ;; symbol----keymap---------documentation
+ ;; | | |
+ dmode-menu dmode-mode-map "dmode Mode Menu"
+ ;; menu:
+ '("dmode" ;; Title
+ ;; Item(s) .....
+ ;; name, callback
+ ["Test" dmode-test-fun])
+ )
+;; ==========================================================================
+(define-derived-mode dmode-mode parent-mode "dmode"
+ "A major mode for dmode."
+ (easy-menu-add dmode-menu)
+ ;; Highly Recommended: c-h v font-lock-keywords <RET>
+ (set (make-local-variable 'font-lock-defaults)
+ (cons 'dmode-font-lock-keywords
+ (or (cdr font-lock-defaults)
+ '(nil t ;; syntax table modifications follow: You may wish to use
+ ;; the table from the parent mode, and add to
+ ;; if necessary.
+ ;; For help: C-h f modify-syntax-entry <RET>
+ ;; In this example, we bind non-alpha characters to the 'word' syntax class
+ ((?+ . "w") (?- . "w") (?* . "w") (?/ . "w")
+ (?. . "w") (?< . "w") (?> . "w") (?= . "w")
+ (?? . "w") (?$ . "w") (?% . "w") (?_ . "w")
+ (?& . "w") (?~ . "w") (?^ . "w") (?: . "w"))))))
+ ;; NOTE: Emacs accepts a more compact approach.
+ ;; The cons-cell list approach used here is for XEmacs compatibility.
+ ;; Thanks to (JB)!
+ ;; *AND* remember! This is just an example!
+ ;; ========================================
+ )
+;;; dmode.el ends here
Oops, something went wrong. Retry.

0 comments on commit 837fb6c

Please sign in to comment.