0
|
1 ;;; options.el --- edit Options command for XEmacs.
|
|
2
|
|
3 ;; Copyright (C) 1985, 1993 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Maintainer: FSF
|
|
6
|
|
7 ;; This file is part of XEmacs.
|
|
8
|
|
9 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
10 ;; under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 ;; General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
4
|
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
22 ;; 02111-1307, USA.
|
0
|
23
|
4
|
24 ;;; Synched up with: FSF 19.34.
|
0
|
25
|
|
26 ;;; Commentary:
|
|
27
|
|
28 ;; This code provides functions to list and edit the values of all global
|
|
29 ;; option variables known to loaded Emacs Lisp code. There are two entry
|
|
30 ;; points, `list-options' and `edit' options'. The latter enters a major
|
|
31 ;; mode specifically for editing option values. Do `M-x describe-mode' in
|
|
32 ;; that context for more details.
|
|
33
|
|
34 ;;; Code:
|
|
35
|
|
36 ;;;###autoload
|
|
37 (defun list-options ()
|
|
38 "Display a list of XEmacs user options, with values and documentation."
|
|
39 (interactive)
|
|
40 (save-excursion
|
|
41 (set-buffer (get-buffer-create "*List Options*"))
|
|
42 (Edit-options-mode))
|
|
43 (with-output-to-temp-buffer "*List Options*"
|
|
44 (let (vars)
|
4
|
45 (mapatoms #'(lambda (sym) ; XEmacs
|
0
|
46 (if (user-variable-p sym)
|
|
47 (setq vars (cons sym vars)))))
|
|
48 (setq vars (sort vars 'string-lessp))
|
|
49 (while vars
|
|
50 (let ((sym (car vars)))
|
|
51 (princ ";; ")
|
|
52 (prin1 sym)
|
|
53 (princ ":\n\t")
|
4
|
54 (if (boundp sym) ; XEmacs
|
0
|
55 (prin1 (symbol-value sym))
|
|
56 (princ "#<unbound>"))
|
|
57 (terpri)
|
|
58 (princ (substitute-command-keys
|
|
59 (documentation-property sym 'variable-documentation)))
|
|
60 (princ "\n;;\n"))
|
|
61 (setq vars (cdr vars)))))
|
|
62 (save-excursion
|
|
63 (set-buffer "*List Options*")
|
|
64 (setq buffer-read-only t)))
|
|
65
|
|
66 ;;;###autoload
|
|
67 (defun edit-options ()
|
|
68 "Edit a list of XEmacs user option values.
|
|
69 Selects a buffer containing such a list,
|
|
70 in which there are commands to set the option values.
|
|
71 Type \\[describe-mode] in that buffer for a list of commands."
|
|
72 (interactive)
|
|
73 (list-options)
|
|
74 (pop-to-buffer "*List Options*"))
|
|
75
|
|
76 (defvar Edit-options-mode-map
|
|
77 (let ((map (make-keymap)))
|
|
78 (define-key map "s" 'Edit-options-set)
|
|
79 (define-key map "x" 'Edit-options-toggle)
|
|
80 (define-key map "1" 'Edit-options-t)
|
|
81 (define-key map "0" 'Edit-options-nil)
|
|
82 (define-key map "p" 'backward-paragraph)
|
|
83 (define-key map " " 'forward-paragraph)
|
|
84 (define-key map "n" 'forward-paragraph)
|
|
85 map)
|
|
86 "")
|
|
87
|
|
88 ;; Edit Options mode is suitable only for specially formatted data.
|
|
89 (put 'Edit-options-mode 'mode-class 'special)
|
|
90
|
|
91 (defun Edit-options-mode ()
|
|
92 "\\<Edit-options-mode-map>\
|
|
93 Major mode for editing XEmacs user option settings.
|
|
94 Special commands are:
|
|
95 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
|
|
96 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
|
|
97 \\[Edit-options-t] -- set variable to t.
|
|
98 \\[Edit-options-nil] -- set variable to nil.
|
|
99 Changed values made by these commands take effect immediately.
|
|
100
|
|
101 Each variable description is a paragraph.
|
|
102 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs."
|
|
103 (kill-all-local-variables)
|
|
104 (set-syntax-table emacs-lisp-mode-syntax-table)
|
|
105 (use-local-map Edit-options-mode-map)
|
|
106 (make-local-variable 'paragraph-separate)
|
|
107 (setq paragraph-separate "[^\^@-\^?]")
|
|
108 (make-local-variable 'paragraph-start)
|
|
109 (setq paragraph-start "\t")
|
|
110 (setq truncate-lines t)
|
|
111 (setq major-mode 'Edit-options-mode)
|
4
|
112 (setq mode-name (gettext "Options")) ; XEmacs
|
0
|
113 (run-hooks 'Edit-options-mode-hook))
|
|
114
|
|
115 (defun Edit-options-set () (interactive)
|
|
116 (Edit-options-modify
|
4
|
117 '(lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": ")))))
|
0
|
118
|
|
119 (defun Edit-options-toggle () (interactive)
|
|
120 (Edit-options-modify '(lambda (var) (not (symbol-value var)))))
|
|
121
|
|
122 (defun Edit-options-t () (interactive)
|
|
123 (Edit-options-modify '(lambda (var) t)))
|
|
124
|
|
125 (defun Edit-options-nil () (interactive)
|
|
126 (Edit-options-modify '(lambda (var) nil)))
|
|
127
|
|
128 (defun Edit-options-modify (modfun)
|
|
129 (save-excursion
|
|
130 (let ((buffer-read-only nil) var pos)
|
|
131 (re-search-backward "^;; \\|\\`")
|
|
132 (forward-char 3)
|
|
133 (setq pos (point))
|
|
134 (save-restriction
|
4
|
135 (narrow-to-region pos (progn (end-of-line) (1- (point))))
|
|
136 (goto-char pos)
|
|
137 (setq var (read (current-buffer))))
|
0
|
138 (goto-char pos)
|
|
139 (forward-line 1)
|
|
140 (forward-char 1)
|
|
141 (save-excursion
|
4
|
142 (set var (funcall modfun var)))
|
0
|
143 (kill-sexp 1)
|
|
144 (prin1 (symbol-value var) (current-buffer)))))
|
|
145
|
|
146 ;;; options.el ends here
|