annotate lisp/gnus/nnheaderxm.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 360340f9fd5f
children 25f70ba0133c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nnheaderxm.el --- making Gnus backends work under XEmacs
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
28 (eval-and-compile
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
29 (autoload 'nnheader-insert-file-contents "nnheader"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
30
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defun nnheader-xmas-run-at-time (time repeat function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (start-itimer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "nnheader-run-at-time"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 `(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (,function ,@args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 time repeat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun nnheader-xmas-cancel-timer (timer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (delete-itimer timer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
41 (defun nnheader-xmas-cancel-function-timers (function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defun nnheader-xmas-find-file-noselect (filename &optional nowarn rawfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Read file FILENAME into a buffer and return the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 If a buffer exists visiting FILENAME, return that one, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 verify that the file has not changed since visited or saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 The buffer is not selected, just returned to the caller."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (setq filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (expand-file-name filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (if (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (if find-file-run-dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (dired-noselect filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (error "%s is a directory." filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let* ((buf (get-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (truename (abbreviate-file-name (file-truename filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (number (nthcdr 10 (file-attributes truename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; Find any buffer for a file which has same truename.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
60 (other (and (not buf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (get-file-buffer filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; Let user know if there is a buffer with the same truename.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
64 (when other
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
65 (or nowarn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
66 (string-equal filename (buffer-file-name other))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
67 (message "%s and %s are the same file"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
68 filename (buffer-file-name other)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
69 ;; Optionally also find that buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
70 (when (or (and (boundp 'find-file-existing-other-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
71 find-file-existing-other-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
72 find-file-visit-truename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 (setq buf other)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (or nowarn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (verify-visited-file-modtime buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (cond ((not (file-exists-p filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (error "File %s no longer exists!" filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ((yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (string= (file-name-nondirectory filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (buffer-name buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (buffer-modified-p buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "File %s changed on disk. Discard your edits? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "File %s changed on disk. Reread from disk? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (file-name-nondirectory filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if (buffer-modified-p buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "File %s changed on disk. Discard your edits in %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "File %s changed on disk. Reread from disk into %s? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (file-name-nondirectory filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (buffer-name buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (revert-buffer t t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; The truename stuff makes this obsolete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; (let* ((link-name (car (file-attributes filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; (linked-buf (and (stringp link-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; (get-file-buffer link-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; (if (bufferp linked-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; (message "Symbolic link to file in buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; (buffer-name linked-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq buf (create-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; (set-buffer-major-mode buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if rawfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (condition-case ()
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
110 (nnheader-insert-file-contents filename t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; Unconditionally set error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (insert-file-contents filename t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; Run find-file-not-found-hooks until one returns non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (or t ; (run-hook-with-args-until-success 'find-file-not-found-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; If they fail too, set error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq error t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; Find the file's truename, and maybe use that as visited name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq buffer-file-truename truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (setq buffer-file-number number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; On VMS, we may want to remember which directory in a search list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; the file was found in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (and (eq system-type 'vax-vms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let (logical)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
128 (when (string-match ":" (file-name-directory filename))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
129 (setq logical (substring (file-name-directory filename)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
130 0 (match-beginning 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (not (member logical find-file-not-true-dirname-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq buffer-file-name buffer-file-truename))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 (when find-file-visit-truename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 (setq buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
135 (setq filename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 (expand-file-name buffer-file-truename))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; Set buffer's default directory to that of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq default-directory (file-name-directory filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; Turn off backup files for certain file names. Since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; this is a permanent local, the major mode won't eliminate it.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
141 (when (not (funcall backup-enable-predicate buffer-file-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
142 (make-local-variable 'backup-inhibited)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
143 (setq backup-inhibited t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if rawfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (after-find-file error (not nowarn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (fset 'nnheader-run-at-time 'nnheader-xmas-run-at-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (fset 'nnheader-cancel-timer 'nnheader-xmas-cancel-timer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
151 (fset 'nnheader-cancel-function-timers 'nnheader-xmas-cancel-function-timers)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (fset 'nnheader-find-file-noselect 'nnheader-xmas-find-file-noselect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (provide 'nnheaderxm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; nnheaderxm.el ends here.