emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 02/05: * omn-mode.el: Fix up copyright notice, plus minor cleanup


From: Phillip Lord
Subject: [elpa] 02/05: * omn-mode.el: Fix up copyright notice, plus minor cleanup. (omn-obsolete-electric-indent): New var. (omn-mode-map): Obey it. (omn-mode-entity-keywords, omn-mode-property-keywords): Move before use to satisfy the byte-compiler. (omn-determine-line-indent): Don't save-match-data for no reason. (auto-mode-alist): Use \\' to match end of file name. (omn-font-lock-defaults): Use regexp-opt. (omn-mode-syntax-table): Don't use "w" syntax for "_". (omn-mode): Move make-local-variables to their corresponding setq. Set electric-indent-chars.
Date: Mon, 20 Oct 2014 20:36:03 +0000

phillord pushed a commit to branch externals/omn-mode
in repository elpa.

commit 777105fdd5d5cd203e37fab98a6f08afc7637cd8
Author: Stefan Monnier <address@hidden>
Date:   Thu Apr 11 11:18:20 2013 -0400

    * omn-mode.el: Fix up copyright notice, plus minor cleanup.
    (omn-obsolete-electric-indent): New var.
    (omn-mode-map): Obey it.
    (omn-mode-entity-keywords, omn-mode-property-keywords): Move before use to
    satisfy the byte-compiler.
    (omn-determine-line-indent): Don't save-match-data for no reason.
    (auto-mode-alist): Use \\' to match end of file name.
    (omn-font-lock-defaults): Use regexp-opt.
    (omn-mode-syntax-table): Don't use "w" syntax for "_".
    (omn-mode): Move make-local-variables to their corresponding setq.
    Set electric-indent-chars.
---
 omn-mode.el |  267 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 130 insertions(+), 137 deletions(-)

diff --git a/omn-mode.el b/omn-mode.el
index 0bcba12..accd68c 100644
--- a/omn-mode.el
+++ b/omn-mode.el
@@ -1,19 +1,16 @@
-;; omn-mode.el --- Support for OWL Manchester Syntax
+;; omn-mode.el --- Support for OWL Manchester Notation
 
-;; Version: 1.0
-
-;; This file is not part of Emacs
+;; Copyright (C) 2013  Free Software Foundation, Inc.
 
 ;; Author: Phillip Lord <address@hidden>
 ;; Maintainer: Phillip Lord <address@hidden>
 ;; Website: http://www.russet.org.uk/blog
+;; Version: 1.0
 
-;; COPYRIGHT NOTICE
-;;
 ;; This program 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 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,122 +18,121 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA. 
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 ;;
-;; Defines a major mode for editing the Manchester OWL syntax
-;; Basically, this is just a bit of font locking. 
+;; Defines a major mode for editing the Manchester OWL syntax.
+;; Basically, this is just a bit of font locking.
+
+;;; Code:
 
