Discussion:
updated patch for nmh-1.5 support
Mike Kupfer
2014-09-26 01:03:34 UTC
Permalink
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")
Jeffrey Honig
2014-09-26 19:18:57 UTC
Permalink
Post by Mike Kupfer
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.
This is the second time I've seen the need to create a temporary folder to
get output of a command. Maybe we should have a function to handle that?

Thanks

Jeff
--
Jeffrey C. Honig <***@honig.net>
http://www.honig.net/jch
GnuPG ID:14E29E13 <http://www.honig.net/jch/key.shtml>
Mike Kupfer
2014-09-27 21:58:43 UTC
Permalink
Post by Jeffrey Honig
Post by Mike Kupfer
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.
This is the second time I've seen the need to create a temporary folder to
get output of a command. Maybe we should have a function to handle that?
What's the other use case? I just did a quick grep through the sources,
and the only other temporary folder that I found is for mh-search, where
we create a subfolder under "mhe-index". But that folder has special
properties, and it's exposed to the user, so I'm not seeing much in
common with the temp folder here.

cheers,
mike
Bill Wohler
2014-09-28 17:14:01 UTC
Permalink
Thanks, Mike! When I move my components file out of the way and run
emacs -Q, I see this:

X-Mailer: MH-E 8.5+bzr; nmh 1.6; GNU Emacs 24.4.50
X-Image-URL: Loading Image...
%;
%; Our default components file. Used by `comp'
%;
%;
%; This line creates our From: header based on the following ordering:
%;
%; - Use a -from switch if it exists ({from})
%; - Use our local mailbox identity; first from the Local-Mailbox profile
%; entry, otherwise gets the information from the local system
%;
%<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
%;
%; Here we include an address list if one or more "-to" arguments were
%; given, otherwise just output a blank header. We do the same for the
%; "cc" header as well.
%;
%<{to}%(void(width))%(putaddr To: )%|To:%>
%<{cc}%(void(width))%(putaddr cc: )%|cc:%>
%;
%; Slight difference here: if we're not given "-fcc" on the command line,
%; make the default mailbox +outbox
%;
Fcc: %<{fcc}%(putstr)%|+outbox%>
Subject:%<{subject} %(putstr)%>
--------

comp from the command line gives me this:

From: Bill Wohler <***@olgas.newt.com>
To:
cc:
Fcc: +outbox
Subject:

Thoughts?
Post by Mike Kupfer
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 @@
+
+ * 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).
+
* 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")
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Bill Wohler
2014-09-28 17:49:55 UTC
Permalink
Oh wait, I was running the wrong version. Stand by...
Post by Bill Wohler
Thanks, Mike! When I move my components file out of the way and run
X-Mailer: MH-E 8.5+bzr; nmh 1.6; GNU Emacs 24.4.50
X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png
%;
%; Our default components file. Used by `comp'
%;
%;
%;
%; - Use a -from switch if it exists ({from})
%; - Use our local mailbox identity; first from the Local-Mailbox profile
%; entry, otherwise gets the information from the local system
%;
%<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
%;
%; Here we include an address list if one or more "-to" arguments were
%; given, otherwise just output a blank header. We do the same for the
%; "cc" header as well.
%;
%<{to}%(void(width))%(putaddr To: )%|To:%>
%<{cc}%(void(width))%(putaddr cc: )%|cc:%>
%;
%; Slight difference here: if we're not given "-fcc" on the command line,
%; make the default mailbox +outbox
%;
Fcc: %<{fcc}%(putstr)%|+outbox%>
Subject:%<{subject} %(putstr)%>
--------
Fcc: +outbox
Thoughts?
Post by Mike Kupfer
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 @@
+
+ * 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).
+
* 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")
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Bill Wohler
2014-09-28 18:27:39 UTC
Permalink
By accident, I used mh-send instead of mh-smail and got this:

send: unable to stat draft file /home/wohler/var/mail/draft: No such
file or directory

The second time I ran mh-send, I got this:

mh-bare-components: Renaming: no such file or directory, /tmp/temp-draftfolder1700p1E/1, /tmp/comp1700Ysr

Since I should have run mh-smail, and mh-smail produces a valid draft
(nice!), this error isn't a problem.

But I mention this since it revealed the name of the new draft folder in
the error message. I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.

