This commit was generated by cvs2svn to compensate for changes in r5323,
[elisp/gnus.git-] / lisp / nnheader.el
index 44f3079..7ef13f2 100644 (file)
@@ -2,7 +2,7 @@
 ;; Copyright (C) 1987,88,89,90,93,94,95,96,97,98 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
-;;     Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
 
 ;; This file is part of GNU Emacs.
@@ -59,7 +59,10 @@ on your system, you could say something like:
  (autoload 'mail-position-on-field "sendmail")
  (autoload 'message-remove-header "message")
  (autoload 'cancel-function-timers "timers")
- (autoload 'gnus-point-at-eol "gnus-util"))
+ (autoload 'gnus-point-at-eol "gnus-util")
+ (autoload 'gnus-delete-line "gnus-util")
+ (autoload 'gnus-buffer-live-p "gnus-util")
+ (autoload 'gnus-encode-coding-string "gnus-ems"))
 
 ;;; Header access macros.
 
@@ -397,7 +400,6 @@ the line could be found."
     (unless (gnus-buffer-live-p nntp-server-buffer)
       (setq nntp-server-buffer (get-buffer-create " *nntpd*")))
     (set-buffer nntp-server-buffer)
-    (buffer-disable-undo (current-buffer))
     (erase-buffer)
     (kill-all-local-variables)
     (setq case-fold-search t)          ;Should ignore case.
@@ -592,21 +594,27 @@ If FILE is t, return the buffer contents as a string."
   "Fold continuation lines in the current buffer."
   (nnheader-replace-regexp "\\(\r?\n[ \t]+\\)+" " "))
 
-(defun nnheader-translate-file-chars (file)
+(defun nnheader-translate-file-chars (file &optional full)
+  "Translate FILE into something that can be a file name.
+If FULL, translate everything."
   (if (null nnheader-file-name-translation-alist)
       ;; No translation is necessary.
       file
-    ;; We translate -- but only the file name.  We leave the directory
-    ;; alone.
     (let* ((i 0)
           trans leaf path len)
-      (if (string-match "/[^/]+\\'" file)
-         ;; This is needed on NT's and stuff.
-         (setq leaf (substring file (1+ (match-beginning 0)))
-               path (substring file 0 (1+ (match-beginning 0))))
-       ;; Fall back on this.
-       (setq leaf (file-name-nondirectory file)
-             path (file-name-directory file)))
+      (if full
+         ;; Do complete translation.
+         (setq leaf (copy-sequence file)
+               path "")
+       ;; We translate -- but only the file name.  We leave the directory
+       ;; alone.
+       (if (string-match "/[^/]+\\'" file)
+           ;; This is needed on NT's and stuff.
+           (setq leaf (substring file (1+ (match-beginning 0)))
+                 path (substring file 0 (1+ (match-beginning 0))))
+         ;; Fall back on this.
+         (setq leaf (file-name-nondirectory file)
+               path (file-name-directory file))))
       (setq len (length leaf))
       (while (< i len)
        (when (setq trans (cdr (assq (aref leaf i)
@@ -627,9 +635,9 @@ The first string in ARGS can be a format string."
 (defun nnheader-get-report (backend)
   "Get the most recent report from BACKEND."
   (condition-case ()
-      (message "%s" (symbol-value (intern (format "%s-status-string"
+      (nnheader-message 5 "%s" (symbol-value (intern (format "%s-status-string"
                                                  backend))))
-    (error (message ""))))
+    (error (nnheader-message 5 ""))))
 
 (defun nnheader-insert (format &rest args)
   "Clear the communication buffer and insert FORMAT and ARGS into the buffer.
@@ -764,18 +772,21 @@ find-file-hooks, etc.
   (let ((format-alist nil)
        (auto-mode-alist (nnheader-auto-mode-alist))
        (default-major-mode 'fundamental-mode)
-        (after-insert-file-functions nil)
-       (coding-system-for-read nnheader-file-coding-system))
-    (insert-file-contents filename visit beg end replace)))
+       (enable-local-variables nil)
+       (after-insert-file-functions nil)
+       (find-file-hooks nil))
+    (insert-file-contents-as-coding-system
+     nnheader-file-coding-system filename visit beg end replace)))
 
 (defun nnheader-find-file-noselect (&rest args)
   (let ((format-alist nil)
        (auto-mode-alist (nnheader-auto-mode-alist))
        (default-major-mode 'fundamental-mode)
        (enable-local-variables nil)
-        (after-insert-file-functions nil)
-       (coding-system-for-read nnheader-file-coding-system))
-    (apply 'find-file-noselect args)))
+       (after-insert-file-functions nil)
+       (find-file-hooks nil))
+    (apply 'find-file-noselect-as-coding-system
+          nnheader-file-coding-system args)))
 
 (defun nnheader-auto-mode-alist ()
   "Return an `auto-mode-alist' with only the .gz (etc) thingies."
@@ -845,6 +856,23 @@ find-file-hooks, etc.
 (fset 'nnheader-cancel-timer 'cancel-timer)
 (fset 'nnheader-cancel-function-timers 'cancel-function-timers)
 
+(defun nnheader-Y-or-n-p (prompt)
+  "Ask user a \"Y/n\" question. Return t if answer is neither \"n\", \"N\" nor \"C-g\"."
+  (let ((cursor-in-echo-area t)
+       (echo-keystrokes 0)
+       (inhibit-quit t)
+       ans)
+    (let (message-log-max)
+      (while (not (memq ans '(?\  ?N ?Y ?\C-g ?\e ?\n ?\r ?n ?y)))
+       (message "%s(Y/n) " prompt)
+       (setq ans (read-char-exclusive))))
+    (if (memq ans '(?\C-g ?N ?n))
+       (progn
+         (message "%s(Y/n) No" prompt)
+         nil)
+      (message "%s(Y/n) Yes" prompt)
+      t)))
+
 (when (string-match "XEmacs\\|Lucid" emacs-version)
   (require 'nnheaderxm))