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