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