From: lawrence m. <we...@gm...> - 2003-04-25 18:03:45
|
On MS-windows systems, ERC-GENERATE-LOG-FILE-NAME-LONG does the wrong thing with respect to generating allowed file names. Since this function is the default value for ERC-GENERATE-LOG-FILE-NAME-FUNCTION, I feel that it ought to work out of the box on w32 systems. The following (rather icky) patch against current CVS introduces a new variable ERC-W32-INVALID-FILE-CHARACTERS, and adds some extra checking to ERC-GENERATE-LOG-FILE-NAME-LONG. A few queries about this: * Should the replacement character be a variable? * Initialisation of ERC-W32-INVALID-FILE-CHARACTERS is done using the Emacs variable FILE-NAME-INVALID-REGEXP. Is this defined in XEmacs? * ERC-W32-INVALID-FILE-CHARACTERS is only initialised if Emacs is running on a w32 system, this is checked using: (memq system-type '(windows-nt ms-dos cygwin)) Does XEmacs have other system-types to describe w32 systems? * Currently I haven't looked at the rest of ERC to see if invalid file names might be created elsewhere. Is this worthwhile doing? ----- Begin erc.el patch ----- Index: erc.el =================================================================== RCS file: /cvsroot/erc/erc/erc.el,v retrieving revision 1.521 diff -c -r1.521 erc.el *** erc.el 20 Apr 2003 11:55:09 -0000 1.521 --- erc.el 25 Apr 2003 18:02:36 -0000 *************** *** 1133,1138 **** --- 1133,1153 ---- ;; activation + (defconst erc-w32-invalid-file-characters + (if (memq system-type '(windows-nt ms-dos cygwin)) + (let ((regexp file-name-invalid-regexp)) + (when (string-match "^.*\\?\\(:.*\\)" regexp) + (setq regexp (match-string 1 regexp)) + (when (string-match "\\[\\(.*\\)]" regexp) + (setq regexp (concat "[" + (regexp-quote + (concat ":" + (match-string 1 regexp))) + "]")))) + regexp) + nil) + "Regular expression matching invalid file-name characters on w32 systems.") + (defconst erc-default-server "irc.openprojects.net" "IRC server to use if it cannot be detected otherwise.") *************** *** 6401,6410 **** "Generates a log-file name in the way ERC always did it. This results in a file name of the form #channel!nick@server:port.txt. This function is a possible value for `erc-generate-log-file-name-function'." ! (concat erc-log-channels-directory "/" (if target (concat target "!")) ! nick "@" server ":" (cond ((stringp port) port) ! ((numberp port) ! (number-to-string port))) ".txt")) (defun erc-save-buffer-in-logs (&optional buffer) "Append BUFFER contents to the log file, if logging is enabled. --- 6416,6430 ---- "Generates a log-file name in the way ERC always did it. This results in a file name of the form #channel!nick@server:port.txt. This function is a possible value for `erc-generate-log-file-name-function'." ! (let ((file (concat ! (if target (concat target "!")) ! nick "@" server ":" (cond ((stringp port) port) ! ((numberp port) ! (number-to-string port))) ".txt"))) ! (if erc-w32-invalid-file-characters ! (while (string-match erc-w32-invalid-file-characters file) ! (setq file (replace-match "-" nil t file)))) ! (concat erc-log-channels-directory "/" file))) (defun erc-save-buffer-in-logs (&optional buffer) "Append BUFFER contents to the log file, if logging is enabled. ----- end erc.el patch ----- -- lawrence mitchell <we...@gm...> |