Annotation of 43BSD/contrib/emacs/lisp/rmailedit.el, revision 1.1

1.1     ! root        1: ;; "RMAIL edit mode"  Edit the current message.
        !             2: ;; Copyright (C) 1985 Richard M. Stallman.
        !             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: (require 'rmail)
        !            23: 
        !            24: (defvar rmail-edit-map nil)
        !            25: (if rmail-edit-map
        !            26:     nil
        !            27:   (setq rmail-edit-map (copy-keymap text-mode-map))
        !            28:   (define-key rmail-edit-map "\C-c\C-c" 'rmail-cease-edit)
        !            29:   (define-key rmail-edit-map "\C-c\C-]" 'rmail-abort-edit))
        !            30: 
        !            31: (defun rmail-edit-mode ()
        !            32:   "Major mode for editing the contents of an RMAIL message.
        !            33: The editing commands are the same as in Text mode, together with two commands
        !            34: to return to regular RMAIL:
        !            35:   *  rmail-abort-edit cancels the changes
        !            36:      you have made and returns to RMAIL
        !            37:   *  rmail-cease-edit makes them permanent.
        !            38: \\{rmail-edit-map}"
        !            39:   (use-local-map rmail-edit-map)
        !            40:   (setq major-mode 'rmail-edit-mode)
        !            41:   (setq mode-name "RMAIL Edit")
        !            42:   (setq mode-line-format default-mode-line-format)
        !            43:   (run-hooks 'text-mode-hook 'rmail-edit-mode-hook))
        !            44: 
        !            45: (defun rmail-edit-current-message ()
        !            46:   "Edit the contents of this message."
        !            47:   (interactive)
        !            48:   (rmail-edit-mode)
        !            49:   (make-local-variable 'rmail-old-text)
        !            50:   (setq rmail-old-text (buffer-substring (point-min) (point-max)))
        !            51:   (setq buffer-read-only nil)
        !            52:   (set-buffer-modified-p (buffer-modified-p))
        !            53:   ;; Make mode line update.
        !            54:   (if (and (eq (key-binding "\C-c\C-c") 'rmail-cease-edit)
        !            55:           (eq (key-binding "\C-c\C-]") 'rmail-abort-edit))
        !            56:       (message "Editing: Type C-c C-c to return to Rmail, C-c C-] to abort")
        !            57:     (message (substitute-command-keys
        !            58:               "Editing: Type \\[rmail-cease-edit] to return to Rmail, \\[rmail-abort-edit] to abort"))))
        !            59: 
        !            60: (defun rmail-cease-edit ()
        !            61:   "Finish editing message; switch back to Rmail proper."
        !            62:   (interactive)
        !            63:   ;; Make sure buffer ends with a newline.
        !            64:   (save-excursion
        !            65:     (goto-char (point-max))
        !            66:     (if (/= (preceding-char) ?\n)
        !            67:        (insert "\n"))
        !            68:     ;; Adjust the marker that points to the end of this message.
        !            69:     (set-marker (aref rmail-message-vector (1+ rmail-current-message))
        !            70:                (point)))
        !            71:   ;; Update the mode line.
        !            72:   (set-buffer-modified-p (buffer-modified-p))
        !            73:   (rmail-mode-1)
        !            74:   (cond ((boundp 'rmail-summary-vector)
        !            75:         (aset rmail-summary-vector (1- rmail-current-message) nil)
        !            76:         (save-excursion
        !            77:           (rmail-widen-to-current-msgbeg
        !            78:            (function (lambda ()
        !            79:                        (forward-line 2)
        !            80:                        (if (looking-at "Summary-line: ")
        !            81:                            (let ((buffer-read-only nil))
        !            82:                              (delete-region (point)
        !            83:                                             (progn (forward-line 1) (point))))))))
        !            84:           (rmail-show-message))))
        !            85:   (setq buffer-read-only t))
        !            86: 
        !            87: (defun rmail-abort-edit ()
        !            88:   "Abort edit of current message; restore original contents."
        !            89:   (interactive)
        !            90:   (delete-region (point-min) (point-max))
        !            91:   (insert rmail-old-text)
        !            92:   (rmail-cease-edit))
        !            93: 

unix.superglobalmegacorp.com

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