unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch)
@ 2009-09-10 12:02 ` David J. Biesack
  2009-09-11  6:54   ` Glenn Morris
  2009-09-15  2:50   ` bug#4388: marked as done (23.1; rmailmm save option does not prompt for filename correctly (patch)) Emacs bug Tracking System
  0 siblings, 2 replies; 4+ messages in thread
From: David J. Biesack @ 2009-09-10 12:02 UTC (permalink / raw)
  To: bug-gnu-emacs


When decoding an RMAIL message with an attachement,
invoke rmail-view. rmailmm creates a button for each
attached file, such as 

  Attached application/rtf file: Ch7_2009_08_31.rtf

On the attachment button/link, press Enter to invoke rmail-mime-save
Currently, this prompts for a location to save the attachment but
does not pass the current file name and directory name correctly.
The attached patch fixes this.

In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
 of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Shell

Minor modes in effect:
  diff-auto-refine-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  show-paren-mode: t
  iswitchb-mode: t
  compilation-shell-minor-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  next-error-follow-minor-mode: t
  abbrev-mode: t

Recent input:
M-f M-f S w <return> M-p M-b M-b M-b M-f C-f C-f | 
<return> C-p C-e C-b C-b C-x <escape> F C-v C-v C-v 
C-v C-v C-v C-v C-v C-x k SPC M-p M-> M-x m a n <return> 
d i f f <return> C-x o C-s w h i C-a C-x p C-x b r 
m a i l m m . e l . o r C-g C-g C-x , C-x C-f r m a 
SPC m m . e l SPC . o SPC <return> C-x , C-x , C-x 
, M-x f i n d - f i l e - l SPC <return> r m a i l 
m m . e l <return> y M-x h s - s h o w - a l l <return> 
C-x p C-x , M-x r m a i l - C-g C-g M-x f i n d - f 
i l e - l i SPC <return> r m a i l . <backspace> m 
m . e l . o r SPC <return> y C-x p C-e C-x C-g C-g 
C-x l C-x o C-x l C-x o C-x ( C-e C-d C-n C-e C-x ) 
C-x e C-x e C-x e M-4 M-0 M-0 C-x e C-u C-x e C-u C-x 
e C-u C-x e C-u C-x e M-< C-a C-x C-s C-x * M-p <return> 
C-p C-e C-b C-b C-x <escape> F C-x 1 C-SPC C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n M-w 
<down-mouse-1> <mouse-1> C-x 4 , C-n M-x r e p o r 
t - b SPC <return>

Recent messages:
History item: 1
rmailmm.patch [2 times]
Fontifying rmailmm.patch... (regexps................)
rmailmm.patch
Fontifying rmailmm.patch... (regexps................)
rmailmm.patch
Mark set
Region saved

8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------
*** rmailmm.el.orig     Thu Aug 13 11:54:46 2009
--- rmailmm.el  Thu Sep 10 07:56:10 2009
***************
*** 81,86 ****
--- 81,89 ----
    (let* ((filename (button-get button 'filename))
         (directory (button-get button 'directory))
         (data (button-get button 'data)))
+     (setq directory (if (not (string-match "^~$\\.*/" directory))
+                         (concat directory "/")
+                       directory))
      (while (file-exists-p (expand-file-name filename directory))
        (let* ((f (file-name-sans-extension filename))
             (i 1))
***************
*** 89,98 ****
                f (substring f 0 (match-beginning 0))))
        (setq filename (concat f "-" (number-to-string i) "."
                               (file-name-extension filename)))))
      (setq filename (expand-file-name
                    (read-file-name (format "Save as (default: %s): " filename)
                                    directory
!                                   (expand-file-name filename directory))
                    directory))
      (when (file-regular-p filename)
        (error (message "File `%s' already exists" filename)))
--- 92,104 ----
                f (substring f 0 (match-beginning 0))))
        (setq filename (concat f "-" (number-to-string i) "."
                               (file-name-extension filename)))))
