1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00
emacs/lisp/obsolete/options.el

141 lines
4.7 KiB
EmacsLisp
Raw Normal View History

2003-05-30 23:23:25 +00:00
;;; options.el --- edit Options command for Emacs
;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
2003-05-30 23:23:25 +00:00
;; Maintainer: emacs-devel@gnu.org
;; Obsolete-since: 22.1
2003-05-30 23:23:25 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
2003-05-30 23:23:25 +00:00
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
2003-05-30 23:23:25 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2003-05-30 23:23:25 +00:00
;;; Commentary:
;; This code provides functions to list and edit the values of all global
;; option variables known to loaded Emacs Lisp code. There are two entry
;; points, `list-options' and `edit' options'. The latter enters a major
;; mode specifically for editing option values. Do `M-x describe-mode' in
;; that context for more details.
;; The customization buffer feature is intended to make this obsolete.
;;; Code:
;;;###autoload
(defun list-options ()
"Display a list of Emacs user options, with values and documentation.
It is now better to use Customize instead."
(interactive)
(with-output-to-temp-buffer "*List Options*"
(let (vars)
(princ "This facility is obsolete; we recommend using M-x customize instead.")
2003-05-30 23:23:25 +00:00
(mapatoms (function (lambda (sym)
(if (custom-variable-p sym)
2003-05-30 23:23:25 +00:00
(setq vars (cons sym vars))))))
(setq vars (sort vars 'string-lessp))
(while vars
(let ((sym (car vars)))
(when (boundp sym)
(princ ";; ")
(prin1 sym)
(princ ":\n\t")
(prin1 (symbol-value sym))
(terpri)
(princ (substitute-command-keys
(documentation-property sym 'variable-documentation)))
(princ "\n;;\n"))
(setq vars (cdr vars))))
(with-current-buffer "*List Options*"
(Edit-options-mode)
(setq buffer-read-only t)))))
;;;###autoload
(defun edit-options ()
"Edit a list of Emacs user option values.
Selects a buffer containing such a list,
in which there are commands to set the option values.
Type \\[describe-mode] in that buffer for a list of commands.
The Custom feature is intended to make this obsolete."
(interactive)
(list-options)
(pop-to-buffer "*List Options*"))
(defvar Edit-options-mode-map
(let ((map (make-keymap)))
(define-key map "s" 'Edit-options-set)
(define-key map "x" 'Edit-options-toggle)
(define-key map "1" 'Edit-options-t)
(define-key map "0" 'Edit-options-nil)
(define-key map "p" 'backward-paragraph)
(define-key map " " 'forward-paragraph)
(define-key map "n" 'forward-paragraph)
map)
"")
;; Edit Options mode is suitable only for specially formatted data.
(put 'Edit-options-mode 'mode-class 'special)
Use define-derived-mode (and derived-mode-p). * lisp/play/snake.el (snake-mode): * lisp/play/mpuz.el (mpuz-mode): * lisp/play/landmark.el (lm-mode): * lisp/play/blackbox.el (blackbox-mode): * lisp/play/5x5.el (5x5-mode): * lisp/obsolete/options.el (Edit-options-mode): * lisp/net/quickurl.el (quickurl-list-mode): * lisp/net/newst-treeview.el (newsticker-treeview-mode): * lisp/mail/rmailsum.el (rmail-summary-mode): * lisp/mail/mspools.el (mspools-mode): * lisp/locate.el (locate-mode): * lisp/ibuffer.el (ibuffer-mode): * lisp/emulation/ws-mode.el (wordstar-mode): * lisp/emacs-lisp/debug.el (debugger-mode): * lisp/array.el (array-mode): * lisp/net/eudc.el (eudc-mode): Use define-derived-mode. * lisp/net/mairix.el (mairix-searches-mode-font-lock-keywords): Move initialization into declaration. (mairix-searches-mode): Use define-derived-mode. * lisp/net/eudc-hotlist.el (eudc-hotlist-mode): Use define-derived-mode. (eudc-edit-hotlist): Use dolist. * lisp/man.el (Man-mode-syntax-table): Rename from man-mode-syntax-table. (Man-mode): Use define-derived-mode. * lisp/info.el (Info-edit-mode-map): Rename from Info-edit-map. (Info-edit-mode): Use define-derived-mode. (Info-cease-edit): Use Info-mode. * lisp/eshell/esh-mode.el (eshell-mode-syntax-table): Move initialization into declaration. (eshell-mode): Use define-derived-mode. * lisp/chistory.el (command-history-mode-map): Rename from command-history-map. (command-history-mode): Use define-derived-mode. * lisp/calc/calc.el (calc-trail-mode-map): New var. (calc-trail-mode): Use define-derived-mode. (calc-trail-buffer): Set calc-main-buffer manually. * lisp/bookmark.el (bookmark-insert-annotation): New function. (bookmark-edit-annotation): Use it. (bookmark-edit-annotation-mode): Make it a proper major mode. (bookmark-send-edited-annotation): Use derived-mode-p. * lisp/arc-mode.el (archive-mode): Move kill-all-local-variables a tiny bit closer to its ideal place. Use \' to match EOS. * lisp/cedet/semantic/grammar.el (semantic-grammar-mode): Use define-derived-mode. (semantic-grammar-mode-syntax-table): Rename from semantic-grammar-syntax-table. (semantic-grammar-mode-map): Rename from semantic-grammar-map. * lisp/cedet/data-debug.el (data-debug-mode-map): Rename from data-debug-map. (data-debug-mode): Use define-derived-mode. * lisp/gnus/score-mode.el (gnus-score-mode-map): Move initialization into declaration. (gnus-score-mode): Use define-derived-mode. * lisp/gnus/gnus-srvr.el (gnus-browse-mode): Use define-derived-mode. * lisp/gnus/gnus-kill.el (gnus-kill-file-mode-map): Move initialization into declaration. (gnus-kill-file-mode): Use define-derived-mode. (gnus-kill-file-edit-file, gnus-kill-file-enter-kill, gnus-kill): Use derived-mode-p. * lisp/gnus/gnus-group.el (gnus-group-mode): Use define-derived-mode. (gnus-group-setup-buffer, gnus-group-name-at-point) (gnus-group-make-web-group, gnus-group-enter-directory) (gnus-group-suspend): Use derived-mode-p. * lisp/gnus/gnus-cus.el (gnus-custom-mode): Use define-derived-mode. * lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode): Use define-derived-mode. * lisp/gnus/gnus-art.el (gnus-article-mode): Use define-derived-mode. (gnus-article-setup-buffer, gnus-article-prepare) (gnus-article-prepare-display, gnus-sticky-article) (gnus-kill-sticky-article-buffer, gnus-kill-sticky-article-buffers) (gnus-bind-safe-url-regexp, gnus-article-check-buffer) (gnus-article-read-summary-keys): Use derived-mode-p.
2013-09-11 03:31:56 +00:00
(define-derived-mode Edit-options-mode emacs-lisp-mode "Options"
2003-05-30 23:23:25 +00:00
"\\<Edit-options-mode-map>\
Major mode for editing Emacs user option settings.
Special commands are:
\\[Edit-options-set] -- set variable point points at. New value read using minibuffer.
\\[Edit-options-toggle] -- toggle variable, t -> nil, nil -> t.
\\[Edit-options-t] -- set variable to t.
\\[Edit-options-nil] -- set variable to nil.
Changed values made by these commands take effect immediately.
Each variable description is a paragraph.
For convenience, the characters \\[backward-paragraph] and \\[forward-paragraph] move back and forward by paragraphs."
Use define-derived-mode (and derived-mode-p). * lisp/play/snake.el (snake-mode): * lisp/play/mpuz.el (mpuz-mode): * lisp/play/landmark.el (lm-mode): * lisp/play/blackbox.el (blackbox-mode): * lisp/play/5x5.el (5x5-mode): * lisp/obsolete/options.el (Edit-options-mode): * lisp/net/quickurl.el (quickurl-list-mode): * lisp/net/newst-treeview.el (newsticker-treeview-mode): * lisp/mail/rmailsum.el (rmail-summary-mode): * lisp/mail/mspools.el (mspools-mode): * lisp/locate.el (locate-mode): * lisp/ibuffer.el (ibuffer-mode): * lisp/emulation/ws-mode.el (wordstar-mode): * lisp/emacs-lisp/debug.el (debugger-mode): * lisp/array.el (array-mode): * lisp/net/eudc.el (eudc-mode): Use define-derived-mode. * lisp/net/mairix.el (mairix-searches-mode-font-lock-keywords): Move initialization into declaration. (mairix-searches-mode): Use define-derived-mode. * lisp/net/eudc-hotlist.el (eudc-hotlist-mode): Use define-derived-mode. (eudc-edit-hotlist): Use dolist. * lisp/man.el (Man-mode-syntax-table): Rename from man-mode-syntax-table. (Man-mode): Use define-derived-mode. * lisp/info.el (Info-edit-mode-map): Rename from Info-edit-map. (Info-edit-mode): Use define-derived-mode. (Info-cease-edit): Use Info-mode. * lisp/eshell/esh-mode.el (eshell-mode-syntax-table): Move initialization into declaration. (eshell-mode): Use define-derived-mode. * lisp/chistory.el (command-history-mode-map): Rename from command-history-map. (command-history-mode): Use define-derived-mode. * lisp/calc/calc.el (calc-trail-mode-map): New var. (calc-trail-mode): Use define-derived-mode. (calc-trail-buffer): Set calc-main-buffer manually. * lisp/bookmark.el (bookmark-insert-annotation): New function. (bookmark-edit-annotation): Use it. (bookmark-edit-annotation-mode): Make it a proper major mode. (bookmark-send-edited-annotation): Use derived-mode-p. * lisp/arc-mode.el (archive-mode): Move kill-all-local-variables a tiny bit closer to its ideal place. Use \' to match EOS. * lisp/cedet/semantic/grammar.el (semantic-grammar-mode): Use define-derived-mode. (semantic-grammar-mode-syntax-table): Rename from semantic-grammar-syntax-table. (semantic-grammar-mode-map): Rename from semantic-grammar-map. * lisp/cedet/data-debug.el (data-debug-mode-map): Rename from data-debug-map. (data-debug-mode): Use define-derived-mode. * lisp/gnus/score-mode.el (gnus-score-mode-map): Move initialization into declaration. (gnus-score-mode): Use define-derived-mode. * lisp/gnus/gnus-srvr.el (gnus-browse-mode): Use define-derived-mode. * lisp/gnus/gnus-kill.el (gnus-kill-file-mode-map): Move initialization into declaration. (gnus-kill-file-mode): Use define-derived-mode. (gnus-kill-file-edit-file, gnus-kill-file-enter-kill, gnus-kill): Use derived-mode-p. * lisp/gnus/gnus-group.el (gnus-group-mode): Use define-derived-mode. (gnus-group-setup-buffer, gnus-group-name-at-point) (gnus-group-make-web-group, gnus-group-enter-directory) (gnus-group-suspend): Use derived-mode-p. * lisp/gnus/gnus-cus.el (gnus-custom-mode): Use define-derived-mode. * lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode): Use define-derived-mode. * lisp/gnus/gnus-art.el (gnus-article-mode): Use define-derived-mode. (gnus-article-setup-buffer, gnus-article-prepare) (gnus-article-prepare-display, gnus-sticky-article) (gnus-kill-sticky-article-buffer, gnus-kill-sticky-article-buffers) (gnus-bind-safe-url-regexp, gnus-article-check-buffer) (gnus-article-read-summary-keys): Use derived-mode-p.
2013-09-11 03:31:56 +00:00
(setq-local paragraph-separate "[^\^@-\^?]")
(setq-local paragraph-start "\t")
(setq-local truncate-lines t))
2003-05-30 23:23:25 +00:00
(defun Edit-options-set () (interactive)
(Edit-options-modify
(lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": ")))))
(defun Edit-options-toggle () (interactive)
(Edit-options-modify (lambda (var) (not (symbol-value var)))))
(defun Edit-options-t () (interactive)
(Edit-options-modify (lambda (var) t)))
(defun Edit-options-nil () (interactive)
(Edit-options-modify (lambda (var) nil)))
(defun Edit-options-modify (modfun)
(save-excursion
(let ((buffer-read-only nil) var pos)
(re-search-backward "^;; \\|\\`")
(forward-char 3)
(setq pos (point))
(save-restriction
(narrow-to-region pos (progn (end-of-line) (1- (point))))
(goto-char pos)
(setq var (read (current-buffer))))
(goto-char pos)
(forward-line 1)
(forward-char 1)
(save-excursion
(set var (funcall modfun var)))
(kill-sexp 1)
(prin1 (symbol-value var) (current-buffer)))))
(provide 'options)
;;; options.el ends here