+;; (defgroup omn-mode nil
+;;   "Major mode to edit OWL Manchester Notation."
+;;   :group 'languages)
 
+(defvar omn-obsolete-electric-indent nil
+  "Set to t to use the old electric indent.  Better use 
`electric-indent-mode'.")
 
-   
 (defvar omn-imenu-generic-expression
   '(
     ("Class"  "Class: \\([a-zA-Z:_]+\\)" 1)
     ("ObjectProperty" "ObjectProperty: \\([a-zA-Z:_]+\\)" 1)
     ("Individual" "Individual: \\([a-zA-Z:_]+\\)" 1)
     )
-    
-  "Add support for imenu in omn
 
+  "Imenu support for OMN.
 See `imenu-generic-expression' for details")
 
 
+(defvar omn-mode-entity-keywords
+  '(
+    "Ontology:"
+    "Namespace:"
+    "Class:"
+    "Individual:"
+    "ObjectProperty:"
+    "Import:"
+    "Datatype:"
+    "AnnotationProperty:"
+    "DisjointClasses:"
+    "Prefix:"
+    "Alias:"
+    "owl:Thing"))
+
+(defvar omn-mode-property-keywords
+  '(
+    "EquivalentTo:"
+    "SubClassOf:"
+    "Annotations:"
+    "Characteristics:"
+    "DisjointUnion:"
+    "DisjointWith:"
+    "Domain:"
+    "Range:"
+    "InverseOf:"
+    "SubPropertyOf:"
+    "Types:"
+    "Facts:"
+    ))
+
+
 ;; indentation engine
 (defun omn-indent-line()
-  (indent-line-to 
+  (indent-line-to
    (omn-determine-line-indent)))
 
 (defun omn-determine-line-indent()
   (save-excursion
     (beginning-of-line)
-    (save-match-data
-      ;; check the first word
-      
-      (let* ((match (re-search-forward "\\w+" (line-end-position) t))
-             (word (if match 
-                       (match-string 0)
-                     "")))
-                     
+    ;; check the first word
+
+    (let* ((match (re-search-forward "\\w+" (line-end-position) t))
+           (word (if match
+                     (match-string 0)
+                   "")))
+
+      (cond
+       ;; ((not match)
+       ;;  (progn
+       ;;    (if (not (forward-line -1))
+       ;;        (omn-determine-line-indent)
+       ;;      0)))
+
+       ;; if it is string, ident should be 0.
+       ((nth 3 (syntax-ppss (point)))
+        0)
+
+       ;; if it is a comment
+       ((nth 4 (syntax-ppss (point)))
+        ;; if there is a next line, indent the same as that
         (cond
-         ;; ((not match)
-         ;;  (progn 
-         ;;    (if (not (forward-line -1))
-         ;;        (omn-determine-line-indent)
-         ;;      0)))
-                
-         ;; if it is string, ident should be 0.
-         ((nth 3 (syntax-ppss (point)))
-          0)
-   
-         ;; if it is a comment
-         ((nth 4 (syntax-ppss (point)))
-          ;; if there is a next line, indent the same as that
-          (cond
-           ((eq 0 (forward-line 1))
-            (omn-determine-line-indent))
-           ;; if there isn't return the same as the line before
-           ((eq 0 (forward-line -1))
-            (omn-determine-line-indent))
-           ;; who knows?
-           (t 0)))
-         
-         ;; if it is one of Class:, Prefix: or so on, then indent should be 0
-         ((member word omn-mode-entity-keywords)
-          0)
-         ;; if it is Annotations:, SubClassOf: or so on, then indent should be 
4
-         ((member word omn-mode-property-keywords)
-          4)
-
-         ;; if it is something else, then 8
-         (t 8))))))
+         ((eq 0 (forward-line 1))
+          (omn-determine-line-indent))
+         ;; if there isn't return the same as the line before
+         ((eq 0 (forward-line -1))
+          (omn-determine-line-indent))
+         ;; who knows?
+         (t 0)))
 
+       ;; if it is one of Class:, Prefix: or so on, then indent should be 0
+       ((member word omn-mode-entity-keywords)
+        0)
+       ;; if it is Annotations:, SubClassOf: or so on, then indent should be 4
+       ((member word omn-mode-property-keywords)
+        4)
 
-(defvar omn-mode-entity-keywords
-  '( 
-   "Ontology:"
-   "Namespace:"
-   "Class:"
-   "Individual:"
-   "ObjectProperty:"
-   "Import:"
-   "Datatype:"
-   "AnnotationProperty:"
-   "DisjointClasses:"
-   "Prefix:"
-   "Alias:"
-   "owl:Thing"))
-  
-(defvar omn-mode-property-keywords
-  '(
-        "EquivalentTo:"
-        "SubClassOf:"
-        "Annotations:"
-        "Characteristics:"
-        "DisjointUnion:"
-        "DisjointWith:"
-        "Domain:"
-        "Range:"
-        "InverseOf:"
-        "SubPropertyOf:"
-        "Types:"
-        "Facts:"
-        ))
-
-(add-to-list 'auto-mode-alist
-             '("\\.pomn$" . omn-mode))
-
-(add-to-list 'auto-mode-alist
-             '("\\.omn$" . omn-mode))
+       ;; if it is something else, then 8
+       (t 8)))))
+
+(add-to-list 'auto-mode-alist '("\\.pomn\\'" . omn-mode))
+
+(add-to-list 'auto-mode-alist '("\\.omn\\'" . omn-mode))
 
 (defvar omn-font-lock-defaults
-  `(,
-    (concat "\\_<" 
-            (regexp-opt omn-mode-entity-keywords t)
-            "\\_>")
+  `(,(concat "\\_<"
+             (regexp-opt omn-mode-entity-keywords t)
+             "\\_>")
     (,(mapconcat
        (lambda(x) x)
        '("\\<some\\>"
@@ -148,14 +144,10 @@ See `imenu-generic-expression' for details")
          )
        "\\|")
      . font-lock-type-face)
-    (
-     ,(mapconcat
-       (lambda(x) x)
-       omn-mode-property-keywords
-       "\\|")
+    (,(regexp-opt omn-mode-property-keywords)
      . font-lock-builtin-face)
     ("\\w+:\\w+" . font-lock-function-name-face)))
-    
+
 
 (defvar omn-mode-syntax-table
   (let ((st (make-syntax-table)))
@@ -166,18 +158,29 @@ See `imenu-generic-expression' for details")
     ;; which is no bad thing. Additionally, it makes the comment character
     ;; work, as "#" is a valid in a URL. The semantics of this isn't quite
     ;; right, because the two characters are not paired. So <url> is
-    ;; recognised, but so is <url< or >url>
+    ;; recognised, but so is <url< or >url>.
+    ;; We could use a syntax-propertize-function to do more carefully.
     (modify-syntax-entry ?\< "|" st)
     (modify-syntax-entry ?\> "|" st)
     ;; define comment characters for syntax
     (modify-syntax-entry ?\# "<" st)
     (modify-syntax-entry ?\n ">" st)
-    ;; underscores are valid separators in "words"
-    (modify-syntax-entry ?\_ "w" st)
-    ;; for name space prefixs
+    ;; Let's not confuse "words" and "symbols": "_" should not be part of the
+    ;; definition of a "word".
+    ;;(modify-syntax-entry ?\_ "w" st)
+    ;; For name space prefixes.
     (modify-syntax-entry ?\: "w" st)
     st))
 
+(defvar omn-mode-map
+  (let ((map (make-sparse-keymap)))
+    (when omn-obsolete-electric-indent
+      (dolist (x `(" " "," ":"))
+        (define-key map x 'omn-mode-electric-indent))
+      ;; need to bind to return as well
+      (define-key map (kbd "RET") 'omn-mode-electric-newline))
+    map))
+
 (defun omn-mode-electric-indent()
   (interactive)
   (self-insert-command 1)
@@ -202,43 +205,33 @@ See `imenu-generic-expression' for details")
   (setq font-lock-defaults
         '(omn-font-lock-defaults))
 
-  (make-local-variable 'comment-start)
-  (make-local-variable 'comment-end)
-  (make-local-variable 'comment-start-skip)
-  ;; set up commenting
-  (setq comment-start "#")
-  (setq comment-end "")
+  (set (make-local-variable 'comment-start) "#")
+  (set (make-local-variable 'comment-end) "")
   ;; no idea what this is about -- stolen from generic
-  (setq comment-start-skip "#+\\s-*")
-
-  (set-syntax-table omn-mode-syntax-table)
-  
-  (setq imenu-generic-expression omn-imenu-generic-expression)
-
-  (make-local-variable 'indent-line-function)
-  (setq indent-line-function 'omn-indent-line))
-
-
-;; need to bind to return as well
-(mapc
- (lambda(x)
-   (define-key omn-mode-map x 'omn-mode-electric-indent))
- `(" " "," ":"))
-
-(define-key omn-mode-map (kbd "RET") 'omn-mode-electric-newline)
-
+  (set (make-local-variable 'comment-start-skip) "#+\\s-*")
 
+  (set (make-local-variable 'imenu-generic-expression)
+       omn-imenu-generic-expression)
 
+  (set (make-local-variable 'electric-indent-chars)
+       (append `(?\  ?\, ?\:)
+               (if (boundp 'electric-indent-chars)
+                   (default-value 'electric-indent-chars)
+                 '(?\n))))
+  
+  (set (make-local-variable 'indent-line-function) 'omn-indent-line))
 
-(provide 'omn-mode)
 
 ;; interaction with a reasoner.....
-;; Define a struct using CL, which defines a command. Then send this to the 
command line 
-;; program as a single key-value pair line. 
-;; 
+;; Define a struct using CL, which defines a command. Then send this to the 
command line
+;; program as a single key-value pair line.
+;;
 ;; Write a parser for this in Java.
-;; Write a "command" interface, use annotation to mark each of the command 
setMethods. 
-;; 
+;; Write a "command" interface, use annotation to mark each of the command 
setMethods.
+;;
 ;; Have the command interface return results between tags as lisp. We can eval
-;; this, and get the result in that way. 
+;; this, and get the result in that way.
+
+(provide 'omn-mode)
 
+;;; omn-mode.el ends here



reply via email to

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