[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Long buffer name under MS Windows
- From: Hideyuki SHIRAI (白井秀行) <shirai@xxxxxxxxxxx>
- Date: Wed, 01 Apr 2009 10:11:21 +0900 (JST)
- X-ml-name: emacs-w3m
- X-mail-count: 10810
- References: <42f485580903310804j5788ac4cucc71b5cb0f3b038@xxxxxxxxxxxxxx>
From: Sergio Pokrovskij <sergio.pokrovskij@xxxxxxxxx> said
Subject: [emacs-w3m:10809] Long buffer name under MS Windows
Message-ID: <42f485580903310804j5788ac4cucc71b5cb0f3b038@xxxxxxxxxxxxxx>
Date: Tue, 31 Mar 2009 23:04:26 +0800
> A few days ago I've installed w3m for use in Emacs, and here is a
> problem with responding to a post from a Google group: when I press
> C-c C-c in order to commit the buffer to the textarea, Emacs complains
> about "Invalid argument"; this argument was, in my case, the buffer
> name
> d:/cygwin/home/Sergio/.w3m/.textarea/http___groups.google.com_group_soc.culture.esperanto_post_hl=en&inreplyto=b2b0ab0c3d632603&reply_to=group&_done=%2Fgroup%2Fsoc.culture.esperanto%2Fbrowse_thread%2Fthread%2F28f5fa36af3f801f%3Fhl%3Den%26&-fid=2_type=textarea_name=body_id=24.txt
>
> In fact, when I tried to save the buffer under this same name
> manually, I received the very same error message; I guess the name is
> too long for the Windows.
>
> I've added two lines into the w3m-form-input-textarea-filename
> function of w3m-form.el, trimming the filename length; and my problem
> has gone:
>
> (defun w3m-form-input-textarea-filename (url id)
> (let ((file "")
> (l-url (length url)); <++++++++++++++++++++++
> ;; Interdit chars of Windows
> (replace (regexp-opt '("\\" "/" ":" "*" "?" "\"" "<" ">" "|"))))
> (if (> l-url 77) (setq url (substring url (- l-url 77))));
In cvs head, this function has been changed as follows.
(1) If it is possible, a unique, short name is made by using MD5.
(2) If (1) fails, the file name is cut short to become 255 or less.
(defun w3m-form-input-textarea-filename (url id)
(condition-case nil
(concat (md5 (concat url id) nil nil w3m-current-coding-system) ".txt")
(error
(let ((file "")
;; Interdit chars of Windows
(replace (regexp-opt '("\\" "/" ":" "*" "?" "\"" "<" ">" "|")))
(max-file-path 254))
(while (string-match replace url)
(setq file (concat file (substring url 0 (match-beginning 0)) "_"))
(setq url (substring url (match-end 0))))
(setq file (concat file url "-"))
(while (string-match replace id)
(setq file (concat file (substring id 0 (match-beginning 0)) "_"))
(setq id (substring id (match-end 0))))
(if (< (- max-file-path 4) (length file))
(setq file (substring file 0 (- max-file-path 4 (length id)))))
(setq file (concat file id ".txt"))
(convert-standard-filename file)))))
Now you can get it from CVS or:
<URL:http://cvs.namazu.org/emacs-w3m.tar.gz?view=tar>
Thank you for your report.
--
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)