annotate lisp/prim/options.el @ 4:b82b59fe008d r19-15b3

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