Mercurial > emacs
annotate lisp/options.el @ 790:47ec7c4c42bc
*** empty log message ***
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Thu, 16 Jul 1992 04:00:03 +0000 |
parents | 505130d1ddf8 |
children | 4f28bd14272c |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; options.el --- edit Options command for Emacs. |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
2 |
228 | 3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 1, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
21 | |
258 | 22 ;;;###autoload |
228 | 23 (defun list-options () |
24 "Display a list of Emacs user options, with values and documentation." | |
25 (interactive) | |
26 (save-excursion | |
27 (set-buffer (get-buffer-create "*List Options*")) | |
28 (Edit-options-mode)) | |
29 (with-output-to-temp-buffer "*List Options*" | |
30 (let (vars) | |
31 (mapatoms (function (lambda (sym) | |
32 (if (user-variable-p sym) | |
33 (setq vars (cons sym vars)))))) | |
34 (setq vars (sort vars 'string-lessp)) | |
35 (while vars | |
36 (let ((sym (car vars))) | |
37 (princ ";; ") | |
38 (prin1 sym) | |
39 (princ ":\n\t") | |
40 (prin1 (symbol-value sym)) | |
41 (terpri) | |
42 (princ (substitute-command-keys | |
43 (documentation-property sym 'variable-documentation))) | |
44 (princ "\n;;\n")) | |
45 (setq vars (cdr vars)))))) | |
46 | |
258 | 47 ;;;###autoload |
228 | 48 (defun edit-options () |
49 "Edit a list of Emacs user option values. | |
50 Selects a buffer containing such a list, | |
51 in which there are commands to set the option values. | |
52 Type \\[describe-mode] in that buffer for a list of commands." | |
53 (interactive) | |
54 (list-options) | |
55 (pop-to-buffer "*List Options*")) | |
56 | |
57 (defvar Edit-options-mode-map | |
58 (let ((map (make-keymap))) | |
59 (define-key map "s" 'Edit-options-set) | |
60 (define-key map "x" 'Edit-options-toggle) | |
61 (define-key map "1" 'Edit-options-t) | |
62 (define-key map "0" 'Edit-options-nil) | |
63 (define-key map "p" 'backward-paragraph) | |
64 (define-key map " " 'forward-paragraph) | |
65 (define-key map "n" 'forward-paragraph) | |
66 map) | |
67 "") | |
68 | |
69 ;; Edit Options mode is suitable only for specially formatted data. | |
70 (put 'Edit-options-mode 'mode-class 'special) | |
71 | |
72 (defun Edit-options-mode () | |
233 | 73 "\\<Edit-options-mode-map>\ |
74 Major mode for editing Emacs user option settings. | |
228 | 75 Special commands are: |
233 | 76 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer. |
77 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t. | |
78 \\[Edit-options-t] -- set variable to t. | |
79 \\[Edit-options-nil] -- set variable to nil. | |
228 | 80 Changed values made by these commands take effect immediately. |
81 | |
82 Each variable description is a paragraph. | |
233 | 83 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs." |
228 | 84 (kill-all-local-variables) |
85 (set-syntax-table emacs-lisp-mode-syntax-table) | |
86 (use-local-map Edit-options-mode-map) | |
87 (make-local-variable 'paragraph-separate) | |
88 (setq paragraph-separate "[^\^@-\^?]") | |
89 (make-local-variable 'paragraph-start) | |
90 (setq paragraph-start "^\t") | |
91 (setq truncate-lines t) | |
92 (setq major-mode 'Edit-options-mode) | |
93 (setq mode-name "Options") | |
94 (run-hooks 'Edit-options-mode-hook)) | |
95 | |
96 (defun Edit-options-set () (interactive) | |
97 (Edit-options-modify | |
98 '(lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": "))))) | |
99 | |
100 (defun Edit-options-toggle () (interactive) | |
101 (Edit-options-modify '(lambda (var) (not (symbol-value var))))) | |
102 | |
103 (defun Edit-options-t () (interactive) | |
104 (Edit-options-modify '(lambda (var) t))) | |
105 | |
106 (defun Edit-options-nil () (interactive) | |
107 (Edit-options-modify '(lambda (var) nil))) | |
108 | |
109 (defun Edit-options-modify (modfun) | |
110 (save-excursion | |
111 (let (var pos) | |
112 (re-search-backward "^;; \\|\\`") | |
113 (forward-char 3) | |
114 (setq pos (point)) | |
115 (save-restriction | |
116 (narrow-to-region pos (progn (end-of-line) (1- (point)))) | |
117 (goto-char pos) | |
118 (setq var (read (current-buffer)))) | |
119 (goto-char pos) | |
120 (forward-line 1) | |
121 (forward-char 1) | |
122 (save-excursion | |
123 (set var (funcall modfun var))) | |
124 (kill-sexp 1) | |
125 (prin1 (symbol-value var) (current-buffer))))) | |
126 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
127 ;;; options.el ends here |