Annotation of GNUtools/emacs/lisp/text-mode.el, revision 1.1

1.1     ! root        1: ;; Text mode, and its ideosyncratic commands.
        !             2: ;; Copyright (C) 1985 Free Software Foundation, Inc.
        !             3: 
        !             4: ;; This file is part of GNU Emacs.
        !             5: 
        !             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)
        !             9: ;; any later version.
        !            10: 
        !            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.
        !            15: 
        !            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.
        !            19: 
        !            20: 
        !            21: (defvar text-mode-syntax-table nil
        !            22:   "Syntax table used while in text mode.")
        !            23: 
        !            24: (defvar text-mode-abbrev-table nil
        !            25:   "Abbrev table used while in text mode.")
        !            26: (define-abbrev-table 'text-mode-abbrev-table ())
        !            27: 
        !            28: (if text-mode-syntax-table
        !            29:     ()
        !            30:   (setq text-mode-syntax-table (make-syntax-table))
        !            31:   (modify-syntax-entry ?\" ".   " text-mode-syntax-table)
        !            32:   (modify-syntax-entry ?\\ ".   " text-mode-syntax-table)
        !            33:   (modify-syntax-entry ?' "w   " text-mode-syntax-table))
        !            34: 
        !            35: (defvar text-mode-map nil "")
        !            36: (if text-mode-map
        !            37:     ()
        !            38:   (setq text-mode-map (make-sparse-keymap))
        !            39:   (define-key text-mode-map "\t" 'tab-to-tab-stop)
        !            40:   (define-key text-mode-map "\es" 'center-line)
        !            41:   (define-key text-mode-map "\eS" 'center-paragraph))
        !            42: 
        !            43: 
        !            44: ;(defun non-saved-text-mode ()
        !            45: ;  "Like text-mode, but delete auto save file when file is saved for real."
        !            46: ;  (text-mode)
        !            47: ;  (make-local-variable 'delete-auto-save-files)
        !            48: ;  (setq delete-auto-save-files t))
        !            49: 
        !            50: (defun text-mode ()
        !            51:   "Major mode for editing text intended for humans to read.  Special commands:\\{text-mode-map}
        !            52: Turning on text-mode calls the value of the variable text-mode-hook,
        !            53: if that value is non-nil."
        !            54:   (interactive)
        !            55:   (kill-all-local-variables)
        !            56:   (use-local-map text-mode-map)
        !            57:   (setq mode-name "Text")
        !            58:   (setq major-mode 'text-mode)
        !            59:   (setq local-abbrev-table text-mode-abbrev-table)
        !            60:   (set-syntax-table text-mode-syntax-table)
        !            61:   (run-hooks 'text-mode-hook))
        !            62: 
        !            63: (defvar indented-text-mode-map ())
        !            64: (if indented-text-mode-map
        !            65:     ()
        !            66:   (setq indented-text-mode-map (make-sparse-keymap))
        !            67:   (define-key indented-text-mode-map "\t" 'indent-relative)
        !            68:   (define-key indented-text-mode-map "\es" 'center-line)
        !            69:   (define-key indented-text-mode-map "\eS" 'center-paragraph))
        !            70: 
        !            71: (defun indented-text-mode ()
        !            72:   "Major mode for editing indented text intended for humans to read.\\{indented-text-mode-map}
        !            73: Turning on indented-text-mode calls the value of the variable text-mode-hook,
        !            74: if that value is non-nil."
        !            75:   (interactive)
        !            76:   (kill-all-local-variables)
        !            77:   (use-local-map text-mode-map)
        !            78:   (define-abbrev-table 'text-mode-abbrev-table ())
        !            79:   (setq local-abbrev-table text-mode-abbrev-table)
        !            80:   (set-syntax-table text-mode-syntax-table)
        !            81:   (make-local-variable 'indent-line-function)
        !            82:   (setq indent-line-function 'indent-relative-maybe)
        !            83:   (use-local-map indented-text-mode-map)
        !            84:   (setq mode-name "Indented Text")
        !            85:   (setq major-mode 'indented-text-mode)
        !            86:   (run-hooks 'text-mode-hook))
        !            87: 
        !            88: (defun center-paragraph ()
        !            89:   "Center each line in the paragraph at or after point.
        !            90: See center-line for more info."
        !            91:   (interactive)
        !            92:   (save-excursion
        !            93:     (forward-paragraph)
        !            94:     (or (bolp) (newline 1))
        !            95:     (let ((end (point)))
        !            96:       (backward-paragraph)
        !            97:       (center-region (point) end))))
        !            98: 
        !            99: (defun center-region (from to)
        !           100:   "Center each line starting in the region.
        !           101: See center-line for more info."
        !           102:   (interactive "r")
        !           103:   (if (> from to)
        !           104:       (let ((tem to))
        !           105:        (setq to from from tem)))
        !           106:   (save-excursion
        !           107:     (save-restriction
        !           108:       (narrow-to-region from to)
        !           109:       (goto-char from)
        !           110:       (while (not (eobp))
        !           111:        (center-line)
        !           112:        (forward-line 1)))))
        !           113: 
        !           114: (defun center-line ()
        !           115:   "Center the line point is on, within the width specified by `fill-column'.
        !           116: This means adjusting the indentation to match
        !           117: the distance between the end of the text and `fill-column'."
        !           118:   (interactive)
        !           119:   (save-excursion
        !           120:     (let (line-length)
        !           121:       (beginning-of-line)
        !           122:       (delete-horizontal-space)
        !           123:       (end-of-line)
        !           124:       (delete-horizontal-space)
        !           125:       (setq line-length (current-column))
        !           126:       (beginning-of-line)
        !           127:       (indent-to 
        !           128:        (+ left-margin 
        !           129:           (/ (- fill-column left-margin line-length) 2))))))

unix.superglobalmegacorp.com

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