the Save As filename should default to the Subject of the message

VERIFIED FIXED

Status

--
enhancement
VERIFIED FIXED
17 years ago
13 years ago

People

(Reporter: Suran, Assigned: iann_bugzilla)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 4 obsolete attachments)

(Reporter)

Description

17 years ago
Now this is a trivial thing that helps a lot:
It would make saving a number of mails much easier if
the subject-line became the default-name in save-as
and if it would remember the file-type one selected
the last time as it remembers the path(saving a number
of related mails as .txt requires to select .txt and
enter the file-name every time again).
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 1

17 years ago
This seems like a rfe bug filed on 2 separate topics:

* Make the filename the Subject (would require some significant munging,
methinks, and isn't quite so "trivial", but I might be wrong.)

* Make the file type "sticky"

The summary poorly describes both, so I'm updating it to reflect the first RFE.
 (old summary was "filename and type in save-as")

Note, I haven't searched exhaustively for a dupe on either subject.  Feel free
to file a 2nd bug for the 2nd request, but please check for dupes first.
Summary: filename and type in save-as → the Save As filename should default to the Subject of the message

Comment 2

16 years ago
*** Bug 148964 has been marked as a duplicate of this bug. ***

Updated

16 years ago
QA Contact: esther → sheelar

Comment 3

16 years ago
Voting for both parts of this report, especially the 2nd:)

Comment 4

16 years ago
Actually, the second part is already done in some way. The actual type of the
saved file is determined from the extension of the filename you specify, not the
type of files you select in the list. If you just press Ctrl+S, type message.txt
and leave the type as .eml files, hit Enter, the mail is saved as plain text file.

I don't know if this is a bug, but I like it as a feature:)

Comment 5

15 years ago
*** Bug 189781 has been marked as a duplicate of this bug. ***

Updated

15 years ago
OS: Linux → All
Hardware: PC → All
Voting for this bug.

Munging the subject for a valid filename should not be that difficult (as KNode
0.7.x does it, too, which is why I missed the feature in MailNews in the first
place.)

Replace problematic characters[1] with underscore (`_'). Optionally replace two
juxtapositioned underscores with one. Strip leading and following underscores,
then add the default extension.

[1]
Problematic characters include `\', `/', `:', `*', `?', `"', `<', `>', and `|'
because (from what Explorer.exe tells me) they must not appear in filenames at
least on a FAT or NTFS partition.


\V/ Live long and prosper

PointedEars

Comment 7

15 years ago
Additional Rationale for this RFE:
I am adding automated racer registration for ski racing events.  Pre-formatted
emails are directed to the race organizer for a particular event.
After saving the email the local copy of the registration program processes the
contents to register the racer. I ensure that each message subject has a unique
number affixed. 
In Outlook Express the race organizer need only use SaveAs (Ctrl S + ENTER) for
each of about 120 messages. In Mozilla the Save As name prompt is always
"message.eml" - which creates a huge increase in effort. 
I presume the SaveAs directory will be sticky as well.
(Assignee)

Updated

15 years ago
Blocks: 182142
(Assignee)

Comment 8

15 years ago
Taking from sspitzer@mozilla.org (Seth Spitzer)
Assignee: sspitzer → bugzilla
(Assignee)

Comment 9

15 years ago
Accepting
Status: NEW → ASSIGNED
(Assignee)

Comment 10

15 years ago
Created attachment 133152 [details] [diff] [review]
Patch v0.1 - implements using subject for mail/compose "save as file" filename

This patch does several things:
Removes most of the duplication of TrimString by moving it to globalOverlay.js
Adds a new function GenerateValidFilename to globalOverlay.js for both mailnews
and editor to use which was originally part of editor's GetSuggestedFilename
Adds an extra argument to editor's SaveDocument to pass the subject via, if the
extra argument is null then reverts to old behaviour
Fixed calls to SaveDocument from elsewhere so extra argument is null
Adds an extra argument to editor's GetSuggestedFilename so editorType is passed

Reworks GetSuggestedFilename so it calls new GenerateValidFilename
Alters fourth argument of nsMessenger's SaveAs to be used for passing the
subject.
(Assignee)

Updated

15 years ago
Attachment #133152 - Flags: review?(neil.parkwaycc.co.uk)

Comment 11

15 years ago
Comment on attachment 133152 [details] [diff] [review]
Patch v0.1 - implements using subject for mail/compose "save as file" filename

Firstly, in the message compose case, wouldn't it be somewhat simpler to set
the document title from the subject? Then the editor save routine would
automagically suggest the correct filename.

Secondly, for the message display case, the content won't have the correct
title if the current message was changed while the preview pane was closed.
Attachment #133152 - Flags: review?(neil.parkwaycc.co.uk) → review-
(Assignee)

Comment 12

15 years ago
Created attachment 133227 [details] [diff] [review]
Patch v0.2 - use subject for compose/mail "Save As File" filename

This patch does several things:
Removes most of the duplication of TrimString by moving it to globalOverlay.js
Adds a new function GenerateValidFilename to globalOverlay.js for both mailnews

and editor to use which was originally part of editor's GetSuggestedFilename
Uses .setDocumentTitle to pass the subject to editor's SaveDocument
Reworks GetSuggestedFilename so it calls new GenerateValidFilename
Alters fourth argument of nsMessenger's SaveAs to be used for passing the
subject.
Attachment #133152 - Attachment is obsolete: true
(Assignee)

Updated

15 years ago
Attachment #133227 - Flags: review?(neil.parkwaycc.co.uk)

Comment 13

15 years ago
Comment on attachment 133227 [details] [diff] [review]
Patch v0.2 - use subject for compose/mail "Save As File" filename

Looking good.

>+  if (title == "")
>+    title = GetCurrentEditor().document.title;
Move XPCNativeWrapper.js into editorOverlay.xul as discussed on IRC.

> function SaveAsFile(uri)
> {
>-	if (uri) messenger.saveAs(uri, true, null, msgWindow);
>+  if (uri) {
>+    var subject = null;
>+    try {
>+      subject = messenger.messageServiceFromURI(uri)
>+                         .messageURIToMsgHdr(uri).subject;
>+      subject = GenerateValidFilename(subject, ".eml");
>+    }
>+    catch (ex) {}
>+    messenger.saveAs(uri, true, null, subject);
As the 4th arg is really a suggested filename rather than a subject, declare
two variables (you can declare subject inside the try block), and rename the
4th arg in the rest of the patch too.
Attachment #133227 - Flags: review?(neil.parkwaycc.co.uk) → review-
(Assignee)

Comment 14

15 years ago
Created attachment 133232 [details] [diff] [review]
Patch v0.2a - uses subject for compose/mail "Save As File" filename

Addresses Neil's review comments.
I presume that globalOverlay.js is a suitable place to move TrimString to and
add GenerateValidFilename to?
Attachment #133227 - Attachment is obsolete: true
(Assignee)

Updated

15 years ago
Attachment #133232 - Flags: review?(neil.parkwaycc.co.uk)
(Assignee)

Comment 15

15 years ago
Created attachment 133286 [details] [diff] [review]
Patch v0.2b - implements use of subject for "Save As File" filename

As per patch v0.2a but functions moved from globalOverlay.js to
utilityOverlay.js, editorUtilities.js is not referenced by messenger.xul so
isn't suitable.
Attachment #133232 - Attachment is obsolete: true
(Assignee)

Comment 16

15 years ago
Comment on attachment 133232 [details] [diff] [review]
Patch v0.2a - uses subject for compose/mail "Save As File" filename

Cancelling old review request
Attachment #133232 - Flags: review?(neil.parkwaycc.co.uk)
(Assignee)

Updated

15 years ago
Attachment #133232 - Flags: review?(neil.parkwaycc.co.uk)
(Assignee)

Updated

15 years ago
Attachment #133232 - Flags: review?(neil.parkwaycc.co.uk)
(Assignee)

Updated

15 years ago
Attachment #133286 - Flags: review?(neil.parkwaycc.co.uk)

Comment 17

15 years ago
Comment on attachment 133286 [details] [diff] [review]
Patch v0.2b - implements use of subject for "Save As File" filename

r=me based on visual differences between this patch and attachment 133232 [details] [diff] [review] and
my previous testing of bug 133232. Make sure to get some sort of editor moa too
(I'm guessing you'll get any mailnews moa by sr).
Attachment #133286 - Flags: review?(neil.parkwaycc.co.uk) → review+

Comment 18

15 years ago
Um, make that attachment 133232 [details] [diff] [review] both times :-[
(Assignee)

Comment 19

15 years ago
Created attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

TrimString has been left where it originally was in editorUtilities.js and the
call to it from GenerateValidFilename has been inlined.
Attachment #133286 - Attachment is obsolete: true
(Assignee)

Updated

15 years ago
Attachment #133364 - Flags: review?(neil.parkwaycc.co.uk)

Updated

15 years ago
Attachment #133364 - Flags: review?(neil.parkwaycc.co.uk) → review+
(Assignee)

Updated

15 years ago
Attachment #133364 - Flags: superreview?(bienvenu)

Comment 20

15 years ago
Comment on attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

sr=bienvenu, but you should get an editor person to do an r= for the editor
changes - maybe daniel@glazman.org

\ No newline at end of file
+}

could you add a newline here so that message won't come up in the diffs?
Attachment #133364 - Flags: superreview?(bienvenu) → superreview+
(Assignee)

Comment 21

15 years ago
Adding Daniel to CC to make sure there's no problems from the editor side of things
(Assignee)

Comment 22

15 years ago
David,

\ No newline at end of file
+}
I'm pretty sure this happens because there was no newline at the end of the file
before.
(Assignee)

Comment 23

15 years ago
Comment on attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

Requesting review for the editor side from Daniel.
Already got
r=neil.parkwaycc.co.uk for the mail side.
Attachment #133364 - Flags: review+ → review?(daniel)

Comment 24

15 years ago
Ian, yes, you're right, it was that way before, I had checked - but I was hoping
you could fix it anyway :-)
Comment on attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

r=daniel@glazman.org for the editor side; seems ok to me
Attachment #133364 - Flags: review?(daniel) → review+
(Assignee)

Comment 26

15 years ago
Comment on attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

Requesting driver approval for checkin to trunk
Attachment #133364 - Flags: approval1.6a?

Comment 27

15 years ago
Comment on attachment 133364 [details] [diff] [review]
Patch v0.2c - as v0.2b except with trimstring change

a=asa (on behalf of drivers) for checkin to 1.6alpha
Attachment #133364 - Flags: approval1.6a? → approval1.6a+

Comment 28

15 years ago
while reading your GenerateValidFilename(), I was reminded of
NS_MsgHashIfNecessary()

http://lxr.mozilla.org/mozilla/source/mailnews/base/util/nsMsgUtils.cpp#240

some characters are valid on some platforms but not others. 

see http://lxr.mozilla.org/mozilla/source/xpcom/ds/nsCRT.h#276

I'll bet there are more places in C++ (and js) where we do this sort thing.

we should both:

1) make sure the code your adding is doing the right thing on all platforms
2) log a bug about unifying all the core of this code in one place, accessible
from C++ and js.

Comment 29

15 years ago
Fix checked in.

BTW, the appropriate filepickers will perform additional filename cleanup.
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
generatevalidfilename seems to do the same job as the existing validateFileName.
filed Bug 223549 to use that existing function instead of adding a new one
Product: Browser → Seamonkey
Verified FIXED using SeaMonkey 1.5a;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060110 Mozilla/1.0.

I checked News, IMAP, and POP/Local Folders.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.