Annotation of 43BSDReno/contrib/emacs-18.55/lisp/options.el, revision 1.1

1.1     ! root        1: ;; Edit Options command for Emacs.
        !             2: ;; Copyright (C) 1985 Free Software Foundation, Inc.
        !             3: 
        !             4: ;; This file is part of GNU Emacs.
        !             5: 
        !             6: ;; GNU Emacs is distributed in the hope that it will be useful,
        !             7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
        !             8: ;; accepts responsibility to anyone for the consequences of using it
        !             9: ;; or for whether it serves any particular purpose or works at all,
        !            10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
        !            11: ;; License for full details.
        !            12: 
        !            13: ;; Everyone is granted permission to copy, modify and redistribute
        !            14: ;; GNU Emacs, but only under the conditions described in the
        !            15: ;; GNU Emacs General Public License.   A copy of this license is
        !            16: ;; supposed to have been given to you along with GNU Emacs so you
        !            17: ;; can know your rights and responsibilities.  It should be in a
        !            18: ;; file named COPYING.  Among other things, the copyright notice
        !            19: ;; and this notice must be preserved on all copies.
        !            20: 
        !            21: 
        !            22: (defun list-options ()
        !            23:   "Display a list of Emacs user options, with values and documentation."
        !            24:   (interactive)
        !            25:   (save-excursion
        !            26:     (set-buffer (get-buffer-create "*List Options*"))
        !            27:     (Edit-options-mode))
        !            28:   (with-output-to-temp-buffer "*List Options*"
        !            29:     (let (vars)
        !            30:       (mapatoms (function (lambda (sym)
        !            31:                            (if (user-variable-p sym)
        !            32:                                (setq vars (cons sym vars))))))
        !            33:       (setq vars (sort vars 'string-lessp))
        !            34:       (while vars
        !            35:        (let ((sym (car vars)))
        !            36:          (princ ";; ")
        !            37:          (prin1 sym)
        !            38:          (princ ":\n\t")
        !            39:          (prin1 (symbol-value sym))
        !            40:          (terpri)
        !            41:          (princ (substitute-command-keys 
        !            42:                  (documentation-property sym 'variable-documentation)))
        !            43:          (princ "\n;;\n"))
        !            44:        (setq vars (cdr vars))))))
        !            45: 
        !            46: (defun edit-options ()
        !            47:   "Edit a list of Emacs user option values.
        !            48: Selects a buffer containing such a list,
        !            49: in which there are commands to set the option values.
        !            50: Type \\[describe-mode] in that buffer for a list of commands."
        !            51:   (interactive)
        !            52:   (list-options)
        !            53:   (pop-to-buffer "*List Options*"))
        !            54: 
        !            55: (defvar Edit-options-mode-map
        !            56:   (let ((map (make-keymap)))
        !            57:     (define-key map "s" 'Edit-options-set)
        !            58:     (define-key map "x" 'Edit-options-toggle)
        !            59:     (define-key map "1" 'Edit-options-t)
        !            60:     (define-key map "0" 'Edit-options-nil)
        !            61:     (define-key map "p" 'backward-paragraph)
        !            62:     (define-key map " " 'forward-paragraph)
        !            63:     (define-key map "n" 'forward-paragraph)
        !            64:     map)
        !            65:   "")
        !            66: 
        !            67: ;; Edit Options mode is suitable only for specially formatted data.
        !            68: (put 'Edit-options-mode 'mode-class 'special)
        !            69: 
        !            70: (defun Edit-options-mode ()
        !            71:   "Major mode for editing Emacs user option settings.
        !            72: Special commands are:
        !            73: s -- set variable point points at.  New value read using minibuffer.
        !            74: x -- toggle variable, t -> nil, nil -> t.
        !            75: 1 -- set variable to t.
        !            76: 0 -- set variable to nil.
        !            77: Each variable description is a paragraph.
        !            78: For convenience, the characters p and n move back and forward by paragraphs."
        !            79:   (kill-all-local-variables)
        !            80:   (set-syntax-table emacs-lisp-mode-syntax-table)
        !            81:   (use-local-map Edit-options-mode-map)
        !            82:   (make-local-variable 'paragraph-separate)
        !            83:   (setq paragraph-separate "[^\^@-\^?]")
        !            84:   (make-local-variable 'paragraph-start)
        !            85:   (setq paragraph-start "^\t")
        !            86:   (setq truncate-lines t)
        !            87:   (setq major-mode 'Edit-options-mode)
        !            88:   (setq mode-name "Options"))
        !            89: 
        !            90: (defun Edit-options-set () (interactive)
        !            91:   (Edit-options-modify
        !            92:    '(lambda (var) (eval-minibuffer (concat "New " (symbol-name var) ": ")))))
        !            93: 
        !            94: (defun Edit-options-toggle () (interactive)
        !            95:   (Edit-options-modify '(lambda (var) (not (symbol-value var)))))
        !            96: 
        !            97: (defun Edit-options-t () (interactive)
        !            98:   (Edit-options-modify '(lambda (var) t)))
        !            99: 
        !           100: (defun Edit-options-nil () (interactive)
        !           101:   (Edit-options-modify '(lambda (var) nil)))
        !           102: 
        !           103: (defun Edit-options-modify (modfun)
        !           104:   (save-excursion
        !           105:    (let (var pos)
        !           106:      (re-search-backward "^;; ")
        !           107:      (forward-char 3)
        !           108:      (setq pos (point))
        !           109:      (save-restriction
        !           110:       (narrow-to-region pos (progn (end-of-line) (1- (point))))
        !           111:       (goto-char pos)
        !           112:       (setq var (read (current-buffer))))
        !           113:      (goto-char pos)
        !           114:      (forward-line 1)
        !           115:      (forward-char 1)
        !           116:      (save-excursion
        !           117:       (set var (funcall modfun var)))
        !           118:      (kill-sexp 1)
        !           119:      (prin1 (symbol-value var) (current-buffer)))))
        !           120: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.