-(defun gnus-inews-do-fcc ()
- "Process FCC: fields in current article buffer.
-Unless the first character of the field is `|', the article is saved
-to the specified file using the function specified by the variable
-gnus-author-copy-saver. The default function rmail-output saves in
-Unix mailbox format.
-If the first character is `|', the contents of the article is send to
-a program specified by the rest of the value."
- (let ((fcc-list nil)
- (fcc-file nil)
- (case-fold-search t)) ;Should ignore case.
- (save-excursion
- (save-restriction
- (goto-char (point-min))
- (search-forward "\n\n")
- (narrow-to-region (point-min) (point))
- (goto-char (point-min))
- (while (re-search-forward "^FCC:[ \t]*" nil t)
- (setq fcc-list
- (cons (buffer-substring
- (point)
- (progn
- (end-of-line)
- (skip-chars-backward " \t")
- (point)))
- fcc-list))
- (delete-region (match-beginning 0)
- (progn (forward-line 1) (point))))
- ;; Process FCC operations.
- (widen)
- (while fcc-list
- (setq fcc-file (car fcc-list))
- (setq fcc-list (cdr fcc-list))
- (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
- (let ((program (substring fcc-file
- (match-beginning 1) (match-end 1))))
- ;; Suggested by yuki@flab.fujitsu.junet.
- ;; Send article to named program.
- (call-process-region (point-min) (point-max) shell-file-name
- nil nil nil "-c" program)))
- (t
- ;; Suggested by hyoko@flab.fujitsu.junet.
- ;; Save article in Unix mail format by default.
- (gnus-make-directory (file-name-directory fcc-file))
- (if (and gnus-author-copy-saver
- (not (eq gnus-author-copy-saver 'rmail-output)))
- (funcall gnus-author-copy-saver fcc-file)
- (if (and (file-readable-p fcc-file)
- (mail-file-babyl-p fcc-file))
- (gnus-output-to-rmail fcc-file)
- (rmail-output fcc-file 1 t t))))))))))
-
-(defun gnus-inews-path ()
- "Return uucp path."
- (let ((login-name (gnus-inews-login-name)))
- (cond ((null gnus-use-generic-path)
- (concat (nth 1 gnus-select-method) "!" login-name))
- ((stringp gnus-use-generic-path)
- ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
- (concat gnus-use-generic-path "!" login-name))
- (t login-name))))
-
-(defun gnus-inews-user-name ()
- "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
- (let ((full-name (gnus-inews-full-name))
- (address (if (or gnus-user-login-name gnus-use-generic-from
- gnus-local-domain (getenv "DOMAINNAME"))
- (concat (gnus-inews-login-name) "@"
- (gnus-inews-domain-name gnus-use-generic-from))
- user-mail-address)))
- (or gnus-user-from-line
- (concat address
- ;; User's full name.
- (cond ((string-equal full-name "&") ;Unix hack.
- (concat " (" (user-login-name) ")"))
- ((string-match "[^ ]+@[^ ]+ +(.*)" address)
- "")
- (t
- (concat " (" full-name ")")))))))
-
-(defun gnus-inews-real-user-address ()
- "Return the \"real\" user address.
-This function tries to ignore all user modifications, and
-give as trustworthy answer as possible."
- (concat (user-login-name) "@" (gnus-inews-full-address)))
-
-(defun gnus-inews-login-name ()
- "Return login name."
- (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
-
-(defun gnus-inews-full-name ()
- "Return full user name."
- (or gnus-user-full-name (getenv "NAME") (user-full-name)))
-
-(defun gnus-inews-domain-name (&optional genericfrom)
- "Return user's domain name.
-If optional argument GENERICFROM is a string, use it as the domain
-name; if it is non-nil, strip off local host name from the domain name.
-If the function `system-name' returns full internet name and the
-domain is undefined, the domain name is got from it."
- (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
- (let* ((system-name (system-name))
- (domain
- (or (if (stringp genericfrom) genericfrom)
- (getenv "DOMAINNAME")
- gnus-local-domain
- ;; Function `system-name' may return full internet name.
- ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
- (if (string-match "\\." system-name)
- (substring system-name (match-end 0)))
- (read-string "Domain name (no host): ")))
- (host (or (if (string-match "\\." system-name)
- (substring system-name 0 (match-beginning 0)))
- system-name)))
- (if (string-equal "." (substring domain 0 1))
- (setq domain (substring domain 1)))
- ;; Support GENERICFROM as same as standard Bnews system.
- ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
- (cond ((null genericfrom)
- (concat host "." domain))
- ;;((stringp genericfrom) genericfrom)
- (t domain)))
- (if (string-match "\\." (system-name))
- (system-name)
- (substring user-mail-address
- (1+ (string-match "@" user-mail-address))))))
-
-(defun gnus-inews-full-address ()
- (let ((domain (gnus-inews-domain-name))
- (system (system-name))
- (case-fold-search t))
- (if (string-match "\\." system) system
- (if (string-match (concat "^" (regexp-quote system)) domain) domain
- (concat system "." domain)))))
-
-(defun gnus-inews-message-id ()
- "Generate unique Message-ID for user."
- ;; Message-ID should not contain a slash and should be terminated by
- ;; a number. I don't know the reason why it is so.
- (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
-
-(defvar gnus-unique-id-char nil)
-
-;; If you ever change this function, make sure the new version
-;; cannot generate IDs that the old version could.
-;; You might for example insert a "." somewhere (not next to another dot
-;; or string boundary), or modify the newsreader name to "Ding".
-(defun gnus-inews-unique-id ()
- ;; Dont use microseconds from (current-time), they may be unsupported.
- ;; Instead we use this randomly inited counter.
- (setq gnus-unique-id-char
- (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
- ;; (current-time) returns 16-bit ints,
- ;; and 2^16*25 just fits into 4 digits i base 36.
- (* 25 25)))
- (let ((tm (if (fboundp 'current-time)
- (current-time) '(12191 46742 287898))))
- (concat
- (if (memq system-type '(ms-dos emx vax-vms))
- (let ((user (downcase (gnus-inews-login-name))))
- (while (string-match "[^a-z0-9_]" user)
- (aset user (match-beginning 0) ?_))
- user)
- (gnus-number-base36 (user-uid) -1))
- (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
- (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
- ;; Append the newsreader name, because while the generated
- ;; ID is unique to this newsreader, other newsreaders might
- ;; otherwise generate the same ID via another algorithm.
- ".fsf")))
-
-
-(defun gnus-inews-date ()
- "Current time string."
- (timezone-make-date-arpa-standard
- (current-time-string) (current-time-zone)))
-
-(defun gnus-inews-organization ()
- "Return user's organization.
-The ORGANIZATION environment variable is used if defined.
-If not, the variable `gnus-local-organization' is used instead.
-If it is a function, the function will be called with the current
-newsgroup name as the argument.
-If this is a file name, the contents of this file will be used as the
-organization."
- (let* ((organization
- (or (getenv "ORGANIZATION")
- (if gnus-local-organization
- (if (and (symbolp gnus-local-organization)
- (fboundp gnus-local-organization))
- (funcall gnus-local-organization gnus-newsgroup-name)
- gnus-local-organization))
- gnus-organization-file
- "~/.organization")))
- (and (stringp organization)
- (> (length organization) 0)
- (or (file-exists-p organization)
- (string-match " " organization)
- (not (string-match "^/usr/lib/" organization)))
- (save-excursion
- (gnus-set-work-buffer)
- (if (file-exists-p organization)
- (insert-file-contents organization)
- (insert organization))
- (goto-char (point-min))
- (while (re-search-forward " *\n *" nil t)
- (replace-match " " t t))
- (buffer-substring (point-min) (point-max))))))
-
-(defun gnus-inews-lines ()
- "Count the number of lines and return numeric string."
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (re-search-forward
- (concat "^" (regexp-quote mail-header-separator) "$"))
- (forward-line 1)
- (int-to-string (count-lines (point) (point-max))))))
-