1 ;; Edit Options command for Emacs.
2 ;; Copyright (C) 1985 Free Software Foundation, Inc.
4 ;; This file is part of GNU Emacs.
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 (defun list-options ()
23 "Display a list of Emacs user options, with values and documentation."
26 (set-buffer (get-buffer-create "*List Options*"))
28 (with-output-to-temp-buffer "*List Options*"
30 (mapatoms (function (lambda (sym)
31 (if (user-variable-p sym
)
32 (setq vars
(cons sym vars
))))))
33 (setq vars
(sort vars
'string-lessp
))
35 (let ((sym (car vars
)))
39 (prin1 (symbol-value sym
))
41 (princ (substitute-command-keys
42 (documentation-property sym
'variable-documentation
)))
44 (setq vars
(cdr vars
))))))
47 (defun edit-options ()
48 "Edit a list of Emacs user option values.
49 Selects a buffer containing such a list,
50 in which there are commands to set the option values.
51 Type \\[describe-mode] in that buffer for a list of commands."
54 (pop-to-buffer "*List Options*"))
56 (defvar Edit-options-mode-map
57 (let ((map (make-keymap)))
58 (define-key map
"s" 'Edit-options-set
)
59 (define-key map
"x" 'Edit-options-toggle
)
60 (define-key map
"1" 'Edit-options-t
)
61 (define-key map
"0" 'Edit-options-nil
)
62 (define-key map
"p" 'backward-paragraph
)
63 (define-key map
" " 'forward-paragraph
)
64 (define-key map
"n" 'forward-paragraph
)
68 ;; Edit Options mode is suitable only for specially formatted data.
69 (put 'Edit-options-mode
'mode-class
'special
)
71 (defun Edit-options-mode ()
72 "\\<Edit-options-mode-map>\
73 Major mode for editing Emacs user option settings.
75 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
76 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
77 \\[Edit-options-t] -- set variable to t.
78 \\[Edit-options-nil] -- set variable to nil.
79 Changed values made by these commands take effect immediately.
81 Each variable description is a paragraph.
82 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs."
83 (kill-all-local-variables)
84 (set-syntax-table emacs-lisp-mode-syntax-table
)
85 (use-local-map Edit-options-mode-map
)
86 (make-local-variable 'paragraph-separate
)
87 (setq paragraph-separate
"[^\^@-\^?]")
88 (make-local-variable 'paragraph-start
)
89 (setq paragraph-start
"^\t")
90 (setq truncate-lines t
)
91 (setq major-mode
'Edit-options-mode
)
92 (setq mode-name
"Options")
93 (run-hooks 'Edit-options-mode-hook
))
95 (defun Edit-options-set () (interactive)
97 '(lambda (var) (eval-minibuffer (concat "New " (symbol-name var
) ": ")))))
99 (defun Edit-options-toggle () (interactive)
100 (Edit-options-modify '(lambda (var) (not (symbol-value var
)))))
102 (defun Edit-options-t () (interactive)
103 (Edit-options-modify '(lambda (var) t
)))
105 (defun Edit-options-nil () (interactive)
106 (Edit-options-modify '(lambda (var) nil
)))
108 (defun Edit-options-modify (modfun)
111 (re-search-backward "^;; \\|\\`")
115 (narrow-to-region pos
(progn (end-of-line) (1- (point))))
117 (setq var
(read (current-buffer))))
122 (set var
(funcall modfun var
)))
124 (prin1 (symbol-value var
) (current-buffer)))))