/nmcobol-mode.el
Emacs Lisp | 2162 lines | 1677 code | 166 blank | 319 comment | 78 complexity | 794f099dbe49df543a16b2714595bad2 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- ;;; nmcobol-mode.el --- For use with Tandem Cobol only - Sorry.
- ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
- ;; Author: Rick Bielawski <rbielaws@i1.net>
- ;; Keywords: languages, COBOL, Tandem, Guardian, NSK
- ;; Maintainer: Rick Bielawski <rbielaws@i1.net>
- ;; This file 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.
- ;; This file 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; see the file COPYING. If not, write to the
- ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- ;; Boston, MA 02110-1301, USA.
- ;;; Commentary:
- ;; NMCOBOL -- COmmon Business Oriented Language - in ?TANDEM line format.
- ;; This is currently a work-in-progress. You are welcome to try it and
- ;; submit changes or report bugs but there is no point trying to report
- ;; lack of features unless you are including patches that address such
- ;; shortcomings.
- ;;
- ;; Since Tandem's line format is not standard this mode is not likely to
- ;; suit the needs of most Cobol progammers. Moreover, Tandem Cobol has
- ;; extensions that standard Cobol doesn't have and may not implement
- ;; features required or generally available by other Cobol compilers.
- ;; I'm happy to add submitted patches to support other compilers only if
- ;; such patches don't interfere with support of Tandem Cobol.
- ;;; Installing:
- ;; Before you can use nmcobol-mode, emacs needs to be able to find it. Place
- ;; the nmcobol-mode.el file in a directory on the load-path; typically the
- ;; .../site-lisp or perhaps .../lisp/progmods directory. Usually you would
- ;; also want to byte compile nmcobol-mode.el but this is not required. To do
- ;; this, visit the nmcobol-mode.el file, type: M-x emacs-lisp-byte-compile <ret>
- ;; There should be no warnings or errors during byte compilation.
- ;;
- ;; There are 4 basic ways to use NMCOBOL-MODE on a file. The first method
- ;; manually selects nmcobol-mode as the editing mode. The other 3 cause emacs
- ;; to recognize automatically that you want to visit the file using
- ;; nmcobol-mode.
- ;;
- ;; Pick one:
- ;; 1. While visiting a file, type: M-x nmcobol-mode <ret>
- ;; 2. Put the string -*-nmcobol-*- in a comment on the first line of the file.
- ;; Save the file and close it. Now any time you open it nmcobol-mode starts.
- ;; 3. Create an association between a particular file naming convention and
- ;; nmcobol-mode. This is done by adding an association to auto-mode-alist.
- ;; For example:
- ;; (setq auto-mode-alist
- ;; (append
- ;; '(("\\.cob\\'" . nmcobol-mode) ;extension of .cob means nmcobol-mode
- ;; ("\\([\\/]\\|^\\)[^.]+$" . nmcobol-mode)) ;so does no extension at all.
- ;; auto-mode-alist))
- ;; 4. Advise set-auto-mode to look at the buffer contents upon loading.
- ;; For an example see: http://www.emacswiki.org/cgi-bin/wiki/TandemNskSupport
- ;;
- ;; The above all tell emacs that you want to use nmcobol-mode but you must load
- ;; nmcobol-mode before you can use it. There are 2 methods of telling emacs to
- ;; load the nmcobol-mode routines. The first unconditionally loads nmcobol-mode
- ;; definitions immediately. The second tells emacs to automatically load
- ;; nmcobol-mode only when you try to use it. Add one of the following lines to
- ;; your .emacs file.
- ;;
- ;;(require 'nmcobol-mode) ; Unconditional load
- ;;(autoload 'nmcobol-mode "nmcobol-mode" "Major mode for Tandem NMCOBOL files." t nil)
- ;;
- ;;; Getting eldoc to work in nmcobol-mode:
- ;; Open a file containing variable declarations for which you want
- ;; help permanently loaded. For example: $SYSTEM.COPYLIBS.COBOLLIB.
- ;; The buffer must be in nmcobol-mode or ddl-mode.
- ;; Use: M-x nmcobol-mode <ret> if necessary.
- ;; Then: M-x nmcobol-eldoc-make-list <ret>
- ;; You should now be in a specially formatted buffer containing a list of
- ;; the variables declared and their corresponding help strings. You can
- ;; modify the strings themselves if desired but do not alter anything
- ;; else. Repeat these steps to add more help entries to the file.
- ;; Save the file somewhere on your search list like your site-lisp
- ;; directory. Example:
- ;; C-x C-w ~/../site-lisp/extdecs-help.el <ret>
- ;; Now add the file you just saved to the list of nmcobol-mode eldoc help
- ;; files to be loaded.
- ;; M-x customize-option <ret> nmcobol-eldoc-def-files <ret>
- ;; Save the customization for future sessions.
- ;; Once you have your help entries defined see help for eldoc-mode for
- ;; turing on the mode. Putting (eldoc-mode t) in .emacs might do it.
- ;;; History:
- ;; 2006-11-07 RGB Started writing this mode using my cobol-mode as skeleton.
- ;; 2006-12-18 RGB Added eldoc support.
- ;; 2006-12-26 RGB Added nmcobol-addup-pics.
- ;; 2006-12-27 RGB Added thing-at-point support for Guardian style 'filename.
- ;; 2006-12-29 RGB Added an NMCobol menu and nmcobol-customize-options.
- ;; 2007-01-03 RGB Added movement by sentences.
- ;; 2007-01-04 RGB Fixed movement by sentences, added paragraphs.
- ;; 2007-01-04 RGB Make COUNT argument in movement by functions optional.
- ;; 2007-01-09 RGB Added eldoc for variables including a buffer-local obarray.
- ;; 2007-01-10 RGB Added Cobol specific support for anchored-transpose.
- ;; 2007-01-11 RGB Fixed 66 level handling in paragraph movement and eldoc-scan.
- ;; 2007-01-28 RGB Sentence/Paragraph movement now saves match data.
- ;; 2007-01-31 RGB Started adding automatic indentation.
- ;; 2007-02-01 RGB Made * electric.
- ;; 2007-02-05 RGB Auto-indent now operates on regions
- ;; 2007-02-07 RGB Fixed customization of nmcobol-keywords-case &
- ;; nmcobol-imenu-menubar. Fixed nmcobol-pic-string-regexp
- ;; not recognizing 'ZZZ-.' syntax. Fixed
- ;; nmcobol-char-maybe-comment which broke numeric
- ;; prefix behavior. Doc-string updates.
- ;; 2007-02-12 RGB Indentation now handles all the block statements properly.
- ;; 2007-02-13 RGB The beginning of secondary indentation started. This
- ;; handles alignment of things like picture clauses, TO
- ;; statements etc.
- ;; 2007-02-19 RGB imenu now ignores xxxx-exit paragraphs. Started trying
- ;; to implement paren matching on end-<verb> keywords.
- ;; 2007-02-22 RGB nmcobol-get-block-type now ignores keywords in strings.
- ;;; Code:
- (defgroup nmcobol nil
- "Major mode for editing NMCOBOL source files in Emacs.
- While in nmcobol-mode use C-h m for a description of the mode's features."
- :prefix 'nmcobol-
- :group 'languages)
- ;;; SYNTAX TABLE
- (defvar nmcobol-mode-syntax-table
- (let ((st (make-syntax-table)))
- (modify-syntax-entry ?\n " " st)
- (modify-syntax-entry ?\! "." st)
- (modify-syntax-entry ?\" "." st) ; wiki ?" bug workaround comment
- (modify-syntax-entry ?\# "w" st)
- (modify-syntax-entry ?\$ "w" st)
- (modify-syntax-entry ?\% "'" st)
- (modify-syntax-entry ?\& "'" st)
- (modify-syntax-entry ?\' "." st)
- (modify-syntax-entry ?\( "()" st)
- (modify-syntax-entry ?\) ")(" st)
- (modify-syntax-entry ?\* "." st)
- (modify-syntax-entry ?\+ "." st)
- (modify-syntax-entry ?\, "." st)
- (modify-syntax-entry ?\- "w" st)
- (modify-syntax-entry ?\. "." st)
- (modify-syntax-entry ?\/ "." st)
- (modify-syntax-entry ?\: "." st)
- (modify-syntax-entry ?\; "." st)
- (modify-syntax-entry ?\< "." st)
- (modify-syntax-entry ?\= "." st)
- (modify-syntax-entry ?\> "." st)
- (modify-syntax-entry ?\? "." st)
- (modify-syntax-entry ?\@ "." st)
- (modify-syntax-entry ?\[ "(]" st)
- (modify-syntax-entry ?\\ "." st)
- (modify-syntax-entry ?\] ")[" st)
- (modify-syntax-entry ?^ "w" st)
- (modify-syntax-entry ?\_ "w" st)
- (modify-syntax-entry ?\{ "(}" st)
- (modify-syntax-entry ?\| "." st)
- (modify-syntax-entry ?\} "){" st)
- st)
- "Syntax table for `nmcobol-mode'.")
- ;;; KEY MAP
- (defvar nmcobol-skeleton-map
- (let ((map (make-sparse-keymap)))
- (define-key map [?i] 'nmcobol-if-skel)
- (define-key map [?p] 'nmcobol-paragraph-skel)
- map)
- "Keymap for `nmcobol-mode'.")
- (defvar nmcobol-eldoc-map
- (let ((map (make-sparse-keymap)))
- (define-key map [?m] 'nmcobol-eldoc-make-list)
- (define-key map [?s] 'nmcobol-eldoc-scan-buffer)
- (define-key map [?v] 'nmcobol-eldoc-visit-file)
- (define-key map [?w] 'nmcobol-eldoc-where-def)
- map)
- "Keymap for `nmcobol-mode'.")
- (defvar nmcobol-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map [tab] 'indent-according-to-mode)
- (define-key map [?\C-c ?\C-c] 'column-marker-here)
- (define-key map [?\C-c ?\C-e] nmcobol-eldoc-map)
- (define-key map [?\C-c ?\C-f] 'auto-fill-mode)
- (define-key map [?\C-c ?\C-o] 'nmcobol-customize-options)
- (define-key map [?\C-c ?\C-r] 'popup-ruler)
- (define-key map [?\C-c ?\C-s] nmcobol-skeleton-map)
- (define-key map [?\C-c ?=] 'nmcobol-addup-pics)
- (define-key map [?\C-c return] 'comment-indent-new-line)
- (define-key map [?*] 'nmcobol-char-maybe-comment)
- (define-key map [?/] 'nmcobol-char-maybe-comment)
- map)
- "Keymap for `nmcobol-mode'.")
- (defun nmcobol-setup-menu ()
- "Adds a menu of NMCOBOL specific functions to the menu bar."
- (define-key (current-local-map) [menu-bar nmcobol-menu]
- (cons "NMCobol" (make-sparse-keymap "NMCobol")))
- (define-key (current-local-map) [menu-bar nmcobol-menu customize]
- '(menu-item "Customize" nmcobol-customize-options
- :key-sequence [?\C-c ?\C-o]
- :help "Customize nmcobol-mode options"))
- (define-key (current-local-map) [menu-bar nmcobol-menu comment-eol]
- '(menu-item "Comment EOL" comment-indent-new-line
- :key-sequence [?\C-c return]
- :help "Continues comment on new line"))
- (if (featurep 'column-marker)
- (define-key (current-local-map) [menu-bar nmcobol-menu column]
- '(menu-item "Column Marker" column-marker-here
- :key-sequence [?\C-c ?\C-c]
- :help "Puts column marker at current column (C-u removes)")))
- (define-key (current-local-map) [menu-bar nmcobol-menu ruler]
- '(menu-item "Ruler" popup-ruler
- :key-sequence [?\C-c ?\C-r]
- :help "Inserts temporary ruler"))
- (define-key (current-local-map) [menu-bar nmcobol-menu eldoc-show]
- '(menu-item "Eldoc Where" nmcobol-eldoc-where-def
- :key-sequence [?\C-c ?\C-e ?w]
- :help "Shows Where function at point is defined"))
- (define-key (current-local-map) [menu-bar nmcobol-menu eldoc-visit]
- '(menu-item "Eldoc Visit" nmcobol-eldoc-visit-file
- :key-sequence [?\C-c ?\C-e ?v]
- :help "Visits file defining function at point"))
- (define-key (current-local-map) [menu-bar nmcobol-menu eldoc-update]
- '(menu-item "Eldoc Scan" nmcobol-eldoc-scan-buffer
- :key-sequence [?\C-c ?\C-e ?s]
- :help "Updates buffer-local eldoc entries (in memory)"))
- (define-key (current-local-map) [menu-bar nmcobol-menu eldoc-create]
- '(menu-item "Eldoc Make List" nmcobol-eldoc-make-list
- :key-sequence [?\C-c ?\C-e ?m]
- :help "Puts current file eldoc entries in a file."))
- (define-key (current-local-map) [menu-bar nmcobol-menu skeletons]
- (cons "Skeletons" (make-sparse-keymap "Skeletons")))
- (define-key (current-local-map) [menu-bar nmcobol-menu skeletons if]
- '(menu-item "If Then" nmcobol-if-skel
- :key-sequence [?\C-c ?\C-s ?i]
- :help "Inserts an If/Then statement"))
- (define-key (current-local-map) [menu-bar nmcobol-menu skeletons paragraph]
- '(menu-item "New Paragraph" nmcobol-paragraph-skel
- :key-sequence [?\C-c ?\C-s ?p]
- :help "Inserts comment bars for new paragraph name")))
- ;; All keyword lists get sorted so new words can be anywhere within the
- ;; appropriate list. The keywords are currently only used for highlighting but
- ;; more uses such as abbrev-mode are in progress.
- (defvar nmcobol-keywords-directives ;font-lock-preprocessor-face
- '( "ANSI" "BLANK" "CALL-SHARED" "CANCEL"
- "CHECK" "CODE" "COLUMNS" "COMPACT"
- "COMPILE" "CONSULT" "CROSSREF" "DIAGNOSE-74"
- "DIAGNOSE-85" "DIAGNOSEALL" "ENDIF" "ENDUNIT"
- "ENV" "ERRORFILE" "ERRORS" "FIPS"
- "FMAP" "HEADING" "HEAP" "HIGHPIN"
- "HIGHREQUESTERS" "ICODE" "IF" "IFNOT"
- "INNERLIST" "INSPECT" "LARGEDATA" "LD"
- "LESS-CODE" "LIBRARY" "LINES" "LIST"
- "LMAP" "MAIN" "MAP" "NLD"
- "NOBLANK" "NOCANCEL" "NOCODE" "NOCOMPACT"
- "NOCONSULT" "NOCROSSREF" "NODIAGNOSE-74" "NODIAGNOSE-85"
- "NODIAGNOSEALL" "NOFIPS" "NOICODE" "NOINNERLIST"
- "NOINSPECT" "NOLIST" "NOLMAP" "NOMAP"
- "NON-SHARED" "NONSTOP" "NOPORT" "NOSAVEABEND"
- "NOSEARCH" "NOSHOWCOPY" "NOSHOWFILE" "NOSQL"
- "NOSUPPRESS" "NOSYMBOLS" "NOTRAP2" "NOTRAP2-74"
- "NOWARN" "OPTIMIZE" "PERFORM-TRACE" "PORT"
- "RESETTOG" "RUNNABLE" "RUNNAMED" "SAVE"
- "SAVEABEND" "SEARCH" "SECTION" "SETTOG"
- "SHARED" "SHOWCOPY" "SHOWFILE" "SOURCE"
- "SQL" "SQLMEM" "SUBSET" "SUBTYPE"
- "SUPPRESS" "SYMBOLS" "SYNTAX" "TANDEM"
- "TRAP2" "TRAP2-74" "UL" "WARN")
- "List of NMCOBOL compiler directives.
- Used to create the `font-lock-keywords' table.")
- (defvar nmcobol-keywords-imperatives
- '( "ACCEPT" "DISPLAY" "MULTIPLY" "STOP"
- "ADD" "DIVIDE" "OPEN" "STRING"
- "ALTER" "ENTER" "PERFORM" "SUBTRACT"
- "CALL" "EXIT" "READ" "UNLOCKFILE"
- "CANCEL" "GO TO" "RELEASE" "UNLOCKRECORD"
- "INITIALIZE" "REWRITE" "UNSTRING" "CLOSE"
- "INSPECT" "SET" "WRITE" "COMPUTE"
- "LOCKFILE" "SORT" "CONTINUE" "MERGE"
- "START" "DELETE" "MOVE")
- "List of NMCOBOL keywords identifying an imperative statement.
- Used by indentation routines in their determination of such."
- )
- (defvar nmcobol-block-keywords
- '("ADD" "COMPUTE" "DELETE" "DIVIDE"
- "EVALUATE" "IF" "MULTIPLY" "PERFORM"
- "READ" "REWRITE" "SEARCH" "START"
- "STRING" "SUBTRACT" "UNSTRING" "WRITE"
- )
- "A list of words that should have open paren syntax - conditionally.
- `nmcobol-get-block-type' determines if they actually require the
- END-<word> statement." )
- (defvar nmcobol-keywords-statements ;font-lock-keyword-face
- '("ACCEPT" "ADD" "ALTER" "CALL"
- "CANCEL" "CHECKPOINT" "CLOSE" "COMPUTE"
- "CONTINUE" "COPY" "DELETE" "DISPLAY"
- "DIVIDE" "ELSE" "END" "END-ADD"
- "END-COMPUTE" "END-DELETE" "END-DIVIDE" "END-EVALUATE"
- "END-IF" "END-MULTIPLY" "END-OF-PAGE" "END-PERFORM"
- "END-READ" "END-RECEIVE" "END-RETURN" "END-REWRITE"
- "END-SEARCH" "END-START" "END-STRING" "END-SUBTRACT"
- "END-UNSTRING" "END-WRITE" "ENTER COBOL" "ENTER"
- "EVALUATE" "EXIT" "FD" "FILE"
- "GO TO" "IF" "INITIALIZE" "INSPECT"
- "LOCKFILE" "MERGE" "MOVE" "MULTIPLY"
- "OPEN" "PERFORM" "READ" "RELEASE"
- "REPLACE" "RETURN" "REWRITE" "SD"
- "SEARCH" "SELECT" "SET" "SORT"
- "START" "STARTBACKUP" "STOP" "STRING"
- "SUBTRACT" "THEN" "UNLOCKFILE" "UNLOCKRECORD"
- "UNSTRING" "USE" "WHEN" "WRITE" )
- "List of NMCOBOL statement keywords.
- Used to create the `font-lock-keywords' table.")
- (defvar nmcobol-keywords-deprecated ;font-lock-warning-face
- '( "STARTBACKUP" "CHECKPOINT")
- "List of NMCOBOL keywords and Builtin functions now deprecated.
- Used to create the `font-lock-keywords' table")
- (defvar nmcobol-keywords-reserved ;font-lock-type-face
- '( "ACCEPT" "ACCESS" "ADD"
- "ADDRESS" "ADVANCING" "AFTER"
- "ALL" "ALPHABET" "ALPHABETIC"
- "ALPHABETIC-LOWER" "ALPHABETIC-UPPER" "ALPHANUMERIC"
- "ALPHANUMERIC-EDITED" "ALSO" "ALTER"
- "ALTERNATE" "AND" "ANY"
- "APPROXIMATE" "AREA" "AREAS"
- "ASCENDING" "ASSIGN" "AT"
- "AUTHOR" "BEFORE" "BINARY"
- "BLANK" "BLOCK" "BOTTOM"
- "BY" "CALL" "CANCEL"
- "CD" "CF" "CH"
- "CHARACTER" "CHARACTERS" "CHARACTER-SET"
- "CHECKPOINT" "CLASS" "CLOCK-UNITS"
- "CLOSE" "COBOL" "CODE"
- "CODE-SET" "COLLATING" "COLUMN"
- "COMMA" "COMMON" "COMMUNICATION"
- "COMP" "COMP-3" "COMP-5"
- "COMPUTATIONAL" "COMPUTATIONAL-3" "COMPUTATIONAL-5"
- "COMPUTE" "CONFIGURATION" "CONTAINS"
- "CONTENT" "CONTINUE" "CONTROL"
- "CONTROLS" "CONVERTING" "COPY"
- "CORR" "CORRESPONDING" "COUNT"
- "CURRENCY" "DATA" "DATE"
- "DATE-COMPILED" "DATE-WRITTEN" "DAY"
- "DAY-OF-WEEK" "DE" "DEBUG-CONTENTS"
- "DEBUG-ITEM" "DEBUG-LINE" "DEBUG-SUB-2"
- "DEBUG-SUB-3" "DEBUGGING" "DECIMAL-POINT"
- "DECLARATIVES" "DEBUG-NAME" "DEBUG-SUB-1"
- "DELETE" "DELIMITED" "DELIMITER"
- "DEPENDING" "DESCENDING" "DESTINATION"
- "DETAIL" "DISABLE" "DISPLAY"
- "DIVIDE" "DIVISION" "DOWN"
- "DUPLICATES" "DYNAMIC" "EGI"
- "ELSE" "EMI" "ENABLE"
- "END" "END-ADD" "END-COMPUTE"
- "END-DELETE" "END-DIVIDE" "END-EVALUATE"
- "END-IF" "END-MULTIPLY" "END-OF-PAGE"
- "END-PERFORM" "END-READ" "END-RECEIVE"
- "END-RETURN" "END-REWRITE" "END-SEARCH"
- "END-START" "END-STRING" "END-SUBTRACT"
- "END-UNSTRING" "END-WRITE" "ENTER"
- "EOP" "EQUAL" "ERROR"
- "ESI" "EVALUATE" "EVERY"
- "EXCEPTION" "EXCLUSIVE" "EXIT"
- "EXTEND" "EXTENDED-STORAGE" "EXTERNAL"
- "FALSE" "FD" "FILE"
- "FILE-CONTROL" "FILLER" "FINAL"
- "FIRST" "FOOTING" "FOR"
- "FROM" "FUNCTION" "GENERATE"
- "GENERIC" "GIVING" "GLOBAL"
- "GO" "GREATER" "GROUP"
- "GUARDIAN-ERR" "HEADING" "HIGH-VALUE"
- "HIGH-VALUES" "I-O" "I-O-CONTROL"
- "IDENTIFICATION" "IF" "IN"
- "INDEX" "INDEXED" "INDICATE"
- "INITIAL" "INITIALIZE" "INITIATE"
- "INPUT" "INPUT-OUTPUT" "INSPECT"
- "INSTALLATION" "INTO" "INVALID"
- "IS" "JUST" "JUSTIFIED"
- "KEY" "LABEL" "LAST"
- "LEADING" "LEFT" "LENGTH"
- "LESS" "LIMIT" "LIMITS"
- "LINAGE" "LINAGE-COUNTER" "LINE"
- "LINE-COUNTER" "LINKAGE" "LOCK"
- "LOCKFILE" "LOW-VALUE" "LOW-VALUES"
- "MEMORY" "MERGE" "MESSAGE"
- "MODE" "MODULES" "MOVE"
- "MULTIPLE" "MULTIPLY" "NATIVE"
- "NEGATIVE" "NEXT" "NO"
- "NOT" "NULL" "NULLS"
- "NUMBER" "NUMERIC" "NUMERIC-EDITED"
- "OBJECT-COMPUTER" "OCCURS" "OF"
- "OFF" "OMITTED" "ON"
- "OPEN" "OPTIONAL" "OR"
- "ORDER" "ORGANIZATION" "OTHER"
- "OUTPUT" "OVERFLOW" "PACKED-DECIMAL"
- "PADDING" "PAGE" "PAGE-COUNTER"
- "PERFORM" "PF" "PH"
- "PIC" "PICTURE" "PLUS"
- "POINTER" "POSITION" "POSITIVE"
- "PRINTING" "PROCEDURE" "PROCEDURES"
- "PROCEED" "PROGRAM" "PROGRAM-ID"
- "PROGRAM-STATUS" "PROGRAM-STATUS-1" "PROGRAM-STATUS-2"
- "PROMPT" "PROTECTED" "PURGE"
- "QUEUE" "QUOTE" "QUOTES"
- "RANDOM" "RD" "READ"
- "RECEIVE" "RECEIVE-CONTROL" "RECORD"
- "RECORDS" "REDEFINES" "REEL"
- "REFERENCE" "REFERENCES" "RELATIVE"
- "RELEASE" "REMAINDER" "REMOVAL"
- "RENAMES" "REPLACE" "REPLACING"
- "REPLY" "REPORT" "REPORTING"
- "REPORTS" "RERUN" "RESERVE"
- "RESET" "RETURN" "REVERSED"
- "REWIND" "REWRITE" "RF"
- "RH" "RIGHT" "ROUNDED"
- "RUN" "SAME" "SD"
- "SEARCH" "SECTION" "SECURITY"
- "SEGMENT" "SEGMENT-LIMIT" "SELECT"
- "SEND" "SENTENCE" "SEPARATE"
- "SEQUENCE" "SEQUENTIAL" "SET"
- "SHARED" "SIGN" "SIZE"
- "SORT" "SORT-MERGE" "SOURCE"
- "SOURCE-COMPUTER" "SPACE" "SPACES"
- "SPECIAL-NAMES" "STANDARD" "STANDARD-1"
- "STANDARD-2" "START" "STARTBACKUP"
- "STATUS" "STOP" "STRING"
- "SUB-QUEUE-1" "SUB-QUEUE-2" "SUB-QUEUE-3"
- "SUBTRACT" "SUM" "SUPPRESS"
- "SYMBOLIC" "SYNC" "SYNCDEPTH"
- "SYNCHRONIZED" "TABLE" "TAL"
- "TALLYING" "TAPE" "TERMINAL"
- "TERMINATE" "TEST" "TEXT"
- "THAN" "THEN" "THROUGH"
- "THRU" "TIME" "TIMES"
- "TO" "TOP" "TRAILING"
- "TRUE" "TYPE" "UNIT"
- "UNLOCK" "UNLOCKFILE" "UNLOCKRECORD"
- "UNSTRING" "UNTIL" "UP"
- "UPON" "USAGE" "USE"
- "USING" "VALUE" "VALUES"
- "VARYING" "WHEN" "WITH"
- "WORDS" "WORKING-STORAGE" "WRITE"
- "ZERO" "ZEROES")
- "List of NMCOBOL keywords reserved only in certain language contexts.
- Used to create the `font-lock-keywords' table.")
- (defvar nmcobol-keywords-std-fcns ;font-lock-keyword-face
- '( "ACOS" "ANNUITY" "ASIN"
- "ATAN" "CHAR" "COS"
- "CURRENT-DATE" "DATE-OF-INTEGER" "DAY-OF-INTEGER"
- "FACTORIAL" "INTEGER" "INTEGER-OF-DATE"
- "INTEGER-OF-DAY" "INTEGER-PART" "LENGTH"
- "LOG" "LOG10" "LOWER-CASE"
- "MAX" "MEAN" "MEDIAN"
- "MIDRANGE" "MIN" "MOD"
- "NUMVAL" "NUMVAL-C" "ORD"
- "ORD-MAX" "ORD-MIN" "PRESENT-VALUE"
- "RANDOM" "RANGE" "REM"
- "REVERSE" "SIN" "SQRT"
- "STANDARD-DEVIATION" "SUM" "TAN"
- "UPPER-CASE" "VARIANCE" "WHEN-COMPILED")
- "List of NMCOBOL standard functions.
- Used to create the `font-lock-keywords' table.")
- (defvar nmcobol-keywords-privileged ;font-lock-warning-face
- '( "END-EXEC" "EXEC")
- "List of NMCOBOL privileged functions.
- Used to create the `font-lock-keywords' table.")
- (defvar nmcobol-keywords-builtin ;font-lock-variable-name-face
- '( "#IN" "#OUT"
- "#TERM" "#TEMP"
- "#DYNAMIC" "COBOL85^ARMTRAP"
- "COBOL85^COMPLETION" "COBOL_COMPLETION_"
- "COBOL_CONTROL_" "COBOL_GETENV_"
- "COBOL_PUTENV_" "COBOL85^RETURN^SORT^ERRORS"
- "COBOL_RETURN_SORT_ERRORS_" "COBOL85^REWIND^SEQUENTIAL"
- "COBOL_REWIND_SEQUENTIAL_" "COBOL85^SET^SORT^PARAM^TEXT"
- "COBOL_SET_SORT_PARAM_TEXT_" "COBOL85^SET^SORT^PARAM^VALUE"
- "COBOL_SET_SORT_PARAM_VALUE_" "COBOL_SET_MAX_RECORD_"
- "COBOL_SETMODE_" "COBOL85^SPECIAL^OPEN"
- "COBOL_SPECIAL_OPEN_" "COBOLASSIGN"
- "COBOL_ASSIGN_" "COBOLFILEINFO"
- "COBOL_FILE_INFO_" "COBOLSPOOLOPEN"
- "CREATEPROCESS" "ALTERPARAMTEXT"
- "CHECKLOGICALNAME" "CHECKMESSAGE"
- "DELETEASSIGN" "DELETEPARAM"
- "DELETESTARTUP" "GETASSIGNTEXT"
- "GETASSIGNVALUE" "GETBACKUPCPU"
- "GETPARAMTEXT" "GETSTARTUPTEXT"
- "PUTASSIGNTEXT" "PUTASSIGNVALUE"
- "PUTPARAMTEXT" "PUTSTARTUPTEXT")
- "List of NMCOBOL privileged builtin functions.
- Used to create the `font-lock-keywords' table.")
- (defcustom nmcobol-block-always-keywords
- '("ELSE" "EVALUATE" "IF" "SEARCH" "THEN"
- "WHEN" )
- "List of keywords that always require and END-<word>. Used in paren matching."
- :type '(repeat (string :tag "word"))
- :group 'nmcobol)
- (defcustom nmcobol-keyword-section-names-regexp
- "^\\s-\\{1,3\\}\\(\\w+\\)\\s-+\\(division\\(\\s-+using\\s-+[^.\n]+\\)?\\|section\\) *\\."
- "Defines a regexp that finds the names of divisions & sections.
- Used to create the `font-lock-keywords' table."
- :type 'regexp
- :group 'nmcobol)
- (defcustom nmcobol-keyword-fcn-names-regexp
- "^\\s-\\{1,3\\}\\(\\w+\\)\\s-*\\."
- "Defines a regexp that finds the names of paragraphs.
- Used by `font-lock-keywords'. See also `nmcobol-imenu-fcn-names-regexp'"
- :type 'regexp
- :group 'nmcobol)
- ;;; Build keyword regexp from keyword lists
- (defvar nmcobol-keywords-imperatives-regexp ()
- "regexp matching `nmcobol-keywords-imperatives'")
- (defvar nmcobol-keywords-statements-regexp ()
- "regexp matching `nmcobol-keywords-statements'")
- (defvar nmcobol-keywords-reserved-regexp ()
- "regexp matching `nmcobol-keywords-reserved'")
- (defvar nmcobol-block-always-regexp ()
- "regexp matching `nmcobol-block-always-keywords'")
- (defvar nmcobol-block-begin-regexp ()
- "regexp matching `nmcobol-block-keywords'")
- (defvar nmcobol-block-end-regexp ()
- "regexp matching \"END-\" + `nmcobol-block-keywords'")
- (defvar nmcobol-non-cobol-regexp
- "^[*/?]"
- "Expression describing comment and compiler directive lines.")
- (defun nmcobol-setup-regexp-vars ()
- "Rebuilds regexp variables from keyword lists."
- (setq nmcobol-keywords-imperatives-regexp
- (concat (regexp-opt nmcobol-keywords-imperatives t) "\\(\\s-\\|\\.\\)")
- nmcobol-keywords-statements-regexp
- (concat "^\\([ \t]+\\)"
- (regexp-opt nmcobol-keywords-statements t) "\\(\\s-\\|\\.\\)")
- nmcobol-keywords-reserved-regexp ;not used!
- (nmcobol-keyword-anywhere-regexp nmcobol-keywords-reserved)
- nmcobol-block-always-regexp
- (concat (regexp-opt nmcobol-block-always-keywords t) "\\(\\s-\\|\\.\\)")
- nmcobol-block-begin-regexp
- (regexp-opt nmcobol-block-keywords t)
- nmcobol-block-end-regexp
- (concat "END-" (regexp-opt nmcobol-block-keywords t))))
- ;;; Font lock (highlighting)
- (defcustom nmcobol-font-lock-always t
- "`nmcobol-mode' makes sure `font-lock-mode' is on for nmcobol-mode buffers.
- Some things don't work if it's off so insuring it's on is the default."
- :type 'boolean
- :group 'nmcobol)
- (defcustom nmcobol-primecode-warning t
- "Highlight instances of ]a ]d and ]e in column 1 with a warning face.
- This alerts you that submission of this file to RMS/PrimeCode will fail
- due to invalid contents. nil disables this warning."
- :type 'boolean
- :group 'nmcobol)
- (defun nmcobol-keyword-special-regexp ( word-list )
- "Returns a regexp that finds any of the words in WORD-LIST.
- But only if the keyword is surrounded by non-word chars."
- (concat "\\W"(regexp-opt word-list t)"\\W"))
- (defun nmcobol-keyword-anywhere-regexp ( word-list )
- "Returns a regexp that finds any of the words in WORD-LIST.
- But only if the keyword is surrounded by non-word chars."
- (concat "\\b"(regexp-opt word-list t)"\\b"))
- ;; The next 4 def's work tightly together and, as coded, cannot be reused for
- ;; additional purposes.
- (defvar nmcobol-keyword-on-directive-line-regexp () "Internal use only.")
- (defun nmcobol-keyword-on-directive-line-regexp ( word-list )
- "Returns a function to find WORD-LIST only if line starts with ?"
- (setq nmcobol-keyword-on-directive-line-regexp
- (concat "\\b"(regexp-opt word-list t)"\\b"))
- 'nmcobol-font-lock-directive-line)
- (defvar nmcobol-amid-font-lock-excursion nil
- "Used by `nmcobol-font-lock-directive-line'. When a line starting with
- ? in column 1 is detected this variable holds the context needed to
- continue searching for more keywords. If nil a line starting with ?
- should be searched for.")
- (make-variable-buffer-local 'nmcobol-amid-font-lock-excursion)
- (defun nmcobol-font-lock-directive-line ( search-limit )
- "This function finds keywords only in lines starting with ?. Valid
- keywords are described by `nmcobol-keyword-on-directive-line-regexp'.
- First a line beginning with ? is searched for. Once found, point is
- moved to the beginning of that area and limit is set to the end.
- Keywords are searched for within that range. If found, context is saved
- in nmcobol-amid-font-lock-excursion and the match-data is returned. If
- not found, another line starting with ? is searched for. If saved
- context exists when this function is called then another keyword is
- searched for in the previously narrowed region. If none is found the
- next region is searched for."
- (let ((looking t))
- (while
- (and looking
- (or nmcobol-amid-font-lock-excursion
- (when (re-search-forward "^\\?.+\n" search-limit t)
- (setq nmcobol-amid-font-lock-excursion (point))
- (goto-char (match-beginning 0)))))
- (if (re-search-forward nmcobol-keyword-on-directive-line-regexp
- nmcobol-amid-font-lock-excursion t)
- (setq looking nil)
- (goto-char nmcobol-amid-font-lock-excursion)
- (setq nmcobol-amid-font-lock-excursion nil)))
- (not looking)))
- (defvar nmcobol-find-syntactic--state ()
- "Used by `nmcobol-find-syntactic-keywords' to find multiple syntactic
- elements which all must be anchored to the beginning of a line.
- nil = No searches on this line yet. skip line if it's a directive.
- 0 = look for sequence number in col 1-6 (removed)
- 1 = sequence/label area checked. look at body.
- 2 = body not a comment, any trailing comment marked, check for strings
- marker = terminated string found check for more.")
- (make-variable-buffer-local 'nmcobol-find-syntactic--state)
- (defun nmcobol-find-syntactic-keywords ( search-limit )
- "Used by `font-lock-syntactic-keywords' to find comments and strings.
- Returns t if either a comment or string is found, nil if neither is found.
- match-data 1&2 are set for comments, 3&4 are set for a normal string, 5&6 are
- set for eol-terminated strings. Where the match pair mark the start character
- and end character respectively. Point is moved to the next line during this
- function only after the last search completes for the current line. A state
- machine, controlled by `nmcobol-find-syntactic--state' sequences the searches."
- (let ((found nil)
- (save (point)))
- (while (and (< (point) search-limit)
- (not found))
- (cond
- ;; no comments or quotes? in compiler directives
- ((or (null nmcobol-find-syntactic--state)
- (equal nmcobol-find-syntactic--state (make-marker)))
- (if (looking-at "^\\?")
- (forward-line 1) ;do this state on next line
- (setq nmcobol-find-syntactic--state 1) ;do next state on this line
- ))
- ;; see if entire line is a comment
- ((= 1 nmcobol-find-syntactic--state)
- (if (not (looking-at "^\\(?:*\\|/\\)"))
- (setq nmcobol-find-syntactic--state 2) ;goto next state
- ;; else set match data and point to next line
- (looking-at "\\(.\\).*\\(\n\\|\\'\\)") ;setup match-data
- (forward-line 1) ;next iteration looks at next line
- (setq nmcobol-find-syntactic--state ()
- found t)))
- ;; look for strings only within columns 8-72 inclusive
- ((= 2 nmcobol-find-syntactic--state)
- (if (looking-at "^[-d D][^\"\n]\\{0,130\\}\"")
- (let* ((open-quote (list (copy-marker (1- (match-end 0)))
- (copy-marker (match-end 0))))
- (leol (copy-marker (line-end-position)))
- close-quote)
- (setq found t)
- (goto-char (cadr open-quote))
- (if (search-forward "\"" leol t)
- (progn ; normally ending string
- (setq close-quote (match-data)
- nmcobol-find-syntactic--state (cadr close-quote))
- (beginning-of-line)
- (set-match-data
- `(,(car open-quote) ,(cadr close-quote)
- nil nil nil nil ;match-string 1&2 not found
- ,@open-quote ,@close-quote)) ;3&4 are normal string
- )
- ;; implicit string end
- (forward-line 1) ;next iteration looks at next line
- (setq close-quote (list (copy-marker (1- leol)) leol)
- nmcobol-find-syntactic--state ())
- (set-match-data
- `(,(car open-quote) ,(cadr close-quote)
- nil nil nil nil ;match-string 1&2 not found
- nil nil nil nil ;match-string 3&4 not found
- ,@open-quote ,@close-quote)) ;5&6 unterminated string
- ))
- ;; no string was found. Start new analysis on next line
- (forward-line 1)
- (setq nmcobol-find-syntactic--state ())))
- ;; a string has been found look for another after it
- ((markerp nmcobol-find-syntactic--state)
- (let ((leol (copy-marker (line-end-position)))
- open-quote close-quote)
- (goto-char nmcobol-find-syntactic--state)
- (if (search-forward "\"" leol t)
- (progn
- (setq open-quote (match-data)
- found t)
- (if (search-forward "\"" leol t)
- (progn ; normally ending string
- (beginning-of-line) ;next iteration starts here again
- (setq close-quote (match-data)
- nmcobol-find-syntactic--state (cadr close-quote))
- (set-match-data
- `(,(car open-quote) ,(cadr close-quote)
- nil nil nil nil ;match-string 1&2 not found
- ,@open-quote ,@close-quote)) ;3&4 normal string
- )
- ;; implicit string end
- (forward-line 1) ;next iteration looks at next line
- (setq close-quote (list (copy-marker (1- leol)) leol)
- nmcobol-find-syntactic--state ())
- (set-match-data
- `(,(car open-quote) ,(cadr close-quote)
- nil nil nil nil ;match-string 1&2 not found
- nil nil nil nil ;match-string 3&4 not found
- ,@open-quote ,@close-quote)) ;5&6 unterminated string
- ))
- (forward-line 1)
- (setq nmcobol-find-syntactic--state ()))))))
- ;; Point should not return forward of search-limit
- (and (> (point) search-limit) (goto-char search-limit))
- ;; point shouldn't move if nothing was found.
- (prog1 found (or found (goto-char save)))))
- (defvar nmcobol-static-font-lock-keywords
- ;; font-lock-keywords is a symbol or list of symbols yielding the keywords to
- ;; be fontified. Keywords are listed here using either (MATCHER . FACENAME)
- ;; or (MATCHER . (MATCH FACENAME)) syntax. Other options are available but
- ;; not used here. For simplicity, all regexp's were designed so MATCH would
- ;; be 1. Nothing forced this but to me it makes debug/maintenance easier.
- `(("^\\([^ ?Dd*/-]\\)" 1 font-lock-warning-face)
- ("^\\([?Dd-]\\)" 1 font-lock-builtin-face)
- (,nmcobol-keyword-section-names-regexp
- 1 font-lock-function-name-face)
- (,(nmcobol-keyword-on-directive-line-regexp nmcobol-keywords-directives)
- 1 font-lock-preprocessor-face)
- (,(nmcobol-keyword-anywhere-regexp nmcobol-keywords-builtin)
- 1 font-lock-variable-name-face)
- (,(nmcobol-keyword-special-regexp nmcobol-keywords-statements)
- 1 font-lock-keyword-face)
- (,(nmcobol-keyword-anywhere-regexp nmcobol-keywords-std-fcns)
- 1 font-lock-keyword-face)
- (,(nmcobol-keyword-anywhere-regexp (append nmcobol-keywords-deprecated
- nmcobol-keywords-privileged))
- 1 font-lock-warning-face)
- (,(nmcobol-keyword-anywhere-regexp nmcobol-keywords-reserved)
- 1 font-lock-type-face)
- (,nmcobol-keyword-fcn-names-regexp
- 1 font-lock-function-name-face)))
- (defvar nmcobol-font-lock-keywords ())
- (defun nmcobol-build-font-lock-keywords ()
- "Creates `font-lock-keywords' based on current customize settings."
- (append nmcobol-static-font-lock-keywords
- `(,(when nmcobol-primecode-warning
- ;; ]a ]d or ]e cannot appear in col 1-2 if using PrimeCode.
- '("^\\][ade]" . font-lock-warning-face)))))
- (defvar nmcobol-this-paren-type ()
- "Used internally by `nmcobol-font-lock-syntactic-keywords'"
- )
- (defvar nmcobol-block-symbol-prefix "nmcobol-blk-typ-"
- "Paren matching symbols are built using this prefix.
- You probably don't want to change it "
- )
- (defcustom nmcobol-else-gets-paren-syntax t
- "When `show-paren-mode' is ON and this is nil, IF always matches END-IF only.
- When this variable is non-nil, IF can match ELSE and ELSE matches END-IF."
- :type 'boolean
- :group 'nmcobol)
- (defun nmcobol-find-paren-words (lim)
- "Function to set paren syntactic properties for Cobol's block keywords.
- Returns t and sets both `nmcobol-this-paren-type' and appropriate match-data
- when keywords requiring paren syntax are seen within range of point & lim."
- (let ((looking t) ;looping continues until lim or found (not looking)
- open-type ;type of paren needed to match this open
- close-type ;type of paren needed to match this close
- open-loc
- close-loc
- word)
- ;; walk thru each statement
- (while (and looking
- (re-search-forward nmcobol-keywords-statements-regexp
- lim 'move-anyway))
- ;; Save the word and it's location in case paren class is to be applied
- (setq word (match-string-no-properties 2)
- open-loc (match-beginning 2)
- close-loc (1- (match-end 2)))
- ;; Look for the different types of paren class we might apply
- (cond
- ;; The ELSE keyword can be ignored or treated as both open and close
- ((and nmcobol-else-gets-paren-syntax (string= "ELSE" word))
- ;; The leading E of Else will match the I of IF and the trailing
- ;; E should match the F of END-IF. When no ELSE is present the I
- ;; of IF will match the F of END-IF.
- (setq looking nil
- word open-loc
- open-loc close-loc
- close-loc word
- close-type (setq open-type
- (intern
- (concat nmcobol-block-symbol-prefix "IF")))))
- ;; close paren keywords always have close paren syntax
- ((string-match nmcobol-block-end-regexp word)
- (setq close-type
- (intern
- (concat nmcobol-block-symbol-prefix
- (upcase (match-string-no-properties 1 word))))
- looking nil))
- ;; 'possible' open paren keywords. More checking needed.
- ((string-match nmcobol-block-begin-regexp word)
- (let ((next (point)))
- (if (re-search-forward nmcobol-keywords-statements-regexp
- lim 'move-anyway)
- (setq next (match-beginning 0)))
- (goto-char open-loc)
- (if (setq open-type (nmcobol-get-block-type next))
- (setq looking nil))
- (goto-char (1+ close-loc))))))
- ;; Build the response data
- (if looking
- ;; nil is returned if no paren syntax to apply
- (set-match-data ())
- ;; both the match data and the paren type data must be set
- (set-match-data
- (append (list open-loc (1+ close-loc))
- (if open-type
- (list open-loc (1+ open-loc))
- (list () ()))
- (if close-type
- (list close-loc (1+ close-loc)))))
- (setq nmcobol-this-paren-type
- (cons
- ;; declare the open-paren type
- (cons 4 open-type)
- ;; declare the close-paren type
- (cons 5 close-type)))
- ;; t must be returned iff match-data should be acted upon
- t)))
- (defvar nmcobol-font-lock-syntactic-keywords
- `(
- ;; nmcobol-find-syntactic-keywords returns matches 1&2 for comments, 3&4
- ;; for strings. 5&6 for eol terminated strings. I must use "|"(15)
- ;; rather than "\""(7) for eol terminated strings because the begin
- ;; and end characters must be the same when "\""(7) is used.
- (nmcobol-find-syntactic-keywords (1 "<" t t) (2 ">" t t)
- (3 "\"" t t) (4 "\"" t t)
- (5 "|" t t) (6 "|" t t))
- ;; nmcobol-find-paren-words returns match 1 for open paren syntax and
- ;; match 2 for close paren syntax. The car of nmcobol-this-paren-type
- ;; is used for open paren type and the cdr for close type. The types
- ;; must be configurable due to the large number of them.
- (nmcobol-find-paren-words (1 (car nmcobol-this-paren-type) t t)
- (2 (cdr nmcobol-this-paren-type) t t)
- )
- )
- "A list of regexp's or functions. Used to add syntax-table properties to
- characters that can't be set by the syntax-table alone.")
- ;(defun nmcobol-start-of-statement-hook ()
- ; "Used as `font-lock-extend-region-functions' hook which see."
- ; ;; WARNING - any malfunction in this can cause emacs to enter a loop
- ; ;; that C-g will not break out of. Your session (and all edits) will
- ; ;; be toast.
- ; ;; There seems to be no good way to suppress the warning caused by
- ; ;; accessing font-lock-beg. It's required but apparently only
- ; ;; defined within a let statement.
- ; (goto-char font-lock-beg)
- ; (unless (bolp) (beginning-of-line))
- ; (unless (or (looking-at nmcobol-non-cobol-regexp)
- ; (looking-at nmcobol-keywords-statements-regexp))
- ; (let* ((lim (progn (nmcobol-backward-sentence 0)(point))))
- ; (goto-char font-lock-beg)
- ; (re-search-backward
- ; nmcobol-keywords-statements-regexp lim 'move-anyway)
- ; ;; If I reached the beginning of the sentence, there may be
- ; ;; comments and blank lines: they don't need refontification.
- ; (when (= (point) lim)
- ; (while (or (looking-at "^[ \t]*$")
- ; (looking-at nmcobol-non-cobol-regexp))
- ; (forward-line)))))
- ; (unless (eq (point) font-lock-beg)
- ; (setq font-lock-beg (point))))
- (defun nmcobol-start-of-statement ()
- "Used as the syntax-begin function of `font-lock-defaults' which see."
- ;; WARNING - any malfunction in this can cause emacs to enter a loop
- ;; that C-g will not break out of. Your session (and all edits) will
- ;; be toast.
- (unless (bolp) (beginning-of-line))
- (unless (or (looking-at nmcobol-non-cobol-regexp)
- (looking-at nmcobol-keywords-statements-regexp))
- (let* ((start (point))
- (lim (progn (nmcobol-backward-sentence 0)(point))))
- (goto-char start)
- (re-search-backward
- nmcobol-keywords-statements-regexp lim 'move-anyway)
- ;; If I reached the beginning of the sentence, there may be
- ;; comments and blank lines: they don't need refontification.
- (when (= (point) lim)
- (while (and (< (point) start)
- (or (looking-at "^[ \t]*$")
- (looking-at nmcobol-non-cobol-regexp)))
- (forward-line))
- (if (> (point) start)
- (goto-char start))))))
- (defun nmcobol-setup-font-lock ()
- "Sets up the buffer local value for font-lock-defaults and optionally
- turns on font-lock-mode"
- ;; I use font-lock-syntactic-keywords to set some properties and I
- ;; don't want them ignored.
- (set (make-local-variable 'parse-sexp-lookup-properties) t)
- ;; I really can't imagine anyone wanting this off.
- (set (make-local-variable 'parse-sexp-ignore-comments) t)
- ;; This allows column markers to be different in separate buffers.
- (set (make-local-variable 'nmcobol-font-lock-keywords)
- (nmcobol-build-font-lock-keywords))
- ;; make sure the parsing state is reset
- (setq nmcobol-find-syntactic--state ())
- ; (setq font-lock-extend-region-functions
- ; (append font-lock-extend-region-functions
- ; '(nmcobol-start-of-statement-hook)))
- ;; This is where all the font-lock stuff actually gets set up. Once
- ;; font-lock-defaults has it's value, setting font-lock-mode true should
- ;; cause all your syntax highlighting dreams to come true.
- (setq font-lock-defaults
- ;; The first value is all the keyword expressions.
- '(nmcobol-font-lock-keywords
- ;; keywords-only means no strings or comments get fontified
- nil
- ;; case-fold (ignore case)
- t
- ;; syntax-alist. See also imenu-syntax-alist
- ;; This can't override syntax applied by font-lock-syntactic-keywords
- ;; It only overrides nmcobol-mode-syntax-table.
- nil
- ;; syntax-begin - function to move outside syntactic block
- ;; This doesn't work for some reason. I'm using the hook
- ;; font-lock-extend-region-functions for this.
- nil ; nmcobol-start-of-statement
- ;; font-lock-syntactic-keywords
- ;; takes (matcher (match syntax override lexmatch) ...)...
- (font-lock-syntactic-keywords . nmcobol-font-lock-syntactic-keywords)))
- ; font lock is turned on by default in this mode. Use customize to disable.
- (when nmcobol-font-lock-always (font-lo…
Large files files are truncated, but you can click here to view the full file