(require 'nnheader)
(require 'nnmail)
-(require 'gnus)
+(require 'gnus-start)
(require 'nnoo)
-(eval-and-compile (require 'cl))
+(require 'cl)
(nnoo-declare nnmh)
nnmh-current-directory)
(int-to-string
(setq article (pop articles))))))
-
(not (file-directory-p file)))
(insert (format "221 %d Article retrieved.\n" article))
(setq beg (point))
(nnheader-report 'nnmh "Selected group %s" group)
t)
(t
+ ;; Re-scan the directory if it's on a foreign system.
+ (nnheader-re-read-dir pathname)
(setq dir
(sort
(mapcar (lambda (name) (string-to-int name))
dir)
;; Recurse down directories.
(while (setq dir (pop dirs))
- (when (and (not (string-match "/\\.\\.?$" dir))
+ (when (and (not (member (file-name-nondirectory dir) '("." "..")))
(file-directory-p dir)
(file-readable-p dir))
(nnmh-request-list-1 dir))))
"%s %d %d y\n"
(progn
(string-match
- (file-truename (file-name-as-directory
- (expand-file-name nnmh-toplev))) dir)
+ (regexp-quote
+ (file-truename (file-name-as-directory
+ (expand-file-name nnmh-toplev)))) dir)
(nnheader-replace-chars-in-string
(substring dir (match-end 0)) ?/ ?.))
- (apply (function max) files)
- (apply (function min) files)))))))
+ (apply 'max files)
+ (apply 'min files)))))))
t)
(deffoo nnmh-request-newgroups (date &optional server)
(condition-case ()
(funcall nnmail-delete-file-function article)
(file-error
+ (nnheader-message 1 "Couldn't delete article %s in %s"
+ article newsgroup)
(setq rest (cons (car articles) rest)))))
(setq rest (cons (car articles) rest))))
(setq articles (cdr articles)))
(setq result (eval accept-form))
(kill-buffer (current-buffer))
result)
- (condition-case ()
- (funcall nnmail-delete-file-function
- (concat nnmh-current-directory (int-to-string article)))
- (file-error nil)))
+ (progn
+ (nnmh-possibly-change-directory group server)
+ (condition-case ()
+ (funcall nnmail-delete-file-function
+ (concat nnmh-current-directory (int-to-string article)))
+ (file-error nil))))
result))
(deffoo nnmh-request-accept-article (group &optional server last noinsert)
(nnmh-possibly-change-directory group server)
+ (nnmail-check-syntax)
(if (stringp group)
(and
(nnmail-activate 'nnmh)
(nnmh-possibly-create-directory group)
(condition-case ()
(progn
- (write-region (point-min) (point-max)
- (concat nnmh-current-directory (int-to-string article))
- nil (if (nnheader-be-verbose 5) nil 'nomesg))
+ (nnmail-write-region
+ (point-min) (point-max)
+ (concat nnmh-current-directory (int-to-string article))
+ nil (if (nnheader-be-verbose 5) nil 'nomesg))
t)
(error nil))))
(deffoo nnmh-request-rename-group (group new-name &optional server)
(nnmh-possibly-change-directory group server)
- ;; Rename directory.
- (and (file-writable-p nnmh-current-directory)
- (condition-case ()
- (progn
- (rename-file
- (directory-file-name nnmh-current-directory)
- (directory-file-name
- (nnmail-group-pathname new-name nnmh-directory)))
- t)
- (error nil))
- ;; That went ok, so we change the internal structures.
- (let ((entry (assoc group nnmh-group-alist)))
- (and entry (setcar entry new-name))
- (setq nnmh-current-directory nil)
- t)))
+ (let ((new-dir (nnmail-group-pathname new-name nnmh-directory))
+ (old-dir (nnmail-group-pathname group nnmh-directory)))
+ (when (condition-case ()
+ (progn
+ (make-directory new-dir t)
+ t)
+ (error nil))
+ ;; We move the articles file by file instead of renaming
+ ;; the directory -- there may be subgroups in this group.
+ ;; One might be more clever, I guess.
+ (let ((files (nnheader-article-to-file-alist old-dir)))
+ (while files
+ (rename-file
+ (concat old-dir (cdar files))
+ (concat new-dir (cdar files)))
+ (pop files)))
+ (when (<= (length (directory-files old-dir)) 2)
+ (condition-case ()
+ (delete-directory old-dir)
+ (error nil)))
+ ;; That went ok, so we change the internal structures.
+ (let ((entry (assoc group nnmh-group-alist)))
+ (and entry (setcar entry new-name))
+ (setq nnmh-current-directory nil)
+ t))))
\f
;;; Internal functions.
;; It was already saved, so we just make a hard link.
(funcall nnmail-crosspost-link-function first file t)
;; Save the article.
- (write-region (point-min) (point-max) file nil nil)
+ (nnmail-write-region (point-min) (point-max) file nil nil)
(setq first file)))
(setq ga (cdr ga))))
group-art))
(insert ";; Gnus article active file for " group "\n\n")
(insert "(setq nnmh-newsgroup-articles '")
(insert (prin1-to-string articles) ")\n")
- (write-region (point-min) (point-max) nnmh-file nil 'nomesg)
+ (nnmail-write-region (point-min) (point-max) nnmh-file nil 'nomesg)
(kill-buffer (current-buffer)))))
(defun nnmh-deletable-article-p (group article)