annotate lisp/prim/options.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; This code provides functions to list and edit the values of all global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; option variables known to loaded Emacs Lisp code. There are two entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; points, `list-options' and `edit' options'. The latter enters a major
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; mode specifically for editing option values. Do `M-x describe-mode' in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; that context for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defun list-options ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "Display a list of XEmacs user options, with values and documentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (set-buffer (get-buffer-create "*List Options*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (Edit-options-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (with-output-to-temp-buffer "*List Options*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (mapatoms #'(lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (user-variable-p sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq vars (cons sym vars)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (setq vars (sort vars 'string-lessp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (while vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (let ((sym (car vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (princ ";; ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (prin1 sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (princ ":\n\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (if (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (prin1 (symbol-value sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (princ "#<unbound>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (princ (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (documentation-property sym 'variable-documentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (princ "\n;;\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (setq vars (cdr vars)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (set-buffer "*List Options*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setq buffer-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defun edit-options ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "Edit a list of XEmacs user option values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Selects a buffer containing such a list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 in which there are commands to set the option values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 Type \\[describe-mode] in that buffer for a list of commands."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (list-options)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (pop-to-buffer "*List Options*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvar Edit-options-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key map "s" 'Edit-options-set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key map "x" 'Edit-options-toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map "1" 'Edit-options-t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key map "0" 'Edit-options-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key map "p" 'backward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key map " " 'forward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "n" 'forward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; Edit Options mode is suitable only for specially formatted data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (put 'Edit-options-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defun Edit-options-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "\\<Edit-options-mode-map>\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Major mode for editing XEmacs user option settings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Special commands are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 \\[Edit-options-t] -- set variable to t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 \\[Edit-options-nil] -- set variable to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Changed values made by these commands take effect immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Each variable description is a paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 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
102 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (set-syntax-table emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (use-local-map Edit-options-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (setq paragraph-separate "[^\^@-\^?]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq paragraph-start "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq major-mode 'Edit-options-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq mode-name (gettext "Options"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (run-hooks 'Edit-options-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun Edit-options-set () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (Edit-options-modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 '(lambda (var) (eval-minibuffer (format "New %s:" (symbol-name var))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defun Edit-options-toggle () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (Edit-options-modify '(lambda (var) (not (symbol-value var)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun Edit-options-t () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (Edit-options-modify '(lambda (var) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun Edit-options-nil () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (Edit-options-modify '(lambda (var) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defun Edit-options-modify (modfun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let ((buffer-read-only nil) var pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (re-search-backward "^;; \\|\\`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (forward-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (narrow-to-region pos (progn (end-of-line) (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq var (read (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (set var (funcall modfun var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (kill-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (prin1 (symbol-value var) (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; options.el ends here