| 1 |
;;; atp.el --- major mode for editing Atoms template files |
| 2 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 3 |
;; Author: Bruce Ravel <[email protected]> |
| 4 |
;; Maintainer: Bruce Ravel <[email protected]> |
| 5 |
;; Created: 25 September 1998 |
| 6 |
;; Updated: 20 November 2000 |
| 7 |
;; Version: see `atp-version' |
| 8 |
;; Keywords: atoms, atp, atoms template files |
| 9 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 10 |
;; This file is not part of GNU Emacs. |
| 11 |
;; |
| 12 |
;; Copyright (C) 1998-2006 Bruce Ravel |
| 13 |
;; |
| 14 |
;; This program is free software; you can redistribute it and/or modify |
| 15 |
;; it under the terms of the GNU General Public License as published by |
| 16 |
;; the Free Software Foundation; either version 2, or (at your option) |
| 17 |
;; any later version. |
| 18 |
;; |
| 19 |
;; This program is distributed in the hope that it will be useful, |
| 20 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
;; GNU General Public License for more details. |
| 23 |
;; |
| 24 |
;; You should have received a copy of the GNU General Public License |
| 25 |
;; along with GNU Emacs; see the file COPYING. If not, write to |
| 26 |
;; the Free Software Foundation, 675 Massachusettes Ave, |
| 27 |
;; Cambridge, MA 02139, USA. |
| 28 |
;; |
| 29 |
;; Everyone is granted permission to copy, modify and redistribute this |
| 30 |
;; and related files provided: |
| 31 |
;; 1. All copies contain this copyright notice. |
| 32 |
;; 2. All modified copies shall carry a prominant notice stating who |
| 33 |
;; made modifications and the date of such modifications. |
| 34 |
;; 3. The name of the modified file be changed. |
| 35 |
;; 4. No charge is made for this software or works derived from it. |
| 36 |
;; This clause shall not be construed as constraining other software |
| 37 |
;; distributed on the same medium as this software, nor is a |
| 38 |
;; distribution fee considered a charge. |
| 39 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 40 |
;; |
| 41 |
;; Please note that most of Atoms is distributed under the terms of |
| 42 |
;; the Artistic License. This file is the exception. This file is |
| 43 |
;; distributed under the terms of the GNU Public License. This |
| 44 |
;; distinction is mostly one of convenience, but also due to the |
| 45 |
;; nature of the GPL. Basically, Emacs is a GPL application, thus |
| 46 |
;; this emacs-lisp program is also GPL. Perl is itself released |
| 47 |
;; under the AL, so Atoms -- a perl application -- is released under |
| 48 |
;; that license as well. |
| 49 |
;; |
| 50 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 51 |
;; |
| 52 |
;;; Installation: |
| 53 |
;; |
| 54 |
;; Put this file in your lisp load-path and byte compile it. Add the |
| 55 |
;; following to your .emacs file |
| 56 |
;; |
| 57 |
;; (setq load-path (append (list ("\\.atp$" . atp-mode)) load-path)) |
| 58 |
;; (autoload 'atp-mode "atp" "Atoms template mode." t) |
| 59 |
;; |
| 60 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 61 |
;; |
| 62 |
;;; Commentary: |
| 63 |
;; |
| 64 |
;; This is a simple major mode for editing Atoms template (atp) |
| 65 |
;; files. Because the syntax of the atp files is rather rigid and |
| 66 |
;; unforgiving, it is useful to have a tool to help write these |
| 67 |
;; files. The main purposes of this mode are to highlight (thus |
| 68 |
;; checking spelling), perform tagword completion, and perform syntax |
| 69 |
;; checking. |
| 70 |
;; |
| 71 |
;; M-tab or M-ret complete keyword at point |
| 72 |
;; M-? describe keyword at point |
| 73 |
;; C-c C-k display all tagwords in a buffer |
| 74 |
;; C-c C-c perform syntax check |
| 75 |
;; C-c C-n scroll through errors after syntax check |
| 76 |
;; |
| 77 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 78 |
;; |
| 79 |
;;; History: |
| 80 |
;; 0.1 initial version |
| 81 |
;; 0.2 (BR Feb 23 1999) completion function, tagword description |
| 82 |
;; 0.3 (BR Apr 29 1999) syntax checker |
| 83 |
;; 1.6 (BR May 26 1999) use cvs number as version number, added |
| 84 |
;; several new tagwords (number ???) |
| 85 |
;; 1.1 (BR Jun 17 1999) added new token for dafs and atoms atp files |
| 86 |
;; 1.2 (BR Aug 14 1999) added tagword display, fixed menu bug |
| 87 |
;; 1.3 (BR Aug 18 1999) actually fixed menu bug ;-) added atp-identify |
| 88 |
;; function |
| 89 |
;; (BR Nov 14 1999) added <utag> <fx> <fy> <fz> |
| 90 |
;; (BR Nov 30 1999) gnxas functionality <gnclass> <redge> <nabs> <gnid> |
| 91 |
;; gnxas option to symmetry file, :gnxas to <meta> |
| 92 |
;; <nabs> and <abslist>, <rx>, <ry>, <rz> for gnxas |
| 93 |
;; sym file |
| 94 |
;; (BR Dec 18 2001) moved :margin to the meta tagword |
| 95 |
;; (BR Aug 14 2005) added and fontified atp tag for file magic |
| 96 |
;; |
| 97 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 98 |
;;; To do: |
| 99 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 100 |
;;; Code: |
| 101 |
|
| 102 |
;; (require 'easymenu) |
| 103 |
(require 'cl) |
| 104 |
|
| 105 |
(eval-and-compile |
| 106 |
(condition-case () |
| 107 |
(require 'custom) |
| 108 |
(error nil)) |
| 109 |
(if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
| 110 |
nil ;; We've got what we needed |
| 111 |
;; We have the old custom-library, hack around it! |
| 112 |
(if (fboundp 'defgroup) |
| 113 |
nil |
| 114 |
(defmacro defgroup (&rest args) |
| 115 |
nil)) |
| 116 |
(if (fboundp 'defface) |
| 117 |
nil |
| 118 |
(defmacro defface (var values doc &rest args) |
| 119 |
(` (progn |
| 120 |
(defvar (, var) (quote (, var))) |
| 121 |
;; To make colors for your faces you need to set your .Xdefaults |
| 122 |
;; or set them up ahead of time in your .emacs file. |
| 123 |
(make-face (, var)) |
| 124 |
)))) |
| 125 |
(if (fboundp 'defcustom) |
| 126 |
nil |
| 127 |
(defmacro defcustom (var value doc &rest args) |
| 128 |
(` (defvar (, var) (, value) (, doc))))))) |
| 129 |
|
| 130 |
;(defconst atp-cvs-version |
| 131 |
; "$Id: atp.el,v 1.5 2000/11/21 01:18:17 bruce Exp $") |
| 132 |
(defconst atp-version "1.6 for Atoms 3.0.1") |
| 133 |
(defconst atp-author "Bruce Ravel") |
| 134 |
(defconst atp-maintainer-email "[email protected]") |
| 135 |
(defconst atp-atoms-url "http://cars9.uchicago.edu/~ravel/software/") |
| 136 |
|
| 137 |
(defgroup atp nil |
| 138 |
"Atoms template mode for Emacs." |
| 139 |
:prefix "atp-" |
| 140 |
:group 'local) |
| 141 |
|
| 142 |
(defcustom atp-mode-hook nil |
| 143 |
"*Hook run when atp minor mode is entered." |
| 144 |
:group 'atp |
| 145 |
:type 'hook) |
| 146 |
(defcustom atp-load-hook nil |
| 147 |
"*Hook run when atp.el is first loaded." |
| 148 |
:group 'atp |
| 149 |
:type 'hook) |
| 150 |
(defcustom atp-check-buffer-name "*atp-check*" |
| 151 |
"*Name of buffer used to display syntax errors." |
| 152 |
:group 'atp |
| 153 |
:type 'string) |
| 154 |
(defcustom atp-keywords-buffer-name "*atp-keywords*" |
| 155 |
"Name of buffer used to display list of ATP tagwords." |
| 156 |
:group 'atp |
| 157 |
:type 'string) |
| 158 |
|
| 159 |
(defvar atp-tagwords-alist nil |
| 160 |
"Alist of tagword properties.") |
| 161 |
(setq atp-tagwords-alist |
| 162 |
(list '("1bou" 3 "one bounce flag") |
| 163 |
'(":file" 6 "file type meta data") |
| 164 |
'(":feff" 6 "feff version meta data") |
| 165 |
'(":display" 6 "potential list display flag") |
| 166 |
'(":incbegin" 6 "beginning of the incremented index") |
| 167 |
'(":ipots" 6 "potential assignment scheme") |
| 168 |
'(":gcd" 6 "greatest common denominator flag") |
| 169 |
'(":gnxas" 6 "GNXAS flag") |
| 170 |
'(":lines" 6 "fixed number of title lines") |
| 171 |
'(":list" 6 "list type meta-data") |
| 172 |
'(":mol" 6 "molecule cluster flag") |
| 173 |
'(":output" 6 "default output file name") |
| 174 |
'(":ccupancy" 6 "dopants display flag") |
| 175 |
'(":precision" 6 "numeric precision meta-data") |
| 176 |
'(":prefix" 6 "prefix string for a text block") |
| 177 |
'(":prettyline" 6 "McMaster corrections delimiter") |
| 178 |
'(":margin" 6 "margin for the overfull list type") |
| 179 |
'(":sphere" 6 "small sphere multiplier for feff8") |
| 180 |
'(":style" 6 "list type") |
| 181 |
'("a" 1 "a lattice constant (or amplitude in a DAFS/powder list)") |
| 182 |
'("abslist" 1 "comma separated list of absorber sites") |
| 183 |
'("asqr" 3 "amplitude squared of a point in a DAFS/powder list") |
| 184 |
'("atp" 5 "file(1) magic for atp files") |
| 185 |
'("alpha" 1 "angle between b and c") |
| 186 |
'("b" 1 "b lattice constant") |
| 187 |
'("beta" 1 "angle between a and c") |
| 188 |
'("bravais" 1 "bravais vectors") |
| 189 |
'("c" 1 "c lattice constant") |
| 190 |
'("central" 1 "central atom element symbol") |
| 191 |
'("class" 1 "crystal class of the lattice") |
| 192 |
'("com" 5 "an ignored comment line") |
| 193 |
'("corrections" 4 "McMaster corrections") |
| 194 |
'("ctag" 1 "central atom tag") |
| 195 |
'("dafs" 2 "list in energy from a DAFS calculation") |
| 196 |
'("dspacing" 1 "d-spacing of the chosen reflection") |
| 197 |
'("e" 3 "energy of a point in a DAFS list") |
| 198 |
'("ease" 4 "local variables for EASE") |
| 199 |
'("edge" 1 "edge symbol") |
| 200 |
'("eedge" 1 "edge energy") |
| 201 |
'("elem" 3 "symbol of an element in a list") |
| 202 |
'("emax" 1 "maximum energy of a DAFS calculation") |
| 203 |
'("emin" 1 "minimum energy of a DAFS calculation") |
| 204 |
'("energy" 1 "energy for a powder diffraction simulation") |
| 205 |
'("estep" 1 "energy step of a DAFS calculation") |
| 206 |
'("fuse" 4 "synonym for ease") |
| 207 |
'("fx" 3 "formula for the x coordinate of a site") |
| 208 |
'("fy" 3 "formula for the y coordinate of a site") |
| 209 |
'("fz" 3 "formula for the z coordinate of a site") |
| 210 |
'("fxc" 1 "central atom x-coordinate formula") |
| 211 |
'("fyc" 1 "central atom y-coordinate formula") |
| 212 |
'("fzc" 1 "central atom z-coordinate formula") |
| 213 |
'("gamma" 1 "angle between a and b") |
| 214 |
'("given" 1 "space group symbol as supplied by the user") |
| 215 |
'("gncell" 4 "unit cell information in the GNXAS format") |
| 216 |
'("gnclass" 1 "crystal class symbol for GNXAS files") |
| 217 |
'("gnid" 1 "silly identifier for GNXAS files") |
| 218 |
'("group" 1 "space group number") |
| 219 |
'("h" 3 "miller index in a powder list") |
| 220 |
'("i" 3 "imaginary part of a point in a DAFS/powder list") |
| 221 |
'("id" 4 "information identifying Atoms and it author") |
| 222 |
'("iedge" 1 "edge index") |
| 223 |
'("inc" 3 "incremented list index") |
| 224 |
'("ipot" 3 "unique potential of the atom in a cluster") |
| 225 |
'("itag" 3 "indexed tag of the atom in a cluster") |
| 226 |
'("k" 3 "miller index in a powder list") |
| 227 |
'("l" 3 "angular momentum in a list (or miller index)") |
| 228 |
'("lambda" 1 "wavelength for a powder diffraction simulation") |
| 229 |
'("lp" 3 "Lorentz-polarization correction in a powder list") |
| 230 |
'("list" 2 "list of atoms") |
| 231 |
'("meta" 5 "atp meta-data") |
| 232 |
'("nabs" 1 "number of sites occupied by the absorber") |
| 233 |
'("occ" 3 "occupancy of a point in an atoms list") |
| 234 |
'("os" 1 "name of the operating system") |
| 235 |
'("mult" 3 "multiplicity in a powder list") |
| 236 |
'("nclus" 1 "size of the list") |
| 237 |
'("p" 3 "phase of a point in a DAFS/powder list") |
| 238 |
'("potentials" 2 "list of unique potentials") |
| 239 |
'("powder" 2 "list for a powder diffraction simulation") |
| 240 |
'("r" 3 "the radial distance of an atom in a cluster") |
| 241 |
'("redge" 1 "edge energy in Rydbergs") |
| 242 |
'("reflection" 1 "Miller indeces of the reflection") |
| 243 |
'("resource" 4 "Absorption data resource") |
| 244 |
'("rmax" 1 "radial size of the cluster") |
| 245 |
'("rnn" 1 "nearest neighbor distance") |
| 246 |
'("rss" 1 "small sphere radius (default: 2.2*rnn)") |
| 247 |
'("rx" 3 "x rotation in GNXAS SYM file") |
| 248 |
'("ry" 3 "y rotation in GNXAS SYM file") |
| 249 |
'("rz" 3 "z rotation in GNXAS SYM file") |
| 250 |
'("space" 1 "canoncalized space group symbol") |
| 251 |
'("setting" 1 "crystallographic setting") |
| 252 |
'("shift" 4 "shift vector on a line of its own") |
| 253 |
'("stoi" 3 "stoichiometry of a unique potential") |
| 254 |
'("tag" 3 "tag of an atom in a list") |
| 255 |
'("th" 3 "theta angle in a powder list") |
| 256 |
'("titles" 4 "user supplied title lines") |
| 257 |
'("tth" 3 "2theta angle in a powder list") |
| 258 |
'("utag" 3 "unique tag of an atom in a list") |
| 259 |
'("x" 3 "x coordinate of an atom in a cluster") |
| 260 |
'("y" 3 "y coordinate of an atom in a cluster") |
| 261 |
'("z" 3 "z coordinate of an atom in a cluster") |
| 262 |
'("znum" 3 "Z number of an atom in a cluster") |
| 263 |
)) |
| 264 |
|
| 265 |
(defsubst atp-tagword-type (obj) (elt (assoc obj atp-tagwords-alist) 1)) |
| 266 |
(defsubst atp-tagword-description (obj) (elt (assoc obj atp-tagwords-alist) 2)) |
| 267 |
|
| 268 |
|
| 269 |
(defvar atp-tagwords nil |
| 270 |
"A list of tagwords used in Atoms template files.") |
| 271 |
(defun atp-make-tagwords-list () |
| 272 |
(let ((list ()) (alist atp-tagwords-alist)) |
| 273 |
(while alist |
| 274 |
(setq list (append list (list (caar alist))) |
| 275 |
alist (cdr alist))) |
| 276 |
list)) |
| 277 |
;; (setq atp-tagwords |
| 278 |
;; '("1bou" ":file" ":incbegin" ":ipots" ":list" ":precision" |
| 279 |
;; ":output" ":prefix" ":margin" ":sphere" ":gcd" ":mol" ":display" |
| 280 |
;; ":prettyline" ":style" ":lines" "a" "alpha" "atp" "b" "beta" "bravais" "c" |
| 281 |
;; "central" "class" "com" "ctag" "corrections" "edge" "eedge" |
| 282 |
;; "elem" "fuse" "gamma" "given" "id" "iedge" "inc" "ipot" "itag" |
| 283 |
;; "l" "list" "meta" "os" "nclus" "potentials" "r" "rmax" "space" |
| 284 |
;; "setting" "stoi" "tag" "titles" "x" "y" "z" "znum" "shift")) |
| 285 |
|
| 286 |
|
| 287 |
(defvar atp-mode-map nil) |
| 288 |
(if atp-mode-map |
| 289 |
() |
| 290 |
(setq atp-mode-map (make-sparse-keymap)) |
| 291 |
(define-key atp-mode-map "\M-\t" 'atp-complete-tagword) |
| 292 |
(define-key atp-mode-map "\M-\r" 'atp-complete-tagword) |
| 293 |
(define-key atp-mode-map "\M-?" 'atp-describe-tagword) |
| 294 |
(define-key atp-mode-map "\C-c\C-k" 'atp-display-tagwords) |
| 295 |
(define-key atp-mode-map "\C-c\C-c" 'atp-check-file) |
| 296 |
(define-key atp-mode-map "\C-c\C-n" 'atp-find-next-error) |
| 297 |
) |
| 298 |
|
| 299 |
(defvar atp-mode-menu nil) |
| 300 |
(defvar atp-menu nil |
| 301 |
"Menu for atp mode.") |
| 302 |
(setq atp-menu |
| 303 |
'("ATP" |
| 304 |
["Describe tagword" atp-describe-tagword t] |
| 305 |
["Display all tagwords" atp-display-tagwords t] |
| 306 |
"---" |
| 307 |
["Check file" atp-check-file t] |
| 308 |
["Next error" atp-find-next-error t] |
| 309 |
"---" |
| 310 |
["Version" atp-identify t] |
| 311 |
)) |
| 312 |
|
| 313 |
|
| 314 |
(defvar atp-mode-syntax-table nil |
| 315 |
"Syntax table in use in `atp-mode' buffers.") |
| 316 |
(if atp-mode-syntax-table |
| 317 |
() |
| 318 |
(setq atp-mode-syntax-table (make-syntax-table)) |
| 319 |
(modify-syntax-entry ?< "(>" atp-mode-syntax-table) |
| 320 |
(modify-syntax-entry ?> ")<" atp-mode-syntax-table) |
| 321 |
(modify-syntax-entry ?: "w" atp-mode-syntax-table) |
| 322 |
(modify-syntax-entry ?. "w" atp-mode-syntax-table) |
| 323 |
) |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
(defun atp-complete-tagword () |
| 328 |
"Perform completion on tagword preceding point. |
| 329 |
This is a pretty simple minded completion function. It is loosely |
| 330 |
adapted from `lisp-complete-symbol'." |
| 331 |
(interactive) |
| 332 |
(let* ((end (point)) |
| 333 |
(beg (unwind-protect (save-excursion (backward-sexp 1) (point)))) |
| 334 |
(patt (buffer-substring beg end)) |
| 335 |
(pattern (if (string-match "\\([^ \t]*\\)\\s-+$" patt) |
| 336 |
(match-string 1 patt) patt)) |
| 337 |
(alist (mapcar 'list atp-tagwords)) |
| 338 |
(completion (try-completion pattern alist))) |
| 339 |
(cond ((eq completion t)) |
| 340 |
((null completion) |
| 341 |
(message "No atp tagwords complete \"%s\"" pattern)) |
| 342 |
(t |
| 343 |
(when (not (string= pattern completion)) |
| 344 |
(delete-region beg end) |
| 345 |
(insert completion) |
| 346 |
(atp-describe-tagword completion)) |
| 347 |
(let* ((list (all-completions pattern alist)) |
| 348 |
(mess (format "\"%s\" could be one of %S" pattern list)) |
| 349 |
(orig (current-buffer)) |
| 350 |
(buff (get-buffer-create "*atp-completions*"))) |
| 351 |
(if (< (length mess) (frame-width)) |
| 352 |
(if (> (length list) 1) (message mess)) |
| 353 |
(switch-to-buffer-other-window buff) |
| 354 |
(insert mess) |
| 355 |
(fill-region (point-min) (point-max)) |
| 356 |
(goto-char (point-min)) |
| 357 |
(enlarge-window |
| 358 |
(+ 2 (- (count-lines (point-min) (point-max)) |
| 359 |
(window-height)))) |
| 360 |
(sit-for (max (length list) 15)) |
| 361 |
(switch-to-buffer orig) |
| 362 |
(kill-buffer buff) |
| 363 |
(delete-other-windows) ))) ))) |
| 364 |
|
| 365 |
|
| 366 |
(defun atp-this-word () |
| 367 |
"Return the word near point." |
| 368 |
(let (begin) |
| 369 |
(save-excursion |
| 370 |
(or (looking-at "\\<") (= (current-column) 0) (forward-word -1)) |
| 371 |
(if (looking-at (regexp-quote "<")) (forward-char 1)) |
| 372 |
(setq begin (point-marker)) |
| 373 |
(forward-word 1) |
| 374 |
(buffer-substring-no-properties begin (point))))) |
| 375 |
|
| 376 |
|
| 377 |
(defun atp-describe-tagword (&optional word) |
| 378 |
"Issue a message describing the tagword WORD." |
| 379 |
(interactive) |
| 380 |
(setq word (or word (atp-this-word))) |
| 381 |
(let ((type (atp-tagword-type word)) note (l "<") (r ">")) |
| 382 |
(cond ((equal type 1) |
| 383 |
(setq note "is replaced by the")) |
| 384 |
((equal type 2) |
| 385 |
(setq note "represents a")) |
| 386 |
((equal type 3) |
| 387 |
(setq note "is replaced by the")) |
| 388 |
((equal type 4) |
| 389 |
(setq note "is replaced by the")) |
| 390 |
((equal type 5) |
| 391 |
(setq note "denotes")) |
| 392 |
((equal type 6) |
| 393 |
(setq note "takes the" l "" r "")) ) |
| 394 |
(message "%s%s%s %s %s" l word r note (atp-tagword-description word)))) |
| 395 |
|
| 396 |
|
| 397 |
(defvar atp-matches-alist nil |
| 398 |
"Alist of error check regular expressions.") |
| 399 |
(setq atp-matches-alist |
| 400 |
(list |
| 401 |
(cons ":incbegin" "\\b[+-]?[0-9]+\\b") |
| 402 |
(cons ":lines" "\\b[0-9]+\\b") |
| 403 |
(cons ":list" (concat "\\b\\(atoms\\|cluster\\|dafs\\|neutral\\|" |
| 404 |
"overfull\\|powder\\|symmetry\\|unit\\)\\b")) |
| 405 |
(cons ":style" (concat "\\b\\(atoms\\|cluster\\|neutral\\|" |
| 406 |
"overfull\\|symmetry\\|unit\\)\\b")) |
| 407 |
(cons ":ipots" "\\b\\(sites\\|species\\|tags\\)\\b") |
| 408 |
(cons ":gcd" "\\b[01]\\b") |
| 409 |
(cons ":margin" "\\b-?[0-9]+\\.[0-9]\\b") |
| 410 |
(cons ":gnxas" "\\b[01]\\b") |
| 411 |
(cons ":mol" "\\b[01]\\b") |
| 412 |
(cons ":display" "\\b[01]\\b") |
| 413 |
(cons ":occupancy" "\\b[01]\\b") |
| 414 |
(cons ":sphere" "\\b[0-9]+\\.[0-9]\\b") |
| 415 |
(cons ":precision" "\\b[0-9]+\\.[0-9]\\b") |
| 416 |
(cons ":prettyline" "\\b[01]\\b") |
| 417 |
(cons "pot" "\\b\\(elem\\|ipot\\|l\\|stoi\\|znum\\)\\b") |
| 418 |
(cons "list" (concat "\\b\\(1bou\\|[brxyz]\\|elem\\|" |
| 419 |
"f\\(x\\|y\\|z\\)\\|" |
| 420 |
"i\\(nc\\|pot\\|tag\\)\\|occ\\|" |
| 421 |
"r\\(x\\|y\\|z\\)\\|tag\\|znum\\)\\b")) |
| 422 |
(cons "dafs" "\\b\\([aeipr]\\|asqr\\|inc\\|occ\\)\\b") |
| 423 |
(cons "powder" "\\b\\([ahiklpr]\\|asqr\\|inc\\|lp\\|mult\\|th\\|tth\\)\\b") |
| 424 |
)) |
| 425 |
(defvar atp-messages-alist nil |
| 426 |
"Alist of error check message formats.") |
| 427 |
(setq atp-messages-alist |
| 428 |
(list |
| 429 |
(cons ":incbegin" "%3s: \":incbegin\" takes an integer argument") |
| 430 |
(cons ":lines" "%3s: \":lines\" takes a non-negative integer argument") |
| 431 |
(cons ":list" |
| 432 |
(concat "%3s: \":list\" must be one of atoms, " |
| 433 |
"cluster, dafs, powder, overfull, symmetry, or unit")) |
| 434 |
(cons ":style" |
| 435 |
(concat "%3s: \":style\" must be one of atoms, " |
| 436 |
"cluster, overfull, symmetry, or unit")) |
| 437 |
(cons ":ipots" |
| 438 |
"%3s: \":ipots\" must be one of species, tags, or sites") |
| 439 |
(cons ":gcd" "%3s: \":gcd\" should be 1 or 0 (true/false)") |
| 440 |
(cons ":mol" "%3s: \":mol\" should be 1 or 0 (true/false)") |
| 441 |
(cons ":gnxas" "%3s: \":gnxas\" should be 1 or 0 (true/false)") |
| 442 |
(cons ":display" "%3s: \":mol\" should be 1 or 0 (true/false)") |
| 443 |
(cons ":occupancy" "%3s: \":occupancy\" should be 1 or 0 (true/false)") |
| 444 |
(cons ":margin" |
| 445 |
"%3s: \":margin\" takes a floating point number") |
| 446 |
(cons ":precision" |
| 447 |
"%3s: \":precision\" takes a format specification of the form #.#") |
| 448 |
(cons ":prefix" "prefix string for a text block") |
| 449 |
(cons ":prettyline" "%3s: \":prettyline\" should be 1 or 0 (true/false)") |
| 450 |
(cons ":sphere" |
| 451 |
"%3s: \":sphere\" takes a floating point number") |
| 452 |
(cons "modifier" "%3s: \"%s\" is not a <%s> modifier") |
| 453 |
(cons "pot" |
| 454 |
(concat "%3s: \"%s\" is not a potential list tag\n\t" |
| 455 |
"should be one of (elem ipot l stoi znum)")) |
| 456 |
(cons "list" |
| 457 |
(concat "%3s: \"%s\" is not an atoms list tag\n\t" |
| 458 |
"should be one of " |
| 459 |
"(x y z r elem inc ipot itag tag znum 1bou occ b)")) |
| 460 |
(cons "dafs" |
| 461 |
(concat "%3s: \"%s\" is not a dafs list tag\n\t" |
| 462 |
"should be one of (e a asqr r i p occ inc)")) |
| 463 |
(cons "powder" |
| 464 |
(concat "%3s: \"%s\" is not a powder list tag\n\t" |
| 465 |
"should be one of (a asqr r i p h k l mult lp inc)")) |
| 466 |
)) |
| 467 |
|
| 468 |
(defvar atp-error-marker nil) |
| 469 |
|
| 470 |
(defun atp-check-file () |
| 471 |
"Check the syntax of the current atp file." |
| 472 |
(interactive) |
| 473 |
(let (match word outbuf (error-list ())) |
| 474 |
(save-excursion |
| 475 |
(goto-char (point-min)) |
| 476 |
(while (not (eobp)) |
| 477 |
(when (re-search-forward "<\\(\\w+\\)" (point-max) "to_end") |
| 478 |
(setq match (match-string 1)) |
| 479 |
(cond |
| 480 |
;; not a keyword |
| 481 |
((not (assoc match atp-tagwords-alist)) |
| 482 |
(setq error-list |
| 483 |
(append error-list |
| 484 |
(list |
| 485 |
(format |
| 486 |
"%3s: \"%s\" is not a keyword" |
| 487 |
(count-lines (point-min) (point)) match))))) |
| 488 |
;; type 1 keyword with whitespace |
| 489 |
((= 1 (atp-tagword-type match)) |
| 490 |
(or (looking-at ">") |
| 491 |
(setq error-list |
| 492 |
(append |
| 493 |
error-list |
| 494 |
(list (format |
| 495 |
"%3s: \"%s\" must be surrounded by <> with no white space" |
| 496 |
(count-lines (point-min) (point)) match)))))) |
| 497 |
;; comment -- skip line |
| 498 |
((string= match "com") |
| 499 |
(forward-line 1)) |
| 500 |
;; meta line |
| 501 |
((string= match "meta") |
| 502 |
(let ((b (point))) |
| 503 |
(while (not (looking-at "[ \t]*>")) |
| 504 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 505 |
(setq word (atp-this-word)) |
| 506 |
(cond |
| 507 |
((member* word '(":precision" ":incbegin" ":list" |
| 508 |
":sphere" ":occupancy" ":margin") |
| 509 |
:test 'string=) |
| 510 |
(forward-sexp 1) |
| 511 |
(unless (string-match (cdr (assoc word atp-matches-alist)) |
| 512 |
(atp-this-word)) |
| 513 |
(setq error-list |
| 514 |
(append |
| 515 |
error-list |
| 516 |
(list |
| 517 |
(format |
| 518 |
(cdr (assoc word atp-messages-alist)) |
| 519 |
(count-lines (point-min) (point)) )))))) |
| 520 |
((member* word '(":file" ":output" ":feff" ":gnxas") |
| 521 |
:test 'string=) |
| 522 |
(forward-sexp 1) ) |
| 523 |
(t |
| 524 |
(setq error-list |
| 525 |
(append |
| 526 |
error-list |
| 527 |
(list |
| 528 |
(format |
| 529 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 530 |
(count-lines (point-min) (point)) |
| 531 |
word "meta"))))) ) ) |
| 532 |
(goto-char b) |
| 533 |
(forward-line 1)) ) |
| 534 |
;; corrections line |
| 535 |
((string= match "corrections") |
| 536 |
(let ((b (point))) |
| 537 |
(while (not (looking-at "[ \t]*>")) |
| 538 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 539 |
(setq word (atp-this-word)) |
| 540 |
(cond |
| 541 |
((string= word ":prefix") |
| 542 |
(forward-sexp 1) ) |
| 543 |
((string= word ":units") |
| 544 |
(forward-sexp 1) ) |
| 545 |
((string= word ":prettyline") |
| 546 |
(forward-sexp 1) |
| 547 |
(unless (string-match (cdr (assoc word atp-matches-alist)) |
| 548 |
(atp-this-word)) |
| 549 |
(setq error-list |
| 550 |
(append |
| 551 |
error-list |
| 552 |
(list |
| 553 |
(format |
| 554 |
(cdr (assoc word atp-messages-alist)) |
| 555 |
(count-lines (point-min) (point)) )))))) |
| 556 |
(t |
| 557 |
(setq error-list |
| 558 |
(append |
| 559 |
error-list |
| 560 |
(list |
| 561 |
(format |
| 562 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 563 |
(count-lines (point-min) (point)) |
| 564 |
word "corrections"))))) ) ) |
| 565 |
(goto-char b) |
| 566 |
(forward-line 1)) ) |
| 567 |
;; titles, id, resource line |
| 568 |
((member* match '("titles" "id" "resource" "shift") :test 'string=) |
| 569 |
(let ((b (point))) |
| 570 |
(while (not (looking-at "[ \t]*>")) |
| 571 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 572 |
(setq word (atp-this-word)) |
| 573 |
(cond |
| 574 |
((string= word ":prefix") |
| 575 |
(forward-sexp 1)) |
| 576 |
((and (string= word ":lines") (string= match "titles")) |
| 577 |
(forward-sexp 1) |
| 578 |
(unless (string-match (cdr (assoc word atp-matches-alist)) |
| 579 |
(atp-this-word)) |
| 580 |
(setq error-list |
| 581 |
(append |
| 582 |
error-list |
| 583 |
(list |
| 584 |
(format |
| 585 |
(cdr (assoc word atp-messages-alist)) |
| 586 |
(count-lines (point-min) (point)) )))))) |
| 587 |
(t |
| 588 |
(setq error-list |
| 589 |
(append |
| 590 |
error-list |
| 591 |
(list |
| 592 |
(format |
| 593 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 594 |
(count-lines (point-min) (point)) |
| 595 |
word match))))) ) ) |
| 596 |
(goto-char b) |
| 597 |
(forward-line 1)) ) |
| 598 |
;; fuse line |
| 599 |
((or (string= match "ease") (string= match "fuse")) |
| 600 |
(let ((b (point))) |
| 601 |
(while (not (looking-at "[ \t]*>")) |
| 602 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 603 |
(setq word (atp-this-word)) |
| 604 |
(cond |
| 605 |
((or (string= word ":file") (string= word ":prefix")) |
| 606 |
(forward-sexp 1)) |
| 607 |
(t |
| 608 |
(setq error-list |
| 609 |
(append |
| 610 |
error-list |
| 611 |
(list |
| 612 |
(format |
| 613 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 614 |
(count-lines (point-min) (point)) |
| 615 |
word "ease"))))) ) ) |
| 616 |
(goto-char b) |
| 617 |
(forward-line 1)) ) |
| 618 |
;; potentials line |
| 619 |
((string= match "potentials") |
| 620 |
(let ((b (point))) |
| 621 |
(while (not (looking-at "[ \t]*>")) |
| 622 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 623 |
(setq word (atp-this-word)) |
| 624 |
(cond |
| 625 |
((member* word '(":ipots" ":gcd" ":mol" ":display") |
| 626 |
:test 'string=) |
| 627 |
(forward-sexp 1) |
| 628 |
(unless (string-match (cdr (assoc word atp-matches-alist)) |
| 629 |
(atp-this-word)) |
| 630 |
(setq error-list |
| 631 |
(append |
| 632 |
error-list |
| 633 |
(list |
| 634 |
(format |
| 635 |
(cdr (assoc word atp-messages-alist)) |
| 636 |
(count-lines (point-min) (point)) )))))) |
| 637 |
(t |
| 638 |
(setq error-list |
| 639 |
(append |
| 640 |
error-list |
| 641 |
(list |
| 642 |
(format |
| 643 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 644 |
(count-lines (point-min) (point)) |
| 645 |
word "potentials"))))) ) ) |
| 646 |
(goto-char b) |
| 647 |
(forward-line 1)) |
| 648 |
(let ((list-line (buffer-substring-no-properties |
| 649 |
(point) |
| 650 |
(save-excursion (end-of-line) (point)))) |
| 651 |
b e m) |
| 652 |
(while (not (string= list-line "")) |
| 653 |
(setq b (or (string-match "<" list-line) (1- (length list-line))) |
| 654 |
e (or (string-match ">" list-line) (length list-line)) |
| 655 |
m (substring list-line (1+ b) e)) |
| 656 |
(unless (or (= (1+ b) e) |
| 657 |
(string-match |
| 658 |
(cdr (assoc "pot" atp-matches-alist)) m)) |
| 659 |
(setq error-list |
| 660 |
(append |
| 661 |
error-list |
| 662 |
(list |
| 663 |
(format |
| 664 |
(cdr (assoc "pot" atp-messages-alist)) |
| 665 |
(1+ (count-lines (point-min) (point))) m ))))) |
| 666 |
(setq list-line (if (= (1+ b) e) "" |
| 667 |
(substring list-line (1+ e))) ))) |
| 668 |
(forward-line 1) ) |
| 669 |
;; list line |
| 670 |
((string= match "list") |
| 671 |
(let ((b (point))) |
| 672 |
(while (not (looking-at "[ \t]*>")) |
| 673 |
(unless (looking-at "[ \t]*>") (forward-sexp 1)) |
| 674 |
(setq word (atp-this-word)) |
| 675 |
(cond |
| 676 |
((member* word '(":style") :test 'string=) |
| 677 |
(forward-sexp 1) |
| 678 |
(unless (string-match (cdr (assoc word atp-matches-alist)) |
| 679 |
(atp-this-word)) |
| 680 |
(setq error-list |
| 681 |
(append |
| 682 |
error-list |
| 683 |
(list |
| 684 |
(format |
| 685 |
(cdr (assoc word atp-messages-alist)) |
| 686 |
(count-lines (point-min) (point)) )))))) |
| 687 |
(t |
| 688 |
(setq error-list |
| 689 |
(append |
| 690 |
error-list |
| 691 |
(list |
| 692 |
(format |
| 693 |
(cdr (assoc "modifier" atp-messages-alist)) |
| 694 |
(count-lines (point-min) (point)) |
| 695 |
word "list"))))) ) ) |
| 696 |
(goto-char b) |
| 697 |
(forward-line 1)) |
| 698 |
(let ((list-line (buffer-substring-no-properties |
| 699 |
(point) |
| 700 |
(save-excursion (end-of-line) (point)))) |
| 701 |
b e m) |
| 702 |
(while (not (string= list-line "")) |
| 703 |
(setq b (or (string-match "<" list-line) (1- (length list-line))) |
| 704 |
e (or (string-match ">" list-line) (length list-line)) |
| 705 |
m (substring list-line (1+ b) e)) |
| 706 |
(unless (or (= (1+ b) e) |
| 707 |
(string-match |
| 708 |
(cdr (assoc "list" atp-matches-alist)) m)) |
| 709 |
(setq error-list |
| 710 |
(append |
| 711 |
error-list |
| 712 |
(list |
| 713 |
(format |
| 714 |
(cdr (assoc "list" atp-messages-alist)) |
| 715 |
(1+ (count-lines (point-min) (point))) m ))))) |
| 716 |
(setq list-line (if (= (1+ b) e) "" |
| 717 |
(substring list-line (1+ e))) ))) |
| 718 |
(forward-line 1) ) |
| 719 |
;; dafs line |
| 720 |
((or (string= match "dafs") (string= match "powder")) |
| 721 |
(forward-line 1) |
| 722 |
(let ((list-line (buffer-substring-no-properties |
| 723 |
(point) |
| 724 |
(save-excursion (end-of-line) (point)))) |
| 725 |
b e m) |
| 726 |
(while (not (string= list-line "")) |
| 727 |
(setq b (or (string-match "<" list-line) (1- (length list-line))) |
| 728 |
e (or (string-match ">" list-line) (length list-line)) |
| 729 |
m (substring list-line (1+ b) e)) |
| 730 |
(unless (or (= (1+ b) e) |
| 731 |
(string-match |
| 732 |
(cdr (assoc match atp-matches-alist)) m)) |
| 733 |
(setq error-list |
| 734 |
(append |
| 735 |
error-list |
| 736 |
(list |
| 737 |
(format |
| 738 |
(cdr (assoc match atp-messages-alist)) |
| 739 |
(1+ (count-lines (point-min) (point))) m ))))) |
| 740 |
(setq list-line (if (= (1+ b) e) "" |
| 741 |
(substring list-line (1+ e))) ))) |
| 742 |
(forward-line 1) ) |
| 743 |
|
| 744 |
)))) |
| 745 |
(if (get-buffer atp-check-buffer-name) (kill-buffer atp-check-buffer-name)) |
| 746 |
(if error-list |
| 747 |
(progn |
| 748 |
(setq outbuf (get-buffer-create atp-check-buffer-name)) |
| 749 |
(switch-to-buffer-other-window outbuf) |
| 750 |
(erase-buffer) |
| 751 |
(insert "line error\n" (make-string 72 ?-) "\n") |
| 752 |
(while error-list |
| 753 |
(insert (format "%s" (car error-list)) "\n") |
| 754 |
(setq error-list (cdr error-list))) |
| 755 |
(insert "\n\n" (substitute-command-keys "\\[atp-find-next-error]") |
| 756 |
" scrolls through the errors.\n") |
| 757 |
(help-mode) |
| 758 |
(font-lock-mode) |
| 759 |
(goto-char (point-min)) |
| 760 |
(setq atp-error-marker (point-marker)) |
| 761 |
(other-window 1)) |
| 762 |
(message "No syntax errors found in this atp file.")) |
| 763 |
)) |
| 764 |
|
| 765 |
(defun atp-find-next-error () |
| 766 |
"Move point to the line containing the next syntax error." |
| 767 |
(interactive) |
| 768 |
(if (get-buffer atp-check-buffer-name) |
| 769 |
(let (line) |
| 770 |
(save-excursion |
| 771 |
(set-buffer (get-buffer atp-check-buffer-name)) |
| 772 |
(goto-char atp-error-marker) |
| 773 |
(if (re-search-forward "^ *\\([0-9]+\\):" (point-max) "to_end") |
| 774 |
(setq line (match-string 1) |
| 775 |
atp-error-marker (point-marker)) )) |
| 776 |
(if line |
| 777 |
(progn |
| 778 |
(goto-char (point-min)) |
| 779 |
(forward-line (1- (string-to-number line)))) |
| 780 |
(message "no more errors"))) |
| 781 |
(message (substitute-command-keys |
| 782 |
"First do \\[atp-check-file] to check this file.")))) |
| 783 |
|
| 784 |
|
| 785 |
(defun atp-display-tagwords () |
| 786 |
"Open a buffer displaying all tagwords for atp files. |
| 787 |
Bound to \\[atp-display-tagwords]" |
| 788 |
(interactive) |
| 789 |
(let* (keyword arg-descr |
| 790 |
(keyword-alist (copy-alist atp-tagwords-alist)) |
| 791 |
(keyword-buffer-name atp-keywords-buffer-name)) |
| 792 |
(if (get-buffer keyword-buffer-name) |
| 793 |
(switch-to-buffer-other-window keyword-buffer-name) |
| 794 |
(switch-to-buffer-other-window keyword-buffer-name) |
| 795 |
;;(erase-buffer) |
| 796 |
(insert "\tATP Tagwords\n\n") |
| 797 |
(insert "Tagword\t\tdescription\n" |
| 798 |
(concat (make-string 75 ?\-) "\n")) |
| 799 |
(while keyword-alist |
| 800 |
(setq keyword (caar keyword-alist) |
| 801 |
arg-descr (nth 1 (cdar keyword-alist))) |
| 802 |
(insert (format "%-14s %s\n" keyword arg-descr)) |
| 803 |
(setq keyword-alist (cdr keyword-alist))) |
| 804 |
(help-mode) |
| 805 |
(setq truncate-lines t |
| 806 |
buffer-read-only t) ) |
| 807 |
(goto-char (point-min)) )) |
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
(defvar atp-font-lock-keywords nil) |
| 812 |
(defvar atp-font-lock-keywords-1 nil) |
| 813 |
(defvar atp-font-lock-keywords-2 nil) |
| 814 |
|
| 815 |
(defvar atp-tab-face 'atp-tab-face) |
| 816 |
(cond ((and (featurep 'custom) (fboundp 'custom-declare-variable)) |
| 817 |
(defface atp-tab-face '((((class color)) |
| 818 |
(:background "beige")) |
| 819 |
(t |
| 820 |
(:reverse t))) |
| 821 |
"Face used to mark tabs." |
| 822 |
:group 'atp)) |
| 823 |
(t |
| 824 |
(copy-face 'highlight 'atp-tab-face) |
| 825 |
(set-face-background 'atp-tab-face "beige") )) |
| 826 |
|
| 827 |
|
| 828 |
(if (featurep 'font-lock) |
| 829 |
(setq atp-font-lock-keywords |
| 830 |
(list ; comments |
| 831 |
(list "<com>.*$" 0 font-lock-comment-face) |
| 832 |
(list "<atp.*$" 0 font-lock-builtin-face) |
| 833 |
; tagword arguments |
| 834 |
(list (concat |
| 835 |
":" |
| 836 |
"\\(display\\|f\\(eff\\|ile\\)\\|g\\(cd\\|nxas\\)" |
| 837 |
"\\|i\\(ncbegin\\|pots\\)\\|li\\(nes\\|st\\)\\|" |
| 838 |
"o\\(ccupancy\\|utput\\)\\|m\\(argin\\|ol\\)\\|" |
| 839 |
"pre\\(cision\\|fix\\|ttyline\\)\\|" |
| 840 |
"s\\(phere\\|tyle\\)\\)\\>") |
| 841 |
0 font-lock-reference-face) |
| 842 |
; tagwords |
| 843 |
(list (concat |
| 844 |
"<\\(" |
| 845 |
"[abcehiklnprxyz]\\|1bou\\|" |
| 846 |
"a\\(bslist\\|lpha\\|sqr\\)\\|" |
| 847 |
"b\\(eta\\|ravais\\|x\\|y\\|z\\)\\|" |
| 848 |
"c\\(entral\\|lass\\|o\\(lor\\|m\\|rrections\\)\\|tag\\)\\|" |
| 849 |
"d\\(afs\\|spacing\\)\\|" |
| 850 |
"e\\(ase\\|dge\\|edge\\|lem\\|m\\(ax\\|in\\)\\|nergy\\|step\\)\\|" |
| 851 |
"f\\(ile\\|use\\|xc?\\|yc?\\|zc?\\)\\|" |
| 852 |
"g\\(amma\\|iven\\|n\\(c\\(ell\\|lass\\)\\|id\\)\\|roup\\)\\|" |
| 853 |
"i\\(d\\|edge\\|nc\\|pot\\|tag\\)\\|" |
| 854 |
"l\\(ambda\\|ist\\)\\|m\\(eta\\|ult\\)\\|n\\(abs\\|clus\\)\\|" |
| 855 |
"o\\(cc\\|s\\)\\|po\\(tentials\\|wder\\)\\|" |
| 856 |
"r\\(e\\(dge\\|flection\\|source\\)\\|max\\|nn\\|ss\\|x\\|y\\|z\\)\\|" |
| 857 |
"s\\(etting\\|hift\\|pace\\|toi\\)\\|" |
| 858 |
"t\\(ag\\|h\\|itles\\|th\\)\\|utag\\|valence\\|znum" |
| 859 |
"\\)\\>") |
| 860 |
1 font-lock-function-name-face) |
| 861 |
; quoted strings |
| 862 |
(list "[\"]\\([^\"\n]+\\)[\"]" 0 font-lock-string-face) |
| 863 |
; tabs |
| 864 |
'("\t+" 0 atp-tab-face t) |
| 865 |
)) |
| 866 |
(setq atp-font-lock-keywords-1 atp-font-lock-keywords) |
| 867 |
(setq atp-font-lock-keywords-2 atp-font-lock-keywords)) |
| 868 |
|
| 869 |
|
| 870 |
(defun atp-identify () |
| 871 |
"Print an identifier message in the echo area." |
| 872 |
(interactive) |
| 873 |
(message "atp-mode %s by %s <%s>" |
| 874 |
atp-version atp-author atp-maintainer-email) |
| 875 |
(sleep-for 3) |
| 876 |
(message "Atoms is part of the horae package: %s" atp-atoms-url) ) |
| 877 |
|
| 878 |
(defun atp-mode () |
| 879 |
"Major mode for editing Atoms template (atp) files. |
| 880 |
This is a pretty simple emacs mode intended for a pretty simple file |
| 881 |
syntax. Because the atp parsing code in Atoms is fairly rigid and |
| 882 |
non-forgiving, the major purpose of this mode is to remind the atp |
| 883 |
author of the spellings and arguments of the various tagwords. A |
| 884 |
syntax checker is also provided. `atp-load-hook' and `atp-mode-hook' |
| 885 |
are run when atp.el is loaded and `atp-mode' is started, respectively. |
| 886 |
|
| 887 |
Key bindings: |
| 888 |
\\{atp-mode-map}" |
| 889 |
(interactive) |
| 890 |
(kill-all-local-variables) |
| 891 |
(use-local-map atp-mode-map) |
| 892 |
(easy-menu-define ; set up gnuplot menu |
| 893 |
atp-mode-menu atp-mode-map "Menu used in atp-mode" |
| 894 |
atp-menu) |
| 895 |
(easy-menu-add atp-mode-menu atp-mode-map) |
| 896 |
(setq major-mode 'atp-mode |
| 897 |
mode-name "ATP") |
| 898 |
(set (make-local-variable 'comment-start) "<com> ") |
| 899 |
(set (make-local-variable 'comment-end) "") |
| 900 |
(if (featurep 'comment) |
| 901 |
(setq comment-mode-alist |
| 902 |
(append comment-mode-alist '((atp-mode "<com> ")) ))) |
| 903 |
(set-syntax-table atp-mode-syntax-table) |
| 904 |
(make-variable-buffer-local 'font-lock-defaults) |
| 905 |
(setq font-lock-defaults '(atp-font-lock-keywords t t)) |
| 906 |
(setq atp-tagwords (atp-make-tagwords-list)) |
| 907 |
(turn-on-font-lock) |
| 908 |
(message "atp mode %s -- send bugs to %s" |
| 909 |
atp-version atp-maintainer-email) |
| 910 |
(run-hooks 'atp-mode-hook)) |
| 911 |
|
| 912 |
|
| 913 |
;;; That's it! ---------------------------------------------------------------- |
| 914 |
|
| 915 |
|
| 916 |
;;;--- any final chores before leaving |
| 917 |
(provide 'atp) |
| 918 |
(run-hooks 'atp-load-hook) |
| 919 |
|
| 920 |
;;;============================================================================ |
| 921 |
;;; |
| 922 |
;;; atp.el ends here |