Otherwise, I don't have any objections to this being checked into the
emacs-24 branch if Stefan doesn't.
Post by Bill Wohler
Thanks, Mike! When I move my components file out of the way and run
X-Mailer: MH-E 8.5+bzr; nmh 1.6; GNU Emacs 24.4.50
X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png
%;
%; Our default components file. Used by `comp'
%;
%;
%;
%; - Use a -from switch if it exists ({from})
%; - Use our local mailbox identity; first from the Local-Mailbox profile
%; entry, otherwise gets the information from the local system
%;
%<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
%;
%; Here we include an address list if one or more "-to" arguments were
%; given, otherwise just output a blank header. We do the same for the
%; "cc" header as well.
%;
%<{to}%(void(width))%(putaddr To: )%|To:%>
%<{cc}%(void(width))%(putaddr cc: )%|cc:%>
%;
%; Slight difference here: if we're not given "-fcc" on the command line,
%; make the default mailbox +outbox
%;
Fcc: %<{fcc}%(putstr)%|+outbox%>
Subject:%<{subject} %(putstr)%>
--------
Fcc: +outbox
Thoughts?
Post by Mike Kupfer
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 @@
+
+ * 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).
+
* 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")
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Mike Kupfer
2014-09-28 18:42:22 UTC
Permalink
Post by Bill Wohler
I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.
That sounds okay to me. I'll try to get a revised patch out this
afternoon. Thanks for the feedback.
Post by Bill Wohler
Otherwise, I don't have any objections to this being checked into the
emacs-24 branch if Stefan doesn't.
AFAIK, I don't have commit privileges, so I'll just be submitting a bzr
bundle.

mike
Mike Kupfer
2014-09-28 20:40:27 UTC
Permalink
Post by Mike Kupfer
Post by Bill Wohler
I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.
That sounds okay to me. I'll try to get a revised patch out this
afternoon. Thanks for the feedback.
An incremental patch is below. Let me know if you'd like a full patch
to play with. While sanity-testing the changes to the temp names, I
realized that I hadn't ever done any real testing on XEmacs or Emacs 23.
There were a couple things that needed changing to work with XEmacs.

mike

=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/ChangeLog 2014-09-28 20:37:54 +0000
@@ -1,3 +1,10 @@
+2014-09-28 Mike Kupfer <***@acm.org>
+
+ * mh-comp.el (mh-bare-components): Improve the temp folder and
+ file names as per a suggestion from Bill Wohler. Also address
+ XEmacs compatibility issues: use mm-make-temp-file instead of
+ make-temp-file, and only pass one argument to delete-directory.
+
2014-09-26 Mike Kupfer <***@acm.org>

* mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a

=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-28 20:14:06 +0000
@@ -916,16 +916,17 @@
;; 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)))
+ (temp-folder (mm-make-temp-file
+ (concat mh-user-path "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"))
+ (setq new (mm-make-temp-file "comp."))
(rename-file (concat temp-folder "/" "1") new t)
- (delete-directory temp-folder t)
+ (delete-file (concat temp-folder "/" ".mh_sequences"))
+ (delete-directory temp-folder)
new))

(defun mh-read-draft (use initial-contents delete-contents-file)
Bill Wohler
2014-09-29 01:31:12 UTC
Permalink
Yes, test-mh-e is your friend.

The new patch is working for me as well. Thanks!
Post by Mike Kupfer
Post by Mike Kupfer
Post by Bill Wohler
I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.
That sounds okay to me. I'll try to get a revised patch out this
afternoon. Thanks for the feedback.
An incremental patch is below. Let me know if you'd like a full patch
to play with. While sanity-testing the changes to the temp names, I
realized that I hadn't ever done any real testing on XEmacs or Emacs 23.
There were a couple things that needed changing to work with XEmacs.
mike
=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/ChangeLog 2014-09-28 20:37:54 +0000
@@ -1,3 +1,10 @@
+
+ * mh-comp.el (mh-bare-components): Improve the temp folder and
+ file names as per a suggestion from Bill Wohler. Also address
+ XEmacs compatibility issues: use mm-make-temp-file instead of
+ make-temp-file, and only pass one argument to delete-directory.
+
* mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a
=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-28 20:14:06 +0000
@@ -916,16 +916,17 @@
;; 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)))
+ (temp-folder (mm-make-temp-file
+ (concat mh-user-path "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"))
+ (setq new (mm-make-temp-file "comp."))
(rename-file (concat temp-folder "/" "1") new t)
- (delete-directory temp-folder t)
+ (delete-file (concat temp-folder "/" ".mh_sequences"))
+ (delete-directory temp-folder)
new))
(defun mh-read-draft (use initial-contents delete-contents-file)
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Bill Wohler
2014-09-29 14:28:52 UTC
Permalink
Mike,

I just got an invitation from Stefan to install it in Emacs. I will do
so after work today.
Post by Bill Wohler
Yes, test-mh-e is your friend.
The new patch is working for me as well. Thanks!
Post by Mike Kupfer
Post by Mike Kupfer
Post by Bill Wohler
I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.
That sounds okay to me. I'll try to get a revised patch out this
afternoon. Thanks for the feedback.
An incremental patch is below. Let me know if you'd like a full patch
to play with. While sanity-testing the changes to the temp names, I
realized that I hadn't ever done any real testing on XEmacs or Emacs 23.
There were a couple things that needed changing to work with XEmacs.
mike
=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/ChangeLog 2014-09-28 20:37:54 +0000
@@ -1,3 +1,10 @@
+
+ * mh-comp.el (mh-bare-components): Improve the temp folder and
+ file names as per a suggestion from Bill Wohler. Also address
+ XEmacs compatibility issues: use mm-make-temp-file instead of
+ make-temp-file, and only pass one argument to delete-directory.
+
* mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a
=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-28 20:14:06 +0000
@@ -916,16 +916,17 @@
;; 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)))
+ (temp-folder (mm-make-temp-file
+ (concat mh-user-path "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"))
+ (setq new (mm-make-temp-file "comp."))
(rename-file (concat temp-folder "/" "1") new t)
- (delete-directory temp-folder t)
+ (delete-file (concat temp-folder "/" ".mh_sequences"))
+ (delete-directory temp-folder)
new))
(defun mh-read-draft (use initial-contents delete-contents-file)
--
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
------------------------------------------------------------------------------
Slashdot TV. Videos for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Bill Wohler
2014-09-30 05:23:23 UTC
Permalink
Done.

I've checked in the changes into the emacs-24 branch. I've also merged
the changes into trunk.

Note the X-Mailer header field. I've started the release process for
MH-E 8.6 to coincide with the Emacs 24.4 release. I'll wait until the
actual Emacs release before tagging and completing the release process
per the MH-E Developers' Manual.

Mike, thanks very much for breathing life back into MH-E development.
Post by Bill Wohler
Mike,
I just got an invitation from Stefan to install it in Emacs. I will do
so after work today.
Post by Bill Wohler
Yes, test-mh-e is your friend.
The new patch is working for me as well. Thanks!
Post by Mike Kupfer
Post by Mike Kupfer
Post by Bill Wohler
I'd like to suggest one small tweak since the temp in
the folder name seems redundant. What do you think about
draftfolder.###### and comp.######, adding a dot to be consistent with
the default filename in mktemp (1)? I now see the folder gets moved to
$MAIL, but the suffix should still be sufficient to indicate its
ephemeral nature.
That sounds okay to me. I'll try to get a revised patch out this
afternoon. Thanks for the feedback.
An incremental patch is below. Let me know if you'd like a full patch
to play with. While sanity-testing the changes to the temp names, I
realized that I hadn't ever done any real testing on XEmacs or Emacs 23.
There were a couple things that needed changing to work with XEmacs.
mike
=== modified file 'lisp/mh-e/ChangeLog'
--- lisp/mh-e/ChangeLog 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/ChangeLog 2014-09-28 20:37:54 +0000
@@ -1,3 +1,10 @@
+
+ * mh-comp.el (mh-bare-components): Improve the temp folder and
+ file names as per a suggestion from Bill Wohler. Also address
+ XEmacs compatibility issues: use mm-make-temp-file instead of
+ make-temp-file, and only pass one argument to delete-directory.
+
* mh-comp.el (mh-insert-x-face): Ensure that mh-x-face-file is a
=== modified file 'lisp/mh-e/mh-comp.el'
--- lisp/mh-e/mh-comp.el 2014-09-27 19:25:19 +0000
+++ lisp/mh-e/mh-comp.el 2014-09-28 20:14:06 +0000
@@ -916,16 +916,17 @@
;; 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)))
+ (temp-folder (mm-make-temp-file
+ (concat mh-user-path "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"))
+ (setq new (mm-make-temp-file "comp."))
(rename-file (concat temp-folder "/" "1") new t)
- (delete-directory temp-folder t)
+ (delete-file (concat temp-folder "/" ".mh_sequences"))
+ (delete-directory temp-folder)
new))
(defun mh-read-draft (use initial-contents delete-contents-file)
--
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
------------------------------------------------------------------------------
Slashdot TV. Videos for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
------------------------------------------------------------------------------
Slashdot TV. Videos for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
mh-e-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mh-e-devel
--
Bill Wohler <***@newt.com> aka <***@nasa.gov>
http://www.newt.com/wohler/
GnuPG ID:610BD9AD
Loading...