+ 
      (setq filename (expand-file-name
                    (read-file-name (format "Save as (default: %s): " filename)
                                    directory
!                                   (expand-file-name filename directory)
!                                     nil
!                                     filename)
                    directory))
      (when (file-regular-p filename)
        (error (message "File `%s' already exists" filename)))
***************


-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch)
  2009-09-10 12:02 ` bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch) David J. Biesack
@ 2009-09-11  6:54   ` Glenn Morris
  2009-09-11 12:38     ` David J. Biesack
  2009-09-15  2:50   ` bug#4388: marked as done (23.1; rmailmm save option does not prompt for filename correctly (patch)) Emacs bug Tracking System
  1 sibling, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2009-09-11  6:54 UTC (permalink / raw)
  To: David J. Biesack; +Cc: 4388

"David J. Biesack" wrote:

> On the attachment button/link, press Enter to invoke rmail-mime-save
> Currently, this prompts for a location to save the attachment but
> does not pass the current file name and directory name correctly.

I don't understand what you mean - can you explain?

> +     (setq directory (if (not (string-match "^~$\\.*/" directory))
> +                         (concat directory "/")
> +                       directory))

What is this supposed to do?

>                     (read-file-name (format "Save as (default: %s): " filename)
>                                     directory
> !                                   (expand-file-name filename directory)
> !                                     nil
> !                                     filename)

It seems you basically want the default value to be eg:

~/foo.jpg

rather than just

~

as it is now?

The current behaviour is consistent with, eg, C-x C-w. Having an
initial default file part just means more typing if you want to delete
it and use a different value.

The only change I would make here is:

--- rmailmm.el  10 Sep 2009 06:18:23 -0000 1.9
+++ rmailmm.el  11 Sep 2009 02:09:11 -0000
@@ -79,7 +79,7 @@
 (defun rmail-mime-save (button)
   "Save the attachment using info in the BUTTON."
   (let* ((filename (button-get button 'filename))
-   (directory (button-get button 'directory))
+    (directory (file-name-as-directory (button-get button 'directory)))
     (data (button-get button 'data)))
     (while (file-exists-p (expand-file-name filename directory))
       (let* ((f (file-name-sans-extension filename))





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch)
  2009-09-11  6:54   ` Glenn Morris
@ 2009-09-11 12:38     ` David J. Biesack
  0 siblings, 0 replies; 4+ messages in thread
From: David J. Biesack @ 2009-09-11 12:38 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 4388

> From: Glenn Morris <rgm@gnu.org>
> CC: <4388@emacsbugs.donarmstrong.com>
> Date: Fri, 11 Sep 2009 02:54:57 -0400
> 
> "David J. Biesack" wrote:
> 
> > On the attachment button/link, press Enter to invoke rmail-mime-save
> > Currently, this prompts for a location to save the attachment but
> > does not pass the current file name and directory name correctly.
> 
> I don't understand what you mean - can you explain?

Yes, sorry, I was not clear.

I invoke rmail-mime-save and enter a different directory, using
completion (and TAB)... this often results with a directory name that
ends with /, such as c:/djb/attachments/

When I press Enter, I get

Debugger entered--Lisp error: (file-error "Opening output file" "no such file or directory" "c:/djb/attachments/")

That is, it appears to be trying to save the attachment file.rtf
as c:/djb/attachments/ and not as c:/djb/attachments/file.rtf

It works correctly if the entered path is a directory name but does not end with /

> > +     (setq directory (if (not (string-match "^~$\\.*/" directory))
> > +                         (concat directory "/")
> > +                       directory))
> 
> What is this supposed to do?

Sorry, my bad; it is buggy. It should just append a / if the directory does not end with /
(file-name-as-directory (button-get button 'directory)) is better.
 
> >                     (read-file-name (format "Save as (default: %s): " filename)
> >                                     directory
> > !                                   (expand-file-name filename directory)
> > !                                     nil
> > !                                     filename)
> 
> It seems you basically want the default value to be eg:
> 
> ~/foo.jpg
> 
> rather than just
> 
> ~
> 
> as it is now?

yes.
 
> The current behaviour is consistent with, eg, C-x C-w. Having an
> initial default file part just means more typing if you want to delete
> it and use a different value.
> 
> The only change I would make here is:
> 
> --- rmailmm.el  10 Sep 2009 06:18:23 -0000 1.9
> +++ rmailmm.el  11 Sep 2009 02:09:11 -0000
> @@ -79,7 +79,7 @@
>  (defun rmail-mime-save (button)
>    "Save the attachment using info in the BUTTON."
>    (let* ((filename (button-get button 'filename))
> -   (directory (button-get button 'directory))
> +    (directory (file-name-as-directory (button-get button 'directory)))
>      (data (button-get button 'data)))
>      (while (file-exists-p (expand-file-name filename directory))
>        (let* ((f (file-name-sans-extension filename))

I still prefer to have the file name in the prompt so that I can change it more easily
rather than having to type it all in (i.e. change the case or change blanks to hyphens or
remove a "-1" or "-2" version string to replace an earlier saved version etc.)

    (setq filename (expand-file-name
                    (read-file-name (format "Save as (default: %s): " filename)
                                    (file-name-as-directory directory)
                                    (expand-file-name filename directory)
                                    nil
                                    filename)
                    directory))

works the way I would like.

-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4388: marked as done (23.1; rmailmm save option does not prompt for filename correctly (patch))
  2009-09-10 12:02 ` bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch) David J. Biesack
  2009-09-11  6:54   ` Glenn Morris
@ 2009-09-15  2:50   ` Emacs bug Tracking System
  1 sibling, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2009-09-15  2:50 UTC (permalink / raw)
  To: Glenn Morris

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

Your message dated Mon, 14 Sep 2009 22:44:17 -0400
with message-id <32hbv5dj0e.fsf@fencepost.gnu.org>
and subject line Re: bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch)
has caused the Emacs bug report #4388,
regarding 23.1; rmailmm save option does not prompt for filename correctly (patch)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
4388: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4388
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 6766 bytes --]

From: "David J. Biesack" <David.Biesack@sas.com>
To: bug-gnu-emacs@gnu.org
Subject: 23.1; rmailmm save option does not prompt for filename correctly (patch)
Date: Thu, 10 Sep 2009 08:02:01 -0400
Message-ID: <ytb8wgnt3d2.fsf@sas.com>


When decoding an RMAIL message with an attachement,
invoke rmail-view. rmailmm creates a button for each
attached file, such as 

  Attached application/rtf file: Ch7_2009_08_31.rtf

On the attachment button/link, press Enter to invoke rmail-mime-save
Currently, this prompts for a location to save the attachment but
does not pass the current file name and directory name correctly.
The attached patch fixes this.

In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
 of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Shell

Minor modes in effect:
  diff-auto-refine-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  show-paren-mode: t
  iswitchb-mode: t
  compilation-shell-minor-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  next-error-follow-minor-mode: t
  abbrev-mode: t

Recent input:
M-f M-f S w <return> M-p M-b M-b M-b M-f C-f C-f | 
<return> C-p C-e C-b C-b C-x <escape> F C-v C-v C-v 
C-v C-v C-v C-v C-v C-x k SPC M-p M-> M-x m a n <return> 
d i f f <return> C-x o C-s w h i C-a C-x p C-x b r 
m a i l m m . e l . o r C-g C-g C-x , C-x C-f r m a 
SPC m m . e l SPC . o SPC <return> C-x , C-x , C-x 
, M-x f i n d - f i l e - l SPC <return> r m a i l 
m m . e l <return> y M-x h s - s h o w - a l l <return> 
C-x p C-x , M-x r m a i l - C-g C-g M-x f i n d - f 
i l e - l i SPC <return> r m a i l . <backspace> m 
m . e l . o r SPC <return> y C-x p C-e C-x C-g C-g 
C-x l C-x o C-x l C-x o C-x ( C-e C-d C-n C-e C-x ) 
C-x e C-x e C-x e M-4 M-0 M-0 C-x e C-u C-x e C-u C-x 
e C-u C-x e C-u C-x e M-< C-a C-x C-s C-x * M-p <return> 
C-p C-e C-b C-b C-x <escape> F C-x 1 C-SPC C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n M-w 
<down-mouse-1> <mouse-1> C-x 4 , C-n M-x r e p o r 
t - b SPC <return>

Recent messages:
History item: 1
rmailmm.patch [2 times]
Fontifying rmailmm.patch... (regexps................)
rmailmm.patch
Fontifying rmailmm.patch... (regexps................)
rmailmm.patch
Mark set
Region saved

8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------
*** rmailmm.el.orig     Thu Aug 13 11:54:46 2009
--- rmailmm.el  Thu Sep 10 07:56:10 2009
***************
*** 81,86 ****
--- 81,89 ----
    (let* ((filename (button-get button 'filename))
         (directory (button-get button 'directory))
         (data (button-get button 'data)))
+     (setq directory (if (not (string-match "^~$\\.*/" directory))
+                         (concat directory "/")
+                       directory))
      (while (file-exists-p (expand-file-name filename directory))
        (let* ((f (file-name-sans-extension filename))
             (i 1))
***************
*** 89,98 ****
                f (substring f 0 (match-beginning 0))))
        (setq filename (concat f "-" (number-to-string i) "."
                               (file-name-extension filename)))))
      (setq filename (expand-file-name
                    (read-file-name (format "Save as (default: %s): " filename)
                                    directory
!                                   (expand-file-name filename directory))
                    directory))
      (when (file-regular-p filename)
        (error (message "File `%s' already exists" filename)))
--- 92,104 ----
                f (substring f 0 (match-beginning 0))))
        (setq filename (concat f "-" (number-to-string i) "."
                               (file-name-extension filename)))))
+ 
      (setq filename (expand-file-name
                    (read-file-name (format "Save as (default: %s): " filename)
                                    directory
!                                   (expand-file-name filename directory)
!                                     nil
!                                     filename)
                    directory))
      (when (file-regular-p filename)
        (error (message "File `%s' already exists" filename)))
***************


-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771



[-- Attachment #3: Type: message/rfc822, Size: 2385 bytes --]

From: Glenn Morris <rgm@gnu.org>
To: 4388-done@emacsbugs.donarmstrong.com
Subject: Re: bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch)
Date: Mon, 14 Sep 2009 22:44:17 -0400
Message-ID: <32hbv5dj0e.fsf@fencepost.gnu.org>

"David J. Biesack" wrote:

> I invoke rmail-mime-save and enter a different directory, using
> completion (and TAB)... this often results with a directory name that
> ends with /, such as c:/djb/attachments/

Should be fixed now.

> I still prefer to have the file name in the prompt so that I can
> change it more easily rather than having to type it all in (i.e.
> change the case or change blanks to hyphens or remove a "-1" or "-2"
> version string to replace an earlier saved version etc.)

I think this is a matter of personal preference, there are advantages
to both styles. The current default is consistent with write-file, and
with rmail-output, so I think it should remain. I have however
simplified the function so that it does not try to come up with a
unique file name, it just lets you decide whether or not you want to
overwrite an existing file.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-15  2:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <32hbv5dj0e.fsf@fencepost.gnu.org>
2009-09-10 12:02 ` bug#4388: 23.1; rmailmm save option does not prompt for filename correctly (patch) David J. Biesack
2009-09-11  6:54   ` Glenn Morris
2009-09-11 12:38     ` David J. Biesack
2009-09-15  2:50   ` bug#4388: marked as done (23.1; rmailmm save option does not prompt for filename correctly (patch)) Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).