1 ;;; options.el --- edit Options command for Emacs
3 ;; Copyright (C) 1985, 2001-2011 Free Software Foundation, Inc.
7 ;; This file is part of GNU Emacs.
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
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This file has been obsolete since Emacs 22.1.
26 ;; This code provides functions to list and edit the values of all global
27 ;; option variables known to loaded Emacs Lisp code. There are two entry
28 ;; points, `list-options' and `edit' options'. The latter enters a major
29 ;; mode specifically for editing option values. Do `M-x describe-mode' in
30 ;; that context for more details.
32 ;; The customization buffer feature is intended to make this obsolete.
37 (defun list-options ()
38 "Display a list of Emacs user options, with values and documentation.
39 It is now better to use Customize instead."
41 (with-output-to-temp-buffer "*List Options*"
43 (princ "This facility is obsolete; we recommend using M-x customize instead.")
45 (mapatoms (function (lambda (sym)
46 (if (user-variable-p sym
)
47 (setq vars
(cons sym vars
))))))
48 (setq vars
(sort vars
'string-lessp
))
50 (let ((sym (car vars
)))
55 (prin1 (symbol-value sym
))
57 (princ (substitute-command-keys
58 (documentation-property sym
'variable-documentation
)))
60 (setq vars
(cdr vars
))))
61 (with-current-buffer "*List Options*"
63 (setq buffer-read-only t
)))))
66 (defun edit-options ()
67 "Edit a list of Emacs 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.
72 The Custom feature is intended to make this obsolete."
75 (pop-to-buffer "*List Options*"))
77 (defvar Edit-options-mode-map
78 (let ((map (make-keymap)))
79 (define-key map
"s" 'Edit-options-set
)
80 (define-key map
"x" 'Edit-options-toggle
)
81 (define-key map
"1" 'Edit-options-t
)
82 (define-key map
"0" 'Edit-options-nil
)
83 (define-key map
"p" 'backward-paragraph
)
84 (define-key map
" " 'forward-paragraph
)
85 (define-key map
"n" 'forward-paragraph
)
89 ;; Edit Options mode is suitable only for specially formatted data.
90 (put 'Edit-options-mode
'mode-class
'special
)
92 (defun Edit-options-mode ()
93 "\\<Edit-options-mode-map>\
94 Major mode for editing Emacs user option settings.
96 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
97 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
98 \\[Edit-options-t] -- set variable to t.
99 \\[Edit-options-nil] -- set variable to nil.
100 Changed values made by these commands take effect immediately.
102 Each variable description is a paragraph.
103 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs."
104 (kill-all-local-variables)
105 (set-syntax-table emacs-lisp-mode-syntax-table
)
106 (use-local-map Edit-options-mode-map
)
107 (make-local-variable 'paragraph-separate
)
108 (setq paragraph-separate
"[^\^@-\^?]")
109 (make-local-variable 'paragraph-start
)
110 (setq paragraph-start
"\t")
111 (setq truncate-lines t
)
112 (setq major-mode
'Edit-options-mode
)
113 (setq mode-name
"Options")
114 (run-mode-hooks 'Edit-options-mode-hook
))
116 (defun Edit-options-set () (interactive)
118 (lambda (var) (eval-minibuffer (concat "New " (symbol-name var
) ": ")))))
120 (defun Edit-options-toggle () (interactive)
121 (Edit-options-modify (lambda (var) (not (symbol-value var
)))))
123 (defun Edit-options-t () (interactive)
124 (Edit-options-modify (lambda (var) t
)))
126 (defun Edit-options-nil () (interactive)
127 (Edit-options-modify (lambda (var) nil
)))
129 (defun Edit-options-modify (modfun)
131 (let ((buffer-read-only nil
) var pos
)
132 (re-search-backward "^;; \\|\\`")
136 (narrow-to-region pos
(progn (end-of-line) (1- (point))))
138 (setq var
(read (current-buffer))))
143 (set var
(funcall modfun var
)))
145 (prin1 (symbol-value var
) (current-buffer)))))
149 ;;; options.el ends here