From cac31bdf1b54a4772de31677df687ee491a1d83c Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 6 Mar 2005 22:38:31 +0000 Subject: [PATCH] Added the beginnings of an emacs pspp-mode for editing pspp files. --- po/en_GB.po | 40 ++++++------- po/pspp.pot | 40 ++++++------- pspp-mode.el | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+), 40 deletions(-) create mode 100644 pspp-mode.el diff --git a/po/en_GB.po b/po/en_GB.po index 33a1565ba5..b11dc75e36 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.3.1\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-03-06 10:44-0800\n" +"POT-Creation-Date: 2005-03-07 06:29+0800\n" "PO-Revision-Date: 2004-01-23 13:04+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -1210,6 +1210,25 @@ msgstr "" msgid "installation error" msgstr "" +#: src/filename.c:221 +#, c-format +msgid "Searching for `%s'..." +msgstr "" + +#: src/filename.c:229 src/filename.c:261 +msgid "Search unsuccessful!" +msgstr "" + +#: src/filename.c:254 +#, c-format +msgid "Found `%s'." +msgstr "" + +#: src/filename.c:686 +#, c-format +msgid "Not opening pipe file `%s' because SAFER option set." +msgstr "" + #: src/file-type.c:129 msgid "MIXED, GROUPED, or NESTED expected." msgstr "" @@ -1348,25 +1367,6 @@ msgstr "" msgid "Unknown record type %g." msgstr "" -#: src/filename.c:221 -#, c-format -msgid "Searching for `%s'..." -msgstr "" - -#: src/filename.c:229 src/filename.c:261 -msgid "Search unsuccessful!" -msgstr "" - -#: src/filename.c:254 -#, c-format -msgid "Found `%s'." -msgstr "" - -#: src/filename.c:686 -#, c-format -msgid "Not opening pipe file `%s' because SAFER option set." -msgstr "" - #: src/flip.c:81 msgid "" "FLIP ignores TEMPORARY. Temporary transformations will be made permanent." diff --git a/po/pspp.pot b/po/pspp.pot index b4fd86b78b..dc3640701a 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-03-06 10:44-0800\n" +"POT-Creation-Date: 2005-03-07 06:29+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1211,6 +1211,25 @@ msgstr "" msgid "installation error" msgstr "" +#: src/filename.c:221 +#, c-format +msgid "Searching for `%s'..." +msgstr "" + +#: src/filename.c:229 src/filename.c:261 +msgid "Search unsuccessful!" +msgstr "" + +#: src/filename.c:254 +#, c-format +msgid "Found `%s'." +msgstr "" + +#: src/filename.c:686 +#, c-format +msgid "Not opening pipe file `%s' because SAFER option set." +msgstr "" + #: src/file-type.c:129 msgid "MIXED, GROUPED, or NESTED expected." msgstr "" @@ -1349,25 +1368,6 @@ msgstr "" msgid "Unknown record type %g." msgstr "" -#: src/filename.c:221 -#, c-format -msgid "Searching for `%s'..." -msgstr "" - -#: src/filename.c:229 src/filename.c:261 -msgid "Search unsuccessful!" -msgstr "" - -#: src/filename.c:254 -#, c-format -msgid "Found `%s'." -msgstr "" - -#: src/filename.c:686 -#, c-format -msgid "Not opening pipe file `%s' because SAFER option set." -msgstr "" - #: src/flip.c:81 msgid "" "FLIP ignores TEMPORARY. Temporary transformations will be made permanent." diff --git a/pspp-mode.el b/pspp-mode.el new file mode 100644 index 0000000000..20e872116d --- /dev/null +++ b/pspp-mode.el @@ -0,0 +1,160 @@ +;;; pspp-mode-el -- Major mode for editing PSPP files + + +;; Author: John Darrington +;; Created: 05 March 2005 +;; Keywords: PSPP major-mode + +;; Copyright (C) 2005 John Darrington +;; +;; Based on the example wpdl-mode.el by Scott Borton +;; Author: Scott Andrew Borton + +;; Copyright (C) 2000, 2003 Scott Andrew Borton + +;; 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 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 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 this program; if not, write to the Free +;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +;; MA 02111-1307 USA + +;;; Code: +(defvar pspp-mode-hook nil) +(defvar pspp-mode-map + (let ((pspp-mode-map (make-keymap))) + (define-key pspp-mode-map "\C-j" 'newline-and-indent) + pspp-mode-map) + "Keymap for PSPP major mode") + +(add-to-list 'auto-mode-alist '("\\.sps\\'" . pspp-mode)) + + +(defun pspp-data-block () + "Returns t if current line is inside a data block." + (interactive) + + (let ( + (end-data-found nil) + (begin-data-found nil) + (inside-block nil) + ) + + (save-excursion + (beginning-of-line) + (while (not (or (bobp) end-data-found) ) + + (if (looking-at "^[ \t]*END +DATA\.") + (setq end-data-found t) + ) + + (forward-line -1) + + (if (looking-at "^[ \t]*BEGIN +DATA\.") + (setq begin-data-found t) + ) + + ) + ) + + (setq inside-block (and begin-data-found (not end-data-found))) + + inside-block + ) + + ) + + +(defun pspp-indent-line () + "Indent current line as PSPP code." + (interactive) + (beginning-of-line) + (let ( + (verbatim nil) + (the-indent 0) ; Default indent to column 0 + ) + + (if (bobp) + (setq the-indent 0) ; First line is always non-indented + ) + + + (let ( + (within-command nil) + (blank-line t) + ) + + ;; If the most recent non blank line ended with a `.' then + ;; we're at the start of a new command. + + (save-excursion + (while (and blank-line (not (bobp))) + (forward-line -1) + + (if (and (not (pspp-data-block)) (not (looking-at "^[ \t]*$"))) + (progn + (setq blank-line nil) + + (if (not (looking-at ".*\\.[ \t]*$")) + (setq within-command t) + ) + ) + ) + ) + + (if within-command (setq the-indent 8) ) + ) + + ) + + (if (not (pspp-data-block)) (indent-line-to the-indent)) +)) + + + +(defvar pspp-mode-syntax-table + (let ( + (x-pspp-mode-syntax-table (make-syntax-table)) + ) + + (modify-syntax-entry ?_ "w" x-pspp-mode-syntax-table) + (modify-syntax-entry ?. "w" x-pspp-mode-syntax-table) + (modify-syntax-entry ?\" "|" x-pspp-mode-syntax-table) + (modify-syntax-entry ?\' "|" x-pspp-mode-syntax-table) + + ;; Comment definitions + (modify-syntax-entry ?* "<\n" x-pspp-mode-syntax-table) + +;; (modify-syntax-entry ?\n "- 1" x-pspp-mode-syntax-table) +;; (modify-syntax-entry ?* ". 2" x-pspp-mode-syntax-table) + + (modify-syntax-entry ?\n ">*" x-pspp-mode-syntax-table) + + x-pspp-mode-syntax-table) + + "Syntax table for pspp-mode") + +(defun pspp-mode () + (interactive) + (kill-all-local-variables) + (use-local-map pspp-mode-map) + (set-syntax-table pspp-mode-syntax-table) + (setq comment-start "* ") + ;; Register our indentation function + (set (make-local-variable 'indent-line-function) 'pspp-indent-line) + (setq major-mode 'pspp-mode) + (setq mode-name "PSPP") + (run-hooks 'pspp-mode-hook)) + +(provide 'pspp-mode) + +;;; pspp-mode.el ends here + -- 2.30.2