annotate lisp/obsolete/options.el @ 90224:2d92f5c9d6ae

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-78 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 514-518) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 104-105) - Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 26 Aug 2005 09:51:52 +0000
parents f9a65d7ebd29 5b1a238fcbb4
children c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; options.el --- edit Options command for Emacs
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1985, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
4
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5 ;; Maintainer: FSF
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
6
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
12 ;; any later version.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
13
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62769
diff changeset
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62769
diff changeset
22 ;; Boston, MA 02110-1301, USA.
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
24 ;;; Commentary:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
26 ;; This code provides functions to list and edit the values of all global
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27 ;; option variables known to loaded Emacs Lisp code. There are two entry
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
28 ;; points, `list-options' and `edit' options'. The latter enters a major
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
29 ;; mode specifically for editing option values. Do `M-x describe-mode' in
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30 ;; that context for more details.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
31
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
32 ;; The customization buffer feature is intended to make this obsolete.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
33
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
34 ;;; Code:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
35
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
36 ;;;###autoload
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
37 (defun list-options ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
38 "Display a list of Emacs user options, with values and documentation.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
39 It is now better to use Customize instead."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
40 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
41 (with-output-to-temp-buffer "*List Options*"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
42 (let (vars)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
43 (mapatoms (function (lambda (sym)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
44 (if (user-variable-p sym)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
45 (setq vars (cons sym vars))))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
46 (setq vars (sort vars 'string-lessp))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
47 (while vars
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
48 (let ((sym (car vars)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
49 (when (boundp sym)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
50 (princ ";; ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
51 (prin1 sym)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
52 (princ ":\n\t")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
53 (prin1 (symbol-value sym))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
54 (terpri)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
55 (princ (substitute-command-keys
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
56 (documentation-property sym 'variable-documentation)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
57 (princ "\n;;\n"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
58 (setq vars (cdr vars))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
59 (with-current-buffer "*List Options*"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60 (Edit-options-mode)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 (setq buffer-read-only t)))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
63 ;;;###autoload
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64 (defun edit-options ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65 "Edit a list of Emacs user option values.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66 Selects a buffer containing such a list,
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67 in which there are commands to set the option values.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 Type \\[describe-mode] in that buffer for a list of commands.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70 The Custom feature is intended to make this obsolete."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72 (list-options)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 (pop-to-buffer "*List Options*"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 (defvar Edit-options-mode-map
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
76 (let ((map (make-keymap)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
77 (define-key map "s" 'Edit-options-set)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
78 (define-key map "x" 'Edit-options-toggle)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
79 (define-key map "1" 'Edit-options-t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80 (define-key map "0" 'Edit-options-nil)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81 (define-key map "p" 'backward-paragraph)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 (define-key map " " 'forward-paragraph)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 (define-key map "n" 'forward-paragraph)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
84 map)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
85 "")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
86
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
87 ;; Edit Options mode is suitable only for specially formatted data.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
88 (put 'Edit-options-mode 'mode-class 'special)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
89
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
90 (defun Edit-options-mode ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
91 "\\<Edit-options-mode-map>\
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92 Major mode for editing Emacs user option settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93 Special commands are:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
95 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
96 \\[Edit-options-t] -- set variable to t.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
97 \\[Edit-options-nil] -- set variable to nil.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
98 Changed values made by these commands take effect immediately.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
99
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
100 Each variable description is a paragraph.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
101 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
102 (kill-all-local-variables)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103 (set-syntax-table emacs-lisp-mode-syntax-table)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
104 (use-local-map Edit-options-mode-map)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
105 (make-local-variable 'paragraph-separate)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
106 (setq paragraph-separate "[^\^@-\^?]")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
107 (make-local-variable 'paragraph-start)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
108 (setq paragraph-start "\t")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
109 (setq truncate-lines t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 (setq major-mode 'Edit-options-mode)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
111 (setq mode-name "Options")
62769
a1fa16a75bde * obsolete/ooutline.el (outline-mode):
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
112 (run-mode-hooks 'Edit-options-mode-hook))
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
113
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
114 (defun Edit-options-set () (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
115 (Edit-options-modify
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
116 (lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": ")))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
117
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
118 (defun Edit-options-toggle () (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
119 (Edit-options-modify (lambda (var) (not (symbol-value var)))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
120
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
121 (defun Edit-options-t () (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
122 (Edit-options-modify (lambda (var) t)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
123
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
124 (defun Edit-options-nil () (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
125 (Edit-options-modify (lambda (var) nil)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
126
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
127 (defun Edit-options-modify (modfun)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
128 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
129 (let ((buffer-read-only nil) var pos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
130 (re-search-backward "^;; \\|\\`")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
131 (forward-char 3)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
132 (setq pos (point))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
133 (save-restriction
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
134 (narrow-to-region pos (progn (end-of-line) (1- (point))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
135 (goto-char pos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
136 (setq var (read (current-buffer))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
137 (goto-char pos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
138 (forward-line 1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
139 (forward-char 1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141 (set var (funcall modfun var)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 (kill-sexp 1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 (prin1 (symbol-value var) (current-buffer)))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145 (provide 'options)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51342
diff changeset
147 ;;; arch-tag: d18211a1-f3fb-48c9-a449-d5acde406a3c
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
148 ;;; options.el ends here