view lisp/mail/pmailedit.el @ 100267:c851df8e004e

2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-goto-calendar): Remove duplicate let bindings of calendar variables. * org-table.el (org-table-find-row-type): Renamed from `org-find-row-type'. (org-table-rewrite-old-row-references): Renamed from `org-rewrite-old-row-references'. (org-table-shift-refpart): Renamed from `org-shift-refpart'. (org-table-cleanup-narrow-column-properties): Renamed from `org-cleanup-narrow-column-properties'. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-find-row-type): New arguments DESC and CLINE, for better error messages. (org-table-get-descriptor-line): Supply the new arguments to `org-find-row-type'. (org-table-error-on-row-ref-crossing-hline): New option. * org.el (org-target-link-regexp): Make buffer-local. (org-move-subtree-down): Fix bug with trees at beginning of buffer. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-faces.el (org-set-tag-faces): New function. (org-tags-special-faces-re): New variable. * org.el (org-font-lock-add-tag-faces, org-get-tag-face): New functions. * org-faces.el (org-tag-faces): New option. (org-tag): Mention `org-tag-faces' in the docstring. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-style-default): Implement new quoting. * org-jsinfo.el (org-infojs-template): Implement new quoting. * org-w3m.el (w3m-minor-mode-hook): Also add the special copy command to the `w3m-minor-mode-map'. * org-archive.el (org-archive-to-archive-sibling): Protect `this-command' to avoid appending kills during archiving. * org-exp.el (org-export-with-priority): New variable. (org-export-add-options-to-plist): Use `org-export-plist-vars' instead of internal list of strings and properties. (org-print-icalendar-entries): Retrieve the location property with inheritance. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-with-todo-keywords): New option. (org-export-plist-vars): Include also the keys for the #+OPTIONS line. (org-default-export-plist, org-export-add-options-to-plist) (org-export-as-ascii, org-export-as-html): Use the new structure of `org-export-plist-vars'. * org.el (org-map-entries): Return all values. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-matcher-time): Recognize more special values. * org-gnus.el (fboundp): Fix defvaralias for XEmacs. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-tags-exclude-from-inheritance): New option. (org-tag-inherit-p, org-remove-uniherited-tags): Respect `org-tags-exclude-from-inheritance'. * org-agenda.el (org-agenda-show-inherited-tags): New option. (org-format-agenda-item): Add inherited tags to the agenda line string, and make sure that properties are kept when downcasing the tags list. (org-agenda-add-inherited-tags): New function. (org-downcase-keep-props): New function. * org.el (org-scan-tags): Mark inherited tags with a text property. (org-get-tags-at): Mark inherited tags with a text property. (org-add-prop-inherited): New function. * org-agenda.el (org-agenda-add-inherited-tags): New function. (org-agenda-show-inherited-tags): New option. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-modules): Add org-w3m to the default modules. * org-table.el (orgtbl-self-insert-command): Make S-SPC work in orgtbl-mode. (orgtabl-create-or-convert-from-region): New command. * org-exp.el (org-export-as-ascii): Remove the handling of targets. (org-export-ascii-preprocess): Handle targets already in this function. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-timer.el (org-timer-start-time): Define this variable. (org-timer-item): Make argument optional. * org-list.el (org-insert-item): Automatically insert a timer item if the current list is a timer list. * org-timer.el: New file. * org-publish.el (org-publish-org-index): Only exclude the index file in the main directory from being added to the site-map. (org-publish-get-project-from-filename): If the current project is a component, start publishing from the parent project. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (orgtbl-ret): Fix RET at beginning-of-buffer. * org-publish.el (org-publish-org-index): Improve removal of temporary buffers.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 07 Dec 2008 18:36:02 +0000
parents 2d0b98e2cb33
children 14070fe82d72
line wrap: on
line source

;;; pmailedit.el --- "PMAIL edit mode"  Edit the current message

;; Copyright (C) 1985, 1994, 2001, 2002, 2003, 2004, 2005, 2006,
;;   2007, 2008 Free Software Foundation, Inc.

;; Maintainer: FSF
;; Keywords: mail

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; 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.

;; 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 <http://www.gnu.org/licenses/>.

;;; Commentary:

;;; Code:

(eval-when-compile
  (require 'pmail)
  (require 'pmailsum))

(require 'pmailhdr)

(defcustom pmail-edit-mode-hook nil
  "List of functions to call when editing an PMAIL message."
  :type 'hook
  :version "21.1"
  :group 'pmail-edit)

(defvar pmail-old-text)

(defvar pmail-edit-map nil)
(if pmail-edit-map
    nil
  ;; Make a keymap that inherits text-mode-map.
  (setq pmail-edit-map (make-sparse-keymap))
  (set-keymap-parent pmail-edit-map text-mode-map)
  (define-key pmail-edit-map "\C-c\C-c" 'pmail-cease-edit)
  (define-key pmail-edit-map "\C-c\C-]" 'pmail-abort-edit))

;; Pmail Edit mode is suitable only for specially formatted data.
(put 'pmail-edit-mode 'mode-class 'special)

(declare-function pmail-summary-disable "" ())
(declare-function pmail-summary-enable "pmailsum" ())

(defun pmail-edit-mode ()
  "Major mode for editing the contents of an PMAIL message.
The editing commands are the same as in Text mode, together with two commands
to return to regular PMAIL:
  *  \\[pmail-abort-edit] cancels the changes
     you have made and returns to PMAIL
  *  \\[pmail-cease-edit] makes them permanent.
This functions runs the normal hook `pmail-edit-mode-hook'.
\\{pmail-edit-map}"
  (delay-mode-hooks (text-mode))
  (use-local-map pmail-edit-map)
  (setq major-mode 'pmail-edit-mode)
  (setq mode-name "PMAIL Edit")
  (if (boundp 'mode-line-modified)
      (setq mode-line-modified (default-value 'mode-line-modified))
    (setq mode-line-format (default-value 'mode-line-format)))
  (if (pmail-summary-exists)
      (save-excursion
	(set-buffer pmail-summary-buffer)
	(pmail-summary-disable)))
  (run-mode-hooks 'pmail-edit-mode-hook))

(defvar pmail-old-pruned nil)
(put 'pmail-old-pruned 'permanent-local t)

(defvar pmail-edit-saved-coding-system nil)
(put 'pmail-edit-saved-coding-system 'permanent-local t)

;;;###autoload
(defun pmail-edit-current-message ()
  "Edit the contents of this message."
  (interactive)
  (if (= pmail-total-messages 0)
      (error "No messages in this file"))
  (make-local-variable 'pmail-old-pruned)
  (setq pmail-old-pruned (eq pmail-header-style 'normal))
  (make-local-variable 'pmail-edit-saved-coding-system)
  (setq pmail-edit-saved-coding-system save-buffer-coding-system)
  (pmail-header-show-headers)
  (pmail-edit-mode)
  ;; As the local value of save-buffer-coding-system is deleted by
  ;; pmail-edit-mode, we restore the original value.
  (make-local-variable 'save-buffer-coding-system)
  (setq save-buffer-coding-system pmail-edit-saved-coding-system)
  (make-local-variable 'pmail-old-text)
  (setq pmail-old-text (buffer-substring (point-min) (point-max)))
  (setq buffer-read-only nil)
  (force-mode-line-update)
  (if (and (eq (key-binding "\C-c\C-c") 'pmail-cease-edit)
	   (eq (key-binding "\C-c\C-]") 'pmail-abort-edit))
      (message "Editing: Type C-c C-c to return to Pmail, C-c C-] to abort")
    (message "%s" (substitute-command-keys
		   "Editing: Type \\[pmail-cease-edit] to return to Pmail, \\[pmail-abort-edit] to abort"))))

(defun pmail-cease-edit ()
  "Finish editing message; switch back to Pmail proper."
  (interactive)
  (if (pmail-summary-exists)
      (save-excursion
	(set-buffer pmail-summary-buffer)
	(pmail-summary-enable)))
  ;; Make sure buffer ends with a newline.
  (save-excursion
    (goto-char (point-max))
    (if (/= (preceding-char) ?\n)
	(insert "\n"))
    ;; Adjust the marker that points to the end of this message.
    (set-marker (aref pmail-message-vector (1+ pmail-current-message))
		(point)))
  (let ((old pmail-old-text))
    (force-mode-line-update)
    (kill-all-local-variables)
    (pmail-mode-1)
    (if (boundp 'tool-bar-map)
	(set (make-local-variable 'tool-bar-map) pmail-tool-bar-map))
    (pmail-variables)
    ;; As the local value of save-buffer-coding-system is changed by
    ;; pmail-variables, we restore the original value.
    (setq save-buffer-coding-system pmail-edit-saved-coding-system)
    (if (and (= (length old) (- (point-max) (point-min)))
	     (string= old (buffer-substring (point-min) (point-max))))
	()
      (setq old nil)
      (pmail-set-attribute "edited" t)
      (if (boundp 'pmail-summary-vector)
	  (progn
	    (aset pmail-summary-vector (1- pmail-current-message) nil)
	    (save-excursion
	      (pmail-widen-to-current-msgbeg
		(function (lambda ()
			    (forward-line 2)
			    (if (looking-at "Summary-line: ")
				(let ((buffer-read-only nil))
				  (delete-region (point)
						 (progn (forward-line 1)
							(point))))))))))))
    (save-excursion
      (pmail-show-message)
      (pmail-toggle-header (if pmail-old-pruned 1 0))))
  (run-hooks 'pmail-mode-hook)
  (setq buffer-read-only t))

(defun pmail-abort-edit ()
  "Abort edit of current message; restore original contents."
  (interactive)
  (delete-region (point-min) (point-max))
  (insert pmail-old-text)
  (pmail-cease-edit)
  (pmail-highlight-headers))

(provide 'pmailedit)

;; Local Variables:
;; change-log-default-name: "ChangeLog.pmail"
;; End:

;; arch-tag: 9524f335-12cc-4e95-9e9b-3208dc30550b
;;; pmailedit.el ends here