Mercurial > emacs
annotate lisp/options.el @ 4543:929e4c850e76
(term_get_fkeys_define_1, term_get_fkeys_define): New functions.
(term_get_fkeys): Use them.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 11 Aug 1993 04:09:28 +0000 |
parents | f287613dfc28 |
children | b808c61b7ee1 |
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 | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
23 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
24 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 ;; 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
|
26 ;; 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
|
27 ;; 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
|
28 ;; 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
|
29 ;; that context for more details. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
31 ;;; Code: |
228 | 32 |
258 | 33 ;;;###autoload |
228 | 34 (defun list-options () |
35 "Display a list of Emacs user options, with values and documentation." | |
36 (interactive) | |
37 (save-excursion | |
38 (set-buffer (get-buffer-create "*List Options*")) | |
39 (Edit-options-mode)) | |
40 (with-output-to-temp-buffer "*List Options*" | |
41 (let (vars) | |
42 (mapatoms (function (lambda (sym) | |
43 (if (user-variable-p sym) | |
44 (setq vars (cons sym vars)))))) | |
45 (setq vars (sort vars 'string-lessp)) | |
46 (while vars | |
47 (let ((sym (car vars))) | |
48 (princ ";; ") | |
49 (prin1 sym) | |
50 (princ ":\n\t") | |
51 (prin1 (symbol-value sym)) | |
52 (terpri) | |
53 (princ (substitute-command-keys | |
54 (documentation-property sym 'variable-documentation))) | |
55 (princ "\n;;\n")) | |
56 (setq vars (cdr vars)))))) | |
57 | |
258 | 58 ;;;###autoload |
228 | 59 (defun edit-options () |
60 "Edit a list of Emacs user option values. | |
61 Selects a buffer containing such a list, | |
62 in which there are commands to set the option values. | |
63 Type \\[describe-mode] in that buffer for a list of commands." | |
64 (interactive) | |
65 (list-options) | |
66 (pop-to-buffer "*List Options*")) | |
67 | |
68 (defvar Edit-options-mode-map | |
69 (let ((map (make-keymap))) | |
70 (define-key map "s" 'Edit-options-set) | |
71 (define-key map "x" 'Edit-options-toggle) | |
72 (define-key map "1" 'Edit-options-t) | |
73 (define-key map "0" 'Edit-options-nil) | |
74 (define-key map "p" 'backward-paragraph) | |
75 (define-key map " " 'forward-paragraph) | |
76 (define-key map "n" 'forward-paragraph) | |
77 map) | |
78 "") | |
79 | |
80 ;; Edit Options mode is suitable only for specially formatted data. | |
81 (put 'Edit-options-mode 'mode-class 'special) | |
82 | |
83 (defun Edit-options-mode () | |
233 | 84 "\\<Edit-options-mode-map>\ |
85 Major mode for editing Emacs user option settings. | |
228 | 86 Special commands are: |
233 | 87 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer. |
88 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t. | |
89 \\[Edit-options-t] -- set variable to t. | |
90 \\[Edit-options-nil] -- set variable to nil. | |
228 | 91 Changed values made by these commands take effect immediately. |
92 | |
93 Each variable description is a paragraph. | |
233 | 94 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs." |
228 | 95 (kill-all-local-variables) |
96 (set-syntax-table emacs-lisp-mode-syntax-table) | |
97 (use-local-map Edit-options-mode-map) | |
98 (make-local-variable 'paragraph-separate) | |
99 (setq paragraph-separate "[^\^@-\^?]") | |
100 (make-local-variable 'paragraph-start) | |
101 (setq paragraph-start "^\t") | |
102 (setq truncate-lines t) | |
103 (setq major-mode 'Edit-options-mode) | |
104 (setq mode-name "Options") | |
105 (run-hooks 'Edit-options-mode-hook)) | |
106 | |
107 (defun Edit-options-set () (interactive) | |
108 (Edit-options-modify | |
109 '(lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": "))))) | |
110 | |
111 (defun Edit-options-toggle () (interactive) | |
112 (Edit-options-modify '(lambda (var) (not (symbol-value var))))) | |
113 | |
114 (defun Edit-options-t () (interactive) | |
115 (Edit-options-modify '(lambda (var) t))) | |
116 | |
117 (defun Edit-options-nil () (interactive) | |
118 (Edit-options-modify '(lambda (var) nil))) | |
119 | |
120 (defun Edit-options-modify (modfun) | |
121 (save-excursion | |
122 (let (var pos) | |
123 (re-search-backward "^;; \\|\\`") | |
124 (forward-char 3) | |
125 (setq pos (point)) | |
126 (save-restriction | |
127 (narrow-to-region pos (progn (end-of-line) (1- (point)))) | |
128 (goto-char pos) | |
129 (setq var (read (current-buffer)))) | |
130 (goto-char pos) | |
131 (forward-line 1) | |
132 (forward-char 1) | |
133 (save-excursion | |
134 (set var (funcall modfun var))) | |
135 (kill-sexp 1) | |
136 (prin1 (symbol-value var) (current-buffer))))) | |
137 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
138 ;;; options.el ends here |