]> code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/notes-first.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / notes-mode / notes-first.el
1 ;;; notes-first.el --- Setup notes-mode before first use
2
3 ;; Copyright (C) 2000-2006,2012 Free Software Foundation, Inc.
4
5 ;; Author: <johnh@isi.edu>.
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;;
25
26 ;;; Code:
27
28 (defvar notes-first-perl5-binary "perl"
29 "Location of the perl binary to invoke notesinit (must be perl v5).")
30
31 (defun notes-first-use-init ()
32 "Set up notes mode for the first time for a new user."
33 ;; note that we CAN'T assume the contents of notes-variables is loaded.
34 (if (y-or-n-p "Setup notes-mode with defaults? ")
35 (notes-first-run-notes-init)
36 (error (concat "Please run " notes-utility-dir "/notesinit by hand in a shell to customize defaults."))))
37
38 ;; xxx: eventually we might do something more sophisticated here
39 ;; (like asking the user questions directly).
40 (defun notes-first-run-notes-init ()
41 "Run notesinit with defaults."
42 (let*
43 ((notes-init-cmd (expand-file-name "notesinit" notes-utility-dir))
44 (process-environment
45 (cons (concat "NOTES_BIN_DIR=" (directory-file-name notes-utility-dir))
46 process-environment)))
47 (message (concat "Running \"" notes-first-perl5-binary notes-init-cmd "\" to set up notes-mode."))
48 (call-process notes-first-perl5-binary nil nil nil notes-init-cmd "-D"))
49 ;; ok, things are setup, but we want to lead the user to what to do next
50 ;; => start up on today's note
51 (message "Notes are now set up. Run M-x notes-index-todays-link to start."))
52
53 (provide 'notes-first)
54 ;;; notes-first.el ends here