-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaph-forms.el
More file actions
executable file
·71 lines (55 loc) · 2.47 KB
/
aph-forms.el
File metadata and controls
executable file
·71 lines (55 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
;;; aph-forms.el --- Extensions for `forms-mode' -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Aaron Harris
;; Author: Aaron Harris <meerwolf@gmail.com>
;; Keywords: data
;; 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 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
;; 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, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Custom functions and commands for use in `forms-mode'.
;;; Code:
;;;; Mode Line
;;============
(defun aph/forms-show-minor-modes ()
"Show minor modes in `forms-mode' mode line.
Since `forms-mode' hijacks `minor-mode-alist' for its own
purposes, minor modes don't appear in the mode line in
`forms-mode'. This function fixes that, and is designed for use
in `forms-mode-hook'."
(kill-local-variable 'minor-mode-alist)
(setq-local minor-mode-alist
(cons '(forms-read-only " View")
minor-mode-alist)))
;;;; Templates
;;============
;;;###autoload
(defun aph/forms-create-from-template (template dir name)
"Make a new `forms-mode' database based on TEMPLATE.
Here, TEMPLATE is the path to an existing `forms-mode' control
file. A new control file named NAME.ctrl is created in DIR, as
well as an empty database file NAME.db. The resulting database
uses `load-file' to inherit all behavior except the value of
`forms-file' from TEMPLATE.
After the file is created, open it in `forms-mode'."
(interactive "fCreate database from template:
DCreate database in directory:
sName for new database: ")
(let ((control-file (expand-file-name (format "%s.ctrl" name) dir)))
(with-temp-buffer
(insert (concat ";; -*- mode: emacs-lisp -*-\n"
"\n"
(format "(load-file %S)\n" template)
(format "(setq forms-file \"%s.db\")\n" name)
"\n"
(format ";;; %s.ctrl ends here" name)))
(write-region nil nil control-file nil nil nil :new))
(forms-find-file control-file)))
(provide 'aph-forms)
;;; aph-forms.el ends here