Mike Kupfer
2014-09-26 01:03:34 UTC
Stefan's mail that emacs-24 is soon going into stoppers-only mode has
spurred me to finish up the nmh-1.5 support.
Below is the latest version of my patch (from "bzr diff"). It passes
checkdoc and lm-verify, and it mostly passes test-mh-e.
Any comments before I submit it to emacs-devel? Stefan said the cutoff
is Tuesday next week. If you have any feedback, it'd be helpful for me
to get it before Monday.
thanks,
mike
=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-03-17 00:50:05 +0000
+++ lisp/mh-e/ChangeLog 2014-09-26 00:01:24 +0000
@@ -1,3 +1,13 @@
+2014-09-26 Mike Kupfer <***@acm.org>
+
+ * mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a
+ string before trying to use it (closes SF #474).
+ (mh-bare-components): New function to create a temporary initial
+ components file; replaces mh-find-components.
+ (mh-edit-again): Use mh-bare-components instead of
+ mh-find-components.
+ (mh-send-sub): Ditto (partially closes SF #468).
+
2014-03-16 Bill Wohler <***@newt.com>
* mh-folder.el (mh-regenerate-headers): Fix scan: bad message list
=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-01-01 07:43:34 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-26 00:22:33 +0000
@@ -411,6 +411,7 @@
(interactive (list (mh-get-msg-num t)))
(let* ((from-folder mh-current-folder)
(config (current-window-configuration))
+ (components-file (mh-bare-components))
(draft
(cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
(pop-to-buffer (find-file-noselect (mh-msg-filename message))
@@ -467,7 +468,8 @@
;; Text field, that's an easy case
(t
(mh-modify-header-field field value))))))
- (mh-components-to-list (mh-find-components)))
+ (mh-components-to-list components-file))
+ (delete-file components-file)
(goto-char (point-min))
(save-buffer)
(mh-compose-and-send-mail
@@ -885,22 +887,6 @@
(t
nil))))
-(defun mh-find-components ()
- "Return the path to the components file."
- (let (components)
- (cond
- ((file-exists-p
- (setq components
- (expand-file-name mh-comp-formfile mh-user-path)))
- components)
- ((file-exists-p
- (setq components
- (expand-file-name mh-comp-formfile mh-lib)))
- components)
- (t
- (error "Can't find %s in %s or %s"
- mh-comp-formfile mh-user-path mh-lib)))))
-
(defun mh-send-sub (to cc subject config)
"Do the real work of composing and sending a letter.
Expects the TO, CC, and SUBJECT fields as arguments.
@@ -910,8 +896,8 @@
(message "Composing a message...")
(let ((draft (mh-read-draft
"message"
- (mh-find-components)
- nil)))
+ (mh-bare-components)
+ t)))
(mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
(goto-char (point-max))
(mh-compose-and-send-mail draft "" folder msg-num
@@ -920,6 +906,28 @@
(mh-letter-mode-message)
(mh-letter-adjust-point))))
+(defun mh-bare-components ()
+ "Generate a temporary, clean components file and return its path."
+ ;; Let comp(1) create the skeleton for us. This is particularly
+ ;; important with nmh-1.5, because its default "components" needs
+ ;; some processing before it can be used. Unfortunately, comp(1)
+ ;; doesn't have a -build option. So, to avoid the possibility of
+ ;; clobbering an existing draft, create a temporary directory and
+ ;; use it as the drafts folder. Then copy the skeleton to a regular
+ ;; temp file, and return the regular temp file.
+ (let (new
+ (temp-folder (make-temp-file
+ (concat mh-user-path "temp-draftfolder") t)))
+ (mh-exec-cmd "comp" "-nowhatnowproc"
+ "-draftfolder" (format "+%s"
+ (file-name-nondirectory temp-folder))
+ (if (stringp mh-comp-formfile)
+ (list "-form" mh-comp-formfile)))
+ (setq new (make-temp-file "comp"))
+ (rename-file (concat temp-folder "/" "1") new t)
+ (delete-directory temp-folder t)
+ new))
+
(defun mh-read-draft (use initial-contents delete-contents-file)
"Read draft file into a draft buffer and make that buffer the current one.
@@ -1069,7 +1077,8 @@
(defun mh-insert-x-face ()
"Append X-Face, Face or X-Image-URL field to header.
If the field already exists, this function does nothing."
- (when (and (file-exists-p mh-x-face-file)
+ (when (and (stringp mh-x-face-file)
+ (file-exists-p mh-x-face-file)
(file-readable-p mh-x-face-file))
(save-excursion
(unless (or (mh-position-on-field "X-Face")
spurred me to finish up the nmh-1.5 support.
Below is the latest version of my patch (from "bzr diff"). It passes
checkdoc and lm-verify, and it mostly passes test-mh-e.
Any comments before I submit it to emacs-devel? Stefan said the cutoff
is Tuesday next week. If you have any feedback, it'd be helpful for me
to get it before Monday.
thanks,
mike
=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-03-17 00:50:05 +0000
+++ lisp/mh-e/ChangeLog 2014-09-26 00:01:24 +0000
@@ -1,3 +1,13 @@
+2014-09-26 Mike Kupfer <***@acm.org>
+
+ * mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a
+ string before trying to use it (closes SF #474).
+ (mh-bare-components): New function to create a temporary initial
+ components file; replaces mh-find-components.
+ (mh-edit-again): Use mh-bare-components instead of
+ mh-find-components.
+ (mh-send-sub): Ditto (partially closes SF #468).
+
2014-03-16 Bill Wohler <***@newt.com>
* mh-folder.el (mh-regenerate-headers): Fix scan: bad message list
=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-01-01 07:43:34 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-26 00:22:33 +0000
@@ -411,6 +411,7 @@
(interactive (list (mh-get-msg-num t)))
(let* ((from-folder mh-current-folder)
(config (current-window-configuration))
+ (components-file (mh-bare-components))
(draft
(cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
(pop-to-buffer (find-file-noselect (mh-msg-filename message))
@@ -467,7 +468,8 @@
;; Text field, that's an easy case
(t
(mh-modify-header-field field value))))))
- (mh-components-to-list (mh-find-components)))
+ (mh-components-to-list components-file))
+ (delete-file components-file)
(goto-char (point-min))
(save-buffer)
(mh-compose-and-send-mail
@@ -885,22 +887,6 @@
(t
nil))))
-(defun mh-find-components ()
- "Return the path to the components file."
- (let (components)
- (cond
- ((file-exists-p
- (setq components
- (expand-file-name mh-comp-formfile mh-user-path)))
- components)
- ((file-exists-p
- (setq components
- (expand-file-name mh-comp-formfile mh-lib)))
- components)
- (t
- (error "Can't find %s in %s or %s"
- mh-comp-formfile mh-user-path mh-lib)))))
-
(defun mh-send-sub (to cc subject config)
"Do the real work of composing and sending a letter.
Expects the TO, CC, and SUBJECT fields as arguments.
@@ -910,8 +896,8 @@
(message "Composing a message...")
(let ((draft (mh-read-draft
"message"
- (mh-find-components)
- nil)))
+ (mh-bare-components)
+ t)))
(mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
(goto-char (point-max))
(mh-compose-and-send-mail draft "" folder msg-num
@@ -920,6 +906,28 @@
(mh-letter-mode-message)
(mh-letter-adjust-point))))
+(defun mh-bare-components ()
+ "Generate a temporary, clean components file and return its path."
+ ;; Let comp(1) create the skeleton for us. This is particularly
+ ;; important with nmh-1.5, because its default "components" needs
+ ;; some processing before it can be used. Unfortunately, comp(1)
+ ;; doesn't have a -build option. So, to avoid the possibility of
+ ;; clobbering an existing draft, create a temporary directory and
+ ;; use it as the drafts folder. Then copy the skeleton to a regular
+ ;; temp file, and return the regular temp file.
+ (let (new
+ (temp-folder (make-temp-file
+ (concat mh-user-path "temp-draftfolder") t)))
+ (mh-exec-cmd "comp" "-nowhatnowproc"
+ "-draftfolder" (format "+%s"
+ (file-name-nondirectory temp-folder))
+ (if (stringp mh-comp-formfile)
+ (list "-form" mh-comp-formfile)))
+ (setq new (make-temp-file "comp"))
+ (rename-file (concat temp-folder "/" "1") new t)
+ (delete-directory temp-folder t)
+ new))
+
(defun mh-read-draft (use initial-contents delete-contents-file)
"Read draft file into a draft buffer and make that buffer the current one.
@@ -1069,7 +1077,8 @@
(defun mh-insert-x-face ()
"Append X-Face, Face or X-Image-URL field to header.
If the field already exists, this function does nothing."
- (when (and (file-exists-p mh-x-face-file)
+ (when (and (stringp mh-x-face-file)
+ (file-exists-p mh-x-face-file)
(file-readable-p mh-x-face-file))
(save-excursion
(unless (or (mh-position-on-field "X-Face")