Mercurial > emacs
annotate lisp/options.el @ 42811:cf0c0ef57504
*** empty log message ***
| author | Jason Rumney <jasonr@gnu.org> |
|---|---|
| date | Thu, 17 Jan 2002 19:29:24 +0000 |
| parents | 253f761ad37b |
| children | e88404e8f2cf |
| rev | line source |
|---|---|
|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Jan?k <Pavel@Janik.cz>
parents:
32289
diff
changeset
|
1 ;;; options.el --- edit Options command for Emacs |
|
659
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 |
| 18383 | 32 ;; The customization buffer feature is intended to make this obsolete. |
| 33 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
34 ;;; Code: |
| 228 | 35 |
| 258 | 36 ;;;###autoload |
| 228 | 37 (defun list-options () |
|
32289
1c042b411eda
(list-options): Doc that you should use customize.
Dave Love <fx@gnu.org>
parents:
30886
diff
changeset
|
38 "Display a list of Emacs user options, with values and documentation. |
|
1c042b411eda
(list-options): Doc that you should use customize.
Dave Love <fx@gnu.org>
parents:
30886
diff
changeset
|
39 It is now better to use Customize instead." |
| 228 | 40 (interactive) |
| 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))) | |
| 24429 | 49 (when (boundp sym) |
| 50 (princ ";; ") | |
| 51 (prin1 sym) | |
| 52 (princ ":\n\t") | |
| 53 (prin1 (symbol-value sym)) | |
| 54 (terpri) | |
| 55 (princ (substitute-command-keys | |
| 56 (documentation-property sym 'variable-documentation))) | |
| 57 (princ "\n;;\n")) | |
| 58 (setq vars (cdr vars)))) | |
| 59 (with-current-buffer "*List Options*" | |
| 60 (Edit-options-mode) | |
| 61 (setq buffer-read-only t))))) | |
| 228 | 62 |
| 258 | 63 ;;;###autoload |
| 228 | 64 (defun edit-options () |
| 65 "Edit a list of Emacs user option values. | |
| 66 Selects a buffer containing such a list, | |
| 67 in which there are commands to set the option values. | |
| 24429 | 68 Type \\[describe-mode] in that buffer for a list of commands. |
| 69 | |
| 70 The Custom feature is intended to make this obsolete." | |
| 228 | 71 (interactive) |
| 72 (list-options) | |
| 73 (pop-to-buffer "*List Options*")) | |
| 74 | |
| 75 (defvar Edit-options-mode-map | |
| 76 (let ((map (make-keymap))) | |
| 77 (define-key map "s" 'Edit-options-set) | |
| 78 (define-key map "x" 'Edit-options-toggle) | |
| 79 (define-key map "1" 'Edit-options-t) | |
| 80 (define-key map "0" 'Edit-options-nil) | |
| 81 (define-key map "p" 'backward-paragraph) | |
| 82 (define-key map " " 'forward-paragraph) | |
| 83 (define-key map "n" 'forward-paragraph) | |
| 84 map) | |
| 85 "") | |
| 86 | |
| 87 ;; Edit Options mode is suitable only for specially formatted data. | |
| 88 (put 'Edit-options-mode 'mode-class 'special) | |
| 89 | |
| 90 (defun Edit-options-mode () | |
| 233 | 91 "\\<Edit-options-mode-map>\ |
| 92 Major mode for editing Emacs user option settings. | |
| 228 | 93 Special commands are: |
| 233 | 94 \\[Edit-options-set] -- set variable point points at. New value read using minibuffer. |
| 95 \\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t. | |
| 96 \\[Edit-options-t] -- set variable to t. | |
| 97 \\[Edit-options-nil] -- set variable to nil. | |
| 228 | 98 Changed values made by these commands take effect immediately. |
| 99 | |
| 100 Each variable description is a paragraph. | |
| 233 | 101 For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs." |
| 228 | 102 (kill-all-local-variables) |
| 103 (set-syntax-table emacs-lisp-mode-syntax-table) | |
| 104 (use-local-map Edit-options-mode-map) | |
| 105 (make-local-variable 'paragraph-separate) | |
| 106 (setq paragraph-separate "[^\^@-\^?]") | |
| 107 (make-local-variable 'paragraph-start) | |
|
10887
b808c61b7ee1
(Edit-options-mode): Remove ^ from paragraph-start.
Boris Goldowsky <boris@gnu.org>
parents:
2308
diff
changeset
|
108 (setq paragraph-start "\t") |
| 228 | 109 (setq truncate-lines t) |
| 110 (setq major-mode 'Edit-options-mode) | |
| 111 (setq mode-name "Options") | |
| 112 (run-hooks 'Edit-options-mode-hook)) | |
| 113 | |
| 114 (defun Edit-options-set () (interactive) | |
| 115 (Edit-options-modify | |
|
30886
207eba858980
(Edit-options-{set,toggle,t,nil}): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24429
diff
changeset
|
116 (lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": "))))) |
| 228 | 117 |
| 118 (defun Edit-options-toggle () (interactive) | |
|
30886
207eba858980
(Edit-options-{set,toggle,t,nil}): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24429
diff
changeset
|
119 (Edit-options-modify (lambda (var) (not (symbol-value var))))) |
| 228 | 120 |
| 121 (defun Edit-options-t () (interactive) | |
|
30886
207eba858980
(Edit-options-{set,toggle,t,nil}): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24429
diff
changeset
|
122 (Edit-options-modify (lambda (var) t))) |
| 228 | 123 |
| 124 (defun Edit-options-nil () (interactive) | |
|
30886
207eba858980
(Edit-options-{set,toggle,t,nil}): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24429
diff
changeset
|
125 (Edit-options-modify (lambda (var) nil))) |
| 228 | 126 |
| 127 (defun Edit-options-modify (modfun) | |
| 128 (save-excursion | |
|
11027
21761da820cd
(edit-options): Make the buffer read-only.
Richard M. Stallman <rms@gnu.org>
parents:
10887
diff
changeset
|
129 (let ((buffer-read-only nil) var pos) |
| 228 | 130 (re-search-backward "^;; \\|\\`") |
| 131 (forward-char 3) | |
| 132 (setq pos (point)) | |
| 133 (save-restriction | |
| 134 (narrow-to-region pos (progn (end-of-line) (1- (point)))) | |
| 135 (goto-char pos) | |
| 136 (setq var (read (current-buffer)))) | |
| 137 (goto-char pos) | |
| 138 (forward-line 1) | |
| 139 (forward-char 1) | |
| 140 (save-excursion | |
| 141 (set var (funcall modfun var))) | |
| 142 (kill-sexp 1) | |
| 143 (prin1 (symbol-value var) (current-buffer))))) | |
| 144 | |
| 18383 | 145 (provide 'options) |
| 146 | |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
147 ;;; options.el ends